mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
issue #144 - replace deprecated methods
This commit is contained in:
parent
c083b74ea7
commit
600087fd33
48 changed files with 398 additions and 379 deletions
|
|
@ -444,7 +444,7 @@ public class VehicleRoutingAlgorithms {
|
|||
if(firstAct){
|
||||
firstAct=false;
|
||||
if(!vehicle.isReturnToDepot()){
|
||||
assert activity.getLocationId().equals(end.getLocationId()) : "route end and last activity are not equal even route is open. this should not be.";
|
||||
assert activity.getLocation().getId().equals(end.getLocation().getId()) : "route end and last activity are not equal even route is open. this should not be.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Inserter {
|
|||
}
|
||||
|
||||
private void setEndLocation(VehicleRoute route, Service service) {
|
||||
route.getEnd().setLocationId(service.getLocationId());
|
||||
route.getEnd().setLocationId(service.getLocation().getId());
|
||||
}
|
||||
|
||||
public void setNextHandler(JobInsertionHandler jobInsertionHandler){
|
||||
|
|
@ -121,7 +121,7 @@ class Inserter {
|
|||
}
|
||||
|
||||
private void setEndLocation(VehicleRoute route, Shipment shipment) {
|
||||
route.getEnd().setLocationId(shipment.getDeliveryLocationId());
|
||||
route.getEnd().setLocationId(shipment.getDeliveryLocation().getId());
|
||||
}
|
||||
|
||||
public void setNextHandler(JobInsertionHandler jobInsertionHandler){
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -35,8 +35,8 @@ public class EuclideanServiceDistance implements JobDistance {
|
|||
} else {
|
||||
Service s_i = (Service) i;
|
||||
Service s_j = (Service) j;
|
||||
if(s_i.getCoord() == null || s_j.getCoord() == null) throw new IllegalStateException("cannot calculate euclidean distance. since service coords are missing");
|
||||
avgCost = EuclideanDistanceCalculator.calculateDistance(s_i.getCoord(), s_j.getCoord());
|
||||
if(s_i.getLocation().getCoordinate() == null || s_j.getLocation().getCoordinate() == null) throw new IllegalStateException("cannot calculate euclidean distance. since service coords are missing");
|
||||
avgCost = EuclideanDistanceCalculator.calculateDistance(s_i.getLocation().getCoordinate(), s_j.getLocation().getCoordinate());
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException(
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Stefan Schroeder.
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package jsprit.core.algorithm.state;
|
||||
|
||||
|
|
@ -36,7 +34,7 @@ public class UpdateEndLocationIfRouteIsOpen implements StateUpdater, RouteVisito
|
|||
private void setRouteEndToLastActivity(VehicleRoute route) {
|
||||
if(!route.getActivities().isEmpty()){
|
||||
TourActivity lastAct = route.getActivities().get(route.getActivities().size()-1);
|
||||
route.getEnd().setLocationId(lastAct.getLocationId());
|
||||
route.getEnd().setLocationId(lastAct.getLocation().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,12 +239,12 @@ public class VehicleRoutingProblem {
|
|||
|
||||
private void addLocationToTentativeLocations(Job job) {
|
||||
if(job instanceof Service) {
|
||||
tentative_coordinates.put(((Service)job).getLocationId(), ((Service)job).getCoord());
|
||||
tentative_coordinates.put(((Service)job).getLocation().getId(), ((Service)job).getLocation().getCoordinate());
|
||||
}
|
||||
else if(job instanceof Shipment){
|
||||
Shipment shipment = (Shipment)job;
|
||||
tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
|
||||
tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord());
|
||||
tentative_coordinates.put(shipment.getPickupLocation().getId(), shipment.getPickupLocation().getCoordinate());
|
||||
tentative_coordinates.put(shipment.getDeliveryLocation().getId(), shipment.getDeliveryLocation().getCoordinate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,11 +290,11 @@ public class VehicleRoutingProblem {
|
|||
}
|
||||
|
||||
private void registerLocation(Job job) {
|
||||
if (job instanceof Service) tentative_coordinates.put(((Service) job).getLocationId(), ((Service) job).getCoord());
|
||||
if (job instanceof Service) tentative_coordinates.put(((Service) job).getLocation().getId(), ((Service) job).getLocation().getCoordinate());
|
||||
if (job instanceof Shipment) {
|
||||
Shipment shipment = (Shipment) job;
|
||||
tentative_coordinates.put(shipment.getPickupLocationId(), shipment.getPickupCoord());
|
||||
tentative_coordinates.put(shipment.getDeliveryLocationId(), shipment.getDeliveryCoord());
|
||||
tentative_coordinates.put(shipment.getPickupLocation().getId(), shipment.getPickupLocation().getCoordinate());
|
||||
tentative_coordinates.put(shipment.getDeliveryLocation().getId(), shipment.getDeliveryLocation().getCoordinate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -322,8 +322,8 @@ public class VehicleRoutingProblem {
|
|||
|
||||
private void addShipment(Shipment job) {
|
||||
if(jobs.containsKey(job.getId())){ logger.warn("job " + job + " already in job list. overrides existing job."); }
|
||||
tentative_coordinates.put(job.getPickupLocationId(), job.getPickupCoord());
|
||||
tentative_coordinates.put(job.getDeliveryLocationId(), job.getDeliveryCoord());
|
||||
tentative_coordinates.put(job.getPickupLocation().getId(), job.getPickupLocation().getCoordinate());
|
||||
tentative_coordinates.put(job.getDeliveryLocation().getId(), job.getDeliveryLocation().getCoordinate());
|
||||
jobs.put(job.getId(),job);
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ public class VehicleRoutingProblem {
|
|||
}
|
||||
|
||||
private Builder addService(Service service){
|
||||
tentative_coordinates.put(service.getLocationId(), service.getCoord());
|
||||
tentative_coordinates.put(service.getLocation().getId(), service.getLocation().getCoordinate());
|
||||
if(jobs.containsKey(service.getId())){ logger.warn("service " + service + " already in job list. overrides existing job."); }
|
||||
jobs.put(service.getId(),service);
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return delivery.getLocationId();
|
||||
return delivery.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return shipment.getDeliveryLocationId();
|
||||
return shipment.getDeliveryLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public final class End extends AbstractActivity implements TourActivity {
|
|||
|
||||
public End(End end) {
|
||||
this.location = end.getLocation();
|
||||
// this.locationId = end.getLocationId();
|
||||
// this.locationId = end.getLocation().getId();
|
||||
theoretical_earliestOperationStartTime = end.getTheoreticalEarliestOperationStartTime();
|
||||
theoretical_latestOperationStartTime = end.getTheoreticalLatestOperationStartTime();
|
||||
arrTime = end.getArrTime();
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public final class PickupService extends AbstractActivity implements PickupActiv
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return pickup.getLocationId();
|
||||
return pickup.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return shipment.getPickupLocationId();
|
||||
return shipment.getPickupLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class ServiceActivity extends AbstractActivity implements JobActivity{
|
|||
|
||||
@Override
|
||||
public String getLocationId() {
|
||||
return service.getLocationId();
|
||||
return service.getLocation().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
|
@ -56,18 +56,18 @@ public class NeighborhoodImpl implements Neighborhood{
|
|||
for(Service i : services){
|
||||
Set<String> neigh = new HashSet<String>();
|
||||
for(Vehicle v : vehicles){
|
||||
double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getCoord());
|
||||
double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getLocation().getCoordinate());
|
||||
if(dist2depot <= threshold){
|
||||
neighborsToAll.add(((Service)i).getLocationId());
|
||||
neighborsToAll.add(((Service)i).getLocation().getId());
|
||||
}
|
||||
}
|
||||
for(Service j : services){
|
||||
double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getCoord(), j.getCoord());
|
||||
double crowFlyDistance = EuclideanDistanceCalculator.calculateDistance(i.getLocation().getCoordinate(), j.getLocation().getCoordinate());
|
||||
if(crowFlyDistance <= threshold) {
|
||||
neigh.add(((Service)j).getLocationId());
|
||||
neigh.add(((Service)j).getLocation().getId());
|
||||
}
|
||||
}
|
||||
neighbors.put(((Service)i).getLocationId(), neigh);
|
||||
neighbors.put(((Service)i).getLocation().getId(), neigh);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue