diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java index 11be2212..76c64d94 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java @@ -85,7 +85,7 @@ final class VehicleTypeDependentJobInsertionCalculator implements JobInsertionCo if(!(selectedVehicle instanceof NoVehicle)) { relevantVehicles.add(selectedVehicle); if(vehicleSwitchAllowed){ - relevantVehicles.addAll(fleetManager.getAvailableVehicles(selectedVehicle.getType().getTypeId(),selectedVehicle.getLocationId())); + relevantVehicles.addAll(fleetManager.getAvailableVehicles(selectedVehicle)); } } else{ //if no vehicle has been assigned, i.e. it is an empty route diff --git a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java index 86768bfe..94b5c947 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java @@ -396,7 +396,7 @@ public class VehicleRoutingProblem { PenaltyVehicleType penType = new PenaltyVehicleType(t,penaltyFactor); String vehicleId = "penaltyVehicle_" + v.getStartLocationId() + "_" + t.getTypeId(); Vehicle penVehicle = VehicleImpl.Builder.newInstance(vehicleId).setEarliestStart(v.getEarliestDeparture()) - .setLatestArrival(v.getLatestArrival()).setStartLocationCoordinate(v.getStartLocationCoordinate()).setLocationId(v.getStartLocationId()) + .setLatestArrival(v.getLatestArrival()).setStartLocationCoordinate(v.getStartLocationCoordinate()).setStartLocationId(v.getStartLocationId()) .setEndLocationId(v.getEndLocationId()).setEndLocationCoordinate(v.getEndLocationCoordinate()) .setReturnToDepot(v.isReturnToDepot()).setType(penType).build(); addVehicle(penVehicle); diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/InfiniteVehicles.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/InfiniteVehicles.java index 6cba846f..f46d6ce3 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/InfiniteVehicles.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/InfiniteVehicles.java @@ -45,7 +45,7 @@ class InfiniteVehicles implements VehicleFleetManager{ private void extractTypes(Collection vehicles) { for(Vehicle v : vehicles){ - VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(),v.getLocationId()); + VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(),v.getEndLocationId()); types.put(typeKey,v); sortedTypes.add(typeKey); @@ -79,10 +79,26 @@ class InfiniteVehicles implements VehicleFleetManager{ return types.values(); } + /** + * @deprecated use getAvailableVehicles(Vehicle withoutThisType) instead + */ @Override + @Deprecated public Collection getAvailableVehicles(String withoutThisType, String locationId) { Collection vehicles = new ArrayList(); - VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType,locationId); + VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType, locationId,locationId); + for(VehicleTypeKey key : types.keySet()){ + if(!key.equals(thisKey)){ + vehicles.add(types.get(key)); + } + } + return vehicles; + } + + @Override + public Collection getAvailableVehicles(Vehicle withoutThisType) { + Collection vehicles = new ArrayList(); + VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocationId(), withoutThisType.getEndLocationId()); for(VehicleTypeKey key : types.keySet()){ if(!key.equals(thisKey)){ vehicles.add(types.get(key)); diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManager.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManager.java index 6d545e42..6eeee1ae 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManager.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManager.java @@ -31,6 +31,16 @@ public interface VehicleFleetManager { public abstract Collection getAvailableVehicles(); + /** + * + * @param withoutThisType + * @param locationId + * @return + * @deprecated use .getAvailableVehicles(Vehicle without) instead. this might ignore withoutType and returns all available vehicles + */ + @Deprecated public Collection getAvailableVehicles(String withoutThisType, String locationId); + + public Collection getAvailableVehicles(Vehicle withoutThisType); } diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManagerImpl.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManagerImpl.java index 31ee75c4..8e1d303e 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManagerImpl.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleFleetManagerImpl.java @@ -132,11 +132,11 @@ class VehicleFleetManagerImpl implements VehicleFleetManager { } String typeId = v.getType().getTypeId(); if(v.getType() instanceof PenaltyVehicleType){ - VehicleTypeKey typeKey = new VehicleTypeKey(typeId,v.getLocationId()); + VehicleTypeKey typeKey = new VehicleTypeKey(typeId, v.getStartLocationId(), v.getEndLocationId()); penaltyVehicles.put(typeKey, v); } else{ - VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(),v.getLocationId()); + VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(), v.getEndLocationId()); if(!typeMapOfAvailableVehicles.containsKey(typeKey)){ typeMapOfAvailableVehicles.put(typeKey, new TypeContainer(typeKey)); } @@ -147,7 +147,7 @@ class VehicleFleetManagerImpl implements VehicleFleetManager { private void removeVehicle(Vehicle v){ //it might be better to introduce a class PenaltyVehicle if(!(v.getType() instanceof PenaltyVehicleType)){ - VehicleTypeKey key = new VehicleTypeKey(v.getType().getTypeId(),v.getLocationId()); + VehicleTypeKey key = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocationId(), v.getEndLocationId()); if(typeMapOfAvailableVehicles.containsKey(key)){ typeMapOfAvailableVehicles.get(key).remove(v); } @@ -186,11 +186,13 @@ class VehicleFleetManagerImpl implements VehicleFleetManager { * @param typeId to specify the typeId that should not be the returned collection * @param locationId to specify the locationId that should not be in the returned collection * @return collection of available vehicles without the vehicles that have the typeId 'withoutThisType' AND the locationId 'withThisLocation'. + * @deprecated use .getAvailableVehicles(Vehicle without) instead - this might ignore withoutThisType and returns all available vehicles */ @Override + @Deprecated public Collection getAvailableVehicles(String withoutThisType, String withThisLocationId) { List vehicles = new ArrayList(); - VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType,withThisLocationId); + VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType, withThisLocationId, withThisLocationId); for(VehicleTypeKey key : typeMapOfAvailableVehicles.keySet()){ if(key.equals(thisKey)) continue; if(!typeMapOfAvailableVehicles.get(key).isEmpty()){ @@ -207,6 +209,24 @@ class VehicleFleetManagerImpl implements VehicleFleetManager { + @Override + public Collection getAvailableVehicles(Vehicle withoutThisType) { + List vehicles = new ArrayList(); + VehicleTypeKey thisKey = new VehicleTypeKey(withoutThisType.getType().getTypeId(), withoutThisType.getStartLocationId(), withoutThisType.getEndLocationId()); + for(VehicleTypeKey key : typeMapOfAvailableVehicles.keySet()){ + if(key.equals(thisKey)) continue; + if(!typeMapOfAvailableVehicles.get(key).isEmpty()){ + vehicles.add(typeMapOfAvailableVehicles.get(key).getVehicle()); + } + else{ + if(penaltyVehicles.containsKey(key)){ + vehicles.add(penaltyVehicles.get(key)); + } + } + } + return vehicles; + } + /* (non-Javadoc) * @see org.matsim.contrib.freight.vrp.basics.VehicleFleetManager#lock(org.matsim.contrib.freight.vrp.basics.Vehicle) */ diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java index 5a50813f..92e69358 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleImpl.java @@ -136,7 +136,9 @@ public class VehicleImpl implements Vehicle { * * @param id * @return this builder + * @deprecated use setStartLocationId(..) instead */ + @Deprecated public Builder setLocationId(String id){ this.locationId = id; this.startLocationId = id; @@ -150,7 +152,9 @@ public class VehicleImpl implements Vehicle { * * @param coord * @return this builder + * @deprecated use setStartLocationCoordinate(...) instead */ + @Deprecated public Builder setLocationCoord(Coordinate coord){ this.locationCoord = coord; this.startLocationCoord = coord; diff --git a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java index a39907df..7a9e82dd 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/vehicle/VehicleTypeKey.java @@ -1,26 +1,45 @@ package jsprit.core.problem.vehicle; +/** + * Key to identify different vehicles + * + *

Two vehicles are equal if they share the same type and location. + *

Note that earliestStart and latestArrival are ignored by this key (this might change in future) + * + * @author stefan + * + */ class VehicleTypeKey { public final String type; - public final String locationId; + public final String startLocationId; + public final String endLocationId; - VehicleTypeKey(String typeId, String locationId) { + VehicleTypeKey(String typeId, String startLocationId, String endLocationId) { super(); this.type = typeId; - this.locationId = locationId; + this.startLocationId = startLocationId; + this.endLocationId = endLocationId; } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result - + ((locationId == null) ? 0 : locationId.hashCode()); + + ((endLocationId == null) ? 0 : endLocationId.hashCode()); + result = prime * result + + ((startLocationId == null) ? 0 : startLocationId.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; } + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object obj) { if (this == obj) @@ -30,10 +49,15 @@ class VehicleTypeKey { if (getClass() != obj.getClass()) return false; VehicleTypeKey other = (VehicleTypeKey) obj; - if (locationId == null) { - if (other.locationId != null) + if (endLocationId == null) { + if (other.endLocationId != null) return false; - } else if (!locationId.equals(other.locationId)) + } else if (!endLocationId.equals(other.endLocationId)) + return false; + if (startLocationId == null) { + if (other.startLocationId != null) + return false; + } else if (!startLocationId.equals(other.startLocationId)) return false; if (type == null) { if (other.type != null) @@ -43,6 +67,6 @@ class VehicleTypeKey { return true; } - + } \ No newline at end of file diff --git a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java b/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java index 393289dc..61fdbaf9 100644 --- a/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java +++ b/jsprit-core/src/main/java/jsprit/core/util/NeighborhoodImpl.java @@ -62,7 +62,7 @@ public class NeighborhoodImpl implements Neighborhood{ for(Service i : services){ Set neigh = new HashSet(); for(Vehicle v : vehicles){ - double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getCoord(), i.getCoord()); + double dist2depot = EuclideanDistanceCalculator.calculateDistance(v.getStartLocationCoordinate(), i.getCoord()); if(dist2depot <= threshold){ neighborsToAll.add(((Service)i).getLocationId()); } @@ -80,7 +80,7 @@ public class NeighborhoodImpl implements Neighborhood{ private void makeNeighborsToAll(Collection vehicles) { for(Vehicle v : vehicles){ - neighborsToAll.add(v.getLocationId()); + neighborsToAll.add(v.getStartLocationId()); } } diff --git a/jsprit-core/src/main/java/jsprit/core/util/VrpVerifier.java b/jsprit-core/src/main/java/jsprit/core/util/VrpVerifier.java index 783e428b..3e6b9309 100644 --- a/jsprit-core/src/main/java/jsprit/core/util/VrpVerifier.java +++ b/jsprit-core/src/main/java/jsprit/core/util/VrpVerifier.java @@ -21,15 +21,21 @@ import java.util.Collection; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.listener.AlgorithmStartsListener; import jsprit.core.problem.VehicleRoutingProblem; -import jsprit.core.problem.driver.DriverImpl; import jsprit.core.problem.job.Job; -import jsprit.core.problem.job.Service; import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.vehicle.Vehicle; import org.apache.log4j.Logger; - +/** + * Verifies whether vrp can be solved. + * + *

Checks
+ * - capacities, i.e. whether all job at least fit into the biggest vehicle + * + * @author stefan + * + */ public class VrpVerifier implements AlgorithmStartsListener{ private static Logger log = Logger.getLogger(VrpVerifier.class); @@ -47,26 +53,26 @@ public class VrpVerifier implements AlgorithmStartsListener{ } } log.info("ok"); - log.info("check vehicles can manage shuttle tours ..."); - for(Job j : problem.getJobs().values()){ - Service s = (Service)j; - boolean jobCanBeRoutedWithinTimeWindow = false; - for(Vehicle v : problem.getVehicles()){ - double transportTime = problem.getTransportCosts().getTransportTime(v.getLocationId(), s.getLocationId(), v.getEarliestDeparture(), DriverImpl.noDriver(), v); - if(transportTime+v.getEarliestDeparture() < s.getTimeWindow().getEnd()){ - jobCanBeRoutedWithinTimeWindow = true; - break; - } - else{ - log.warn("vehicle " + v + " needs " + transportTime + " time-units to get to " + s.getLocationId() + ". latestOperationStartTime however is " + s.getTimeWindow().getEnd()); - } - - } - if(!jobCanBeRoutedWithinTimeWindow){ - throw new IllegalStateException("no vehicle is able to cover the distance from depot to " + s.getLocationId() + " to meet the time-window " + s.getTimeWindow() + "."); - } - } - log.info("ok"); +// log.info("check vehicles can manage shuttle tours ..."); +// for(Job j : problem.getJobs().values()){ +// Service s = (Service)j; +// boolean jobCanBeRoutedWithinTimeWindow = false; +// for(Vehicle v : problem.getVehicles()){ +// double transportTime = problem.getTransportCosts().getTransportTime(v.getStartLocationId(), s.getLocationId(), v.getEarliestDeparture(), DriverImpl.noDriver(), v); +// if(transportTime+v.getEarliestDeparture() < s.getTimeWindow().getEnd()){ +// jobCanBeRoutedWithinTimeWindow = true; +// break; +// } +// else{ +// log.warn("vehicle " + v + " needs " + transportTime + " time-units to get to " + s.getLocationId() + ". latestOperationStartTime however is " + s.getTimeWindow().getEnd()); +// } +// +// } +// if(!jobCanBeRoutedWithinTimeWindow){ +// throw new IllegalStateException("no vehicle is able to cover the distance from depot to " + s.getLocationId() + " to meet the time-window " + s.getTimeWindow() + "."); +// } +// } +// log.info("ok"); log.info("verifying done"); } diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java index ccf9ffbf..3f0c36c4 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/RefuseCollection_IT.java @@ -153,7 +153,7 @@ public class RefuseCollection_IT { VehicleTypeImpl bigType = typeBuilder.build(); VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); - vehicleBuilder.setLocationId("1"); + vehicleBuilder.setStartLocationId("1"); vehicleBuilder.setType(bigType); Vehicle bigVehicle = vehicleBuilder.build(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/CalcWithTimeSchedulingTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/CalcWithTimeSchedulingTest.java index 8c175cf2..05338448 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/CalcWithTimeSchedulingTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/CalcWithTimeSchedulingTest.java @@ -43,7 +43,7 @@ public class CalcWithTimeSchedulingTest { public void timeScheduler(){ VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); Vehicle vehicle = VehicleImpl.Builder.newInstance("myVehicle").setEarliestStart(0.0).setLatestArrival(100.0). - setLocationCoord(Coordinate.newInstance(0, 0)).setLocationId("0,0") + setStartLocationCoordinate(Coordinate.newInstance(0, 0)).setStartLocationId("0,0") .setType(VehicleTypeImpl.Builder.newInstance("myType", 20).setCostPerDistance(1.0).build()).build(); vrpBuilder.addVehicle(vehicle); vrpBuilder.addJob(Service.Builder.newInstance("myService", 2).setLocationId("0,20").setCoord(Coordinate.newInstance(0, 20)).build()); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java index 874264dc..f5f00b17 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ServiceInsertionAndLoadConstraintsTest.java @@ -91,7 +91,7 @@ public class ServiceInsertionAndLoadConstraintsTest { }; routingCosts = new ManhattanCosts(locations); VehicleType type = VehicleTypeImpl.Builder.newInstance("t", 2).setCostPerDistance(1).build(); - vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("0,0").setType(type).build(); + vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build(); activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts); createInsertionCalculator(hardRouteLevelConstraint); } @@ -106,7 +106,7 @@ public class ServiceInsertionAndLoadConstraintsTest { Pickup pickup = (Pickup) Pickup.Builder.newInstance("pick", 15).setLocationId("0,10").build(); VehicleType type = VehicleTypeImpl.Builder.newInstance("t", 50).setCostPerDistance(1).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("0,0").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build(); VehicleRoute route = VehicleRoute.emptyRoute(); route.setVehicleAndDepartureTime(vehicle, 0.0); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java index 655e754e..9f13405e 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculatorTest.java @@ -87,7 +87,7 @@ public class ShipmentInsertionCalculatorTest { }; routingCosts = new ManhattanCosts(locations); VehicleType type = VehicleTypeImpl.Builder.newInstance("t", 2).setCostPerDistance(1).build(); - vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("0,0").setType(type).build(); + vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("0,0").setType(type).build(); activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts); createInsertionCalculator(hardRouteLevelConstraint); } diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java index a83b58a7..2aa213e5 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestDepartureTimeOpt.java @@ -45,7 +45,7 @@ public class TestDepartureTimeOpt { public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50(){ TimeWindow timeWindow = TimeWindow.newInstance(40, 45); Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); @@ -72,7 +72,7 @@ public class TestDepartureTimeOpt { public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0(){ TimeWindow timeWindow = TimeWindow.newInstance(40, 45); Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); @@ -99,7 +99,7 @@ public class TestDepartureTimeOpt { public void whenSettingOneCustWithTWAndDepTimeChoice_totalCostsShouldBe50(){ TimeWindow timeWindow = TimeWindow.newInstance(40, 45); Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); @@ -127,7 +127,7 @@ public class TestDepartureTimeOpt { public void whenSettingOneCustWithTWAndDepTimeChoice_depTimeShouldBe0(){ TimeWindow timeWindow = TimeWindow.newInstance(40, 45); Service service = Service.Builder.newInstance("s", 0).setLocationId("servLoc").setCoord(Coordinate.newInstance(0, 10)).setTimeWindow(timeWindow).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); @@ -159,7 +159,7 @@ public class TestDepartureTimeOpt { Service service2 = Service.Builder.newInstance("s2", 0).setLocationId("servLoc2").setCoord(Coordinate.newInstance(0, 20)). setTimeWindow(TimeWindow.newInstance(30, 40)).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); @@ -191,7 +191,7 @@ public class TestDepartureTimeOpt { Service service2 = Service.Builder.newInstance("s2", 0).setLocationId("servLoc2").setCoord(Coordinate.newInstance(0, 20)). setTimeWindow(TimeWindow.newInstance(30, 40)).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("vehLoc").setLocationCoord(Coordinate.newInstance(0, 0)) + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("vehLoc").setStartLocationCoordinate(Coordinate.newInstance(0, 0)) .setType(VehicleTypeImpl.Builder.newInstance("vType", 0).build()).build(); Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java index 4a1d3228..74a90766 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestInserter.java @@ -127,8 +127,8 @@ public class TestInserter { @Test public void whenSwitchingVehicleAndRouteIsClosed_newStartAndEndShouldBeTheLocationOfNewVehicle(){ Shipment shipment = mock(Shipment.class); - Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setLocationId("vehLoc").setType(mock(VehicleType.class)).build(); - Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build(); + Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build(); //start - pick(shipment) - del(shipment) - end @@ -150,8 +150,8 @@ public class TestInserter { @Test public void whenSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){ Shipment shipment = mock(Shipment.class); - Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setLocationId("vehLoc").setType(mock(VehicleType.class)).build(); - Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build(); + Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build(); //start - pick(shipment) - del(shipment) - end @@ -174,8 +174,8 @@ public class TestInserter { public void whenInsertingShipmentAtBeginningAndSwitchingVehicleAndRouteIsOpen_endLocationShouldBeTheLocationOfTheLastActivity(){ Shipment shipment = mock(Shipment.class); when(shipment.getDeliveryLocation()).thenReturn("oldShipmentDelLoc"); - Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setLocationId("vehLoc").setType(mock(VehicleType.class)).build(); - Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("vehId").setReturnToDepot(false).setStartLocationId("vehLoc").setType(mock(VehicleType.class)).build(); + Vehicle newVehicle = VehicleImpl.Builder.newInstance("newVehId").setReturnToDepot(false).setStartLocationId("newVehLoc").setType(mock(VehicleType.class)).build(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)).addPickup(shipment).addDelivery(shipment).build(); //start - pick(shipment) - del(shipment) - end diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestMixedServiceAndShipmentsProblemOnRouteLevel.java b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestMixedServiceAndShipmentsProblemOnRouteLevel.java index 7cbf8fa3..042901a1 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestMixedServiceAndShipmentsProblemOnRouteLevel.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/recreate/TestMixedServiceAndShipmentsProblemOnRouteLevel.java @@ -36,7 +36,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel { * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" */ Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); - vehicleBuilder.setLocationCoord(Coordinate.newInstance(10, 10)); + vehicleBuilder.setStartLocationCoordinate(Coordinate.newInstance(10, 10)); vehicleBuilder.setType(vehicleType); Vehicle vehicle = vehicleBuilder.build(); @@ -101,7 +101,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel { * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" */ Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); - vehicleBuilder.setLocationCoord(Coordinate.newInstance(10, 10)); + vehicleBuilder.setStartLocationCoordinate(Coordinate.newInstance(10, 10)); vehicleBuilder.setType(vehicleType); Vehicle vehicle = vehicleBuilder.build(); diff --git a/jsprit-core/src/test/java/jsprit/core/algorithm/state/TestTourStateUpdaterWithService.java b/jsprit-core/src/test/java/jsprit/core/algorithm/state/TestTourStateUpdaterWithService.java index 3498829a..ed15514b 100644 --- a/jsprit-core/src/test/java/jsprit/core/algorithm/state/TestTourStateUpdaterWithService.java +++ b/jsprit-core/src/test/java/jsprit/core/algorithm/state/TestTourStateUpdaterWithService.java @@ -107,7 +107,7 @@ public class TestTourStateUpdaterWithService { services.add(secondService); VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("test", 10).build(); - vehicle = VehicleImpl.Builder.newInstance("testvehicle").setType(type).setLocationId("0,0") + vehicle = VehicleImpl.Builder.newInstance("testvehicle").setType(type).setStartLocationId("0,0") .setEarliestStart(0.0).setLatestArrival(50.0).build(); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java index 62728eb7..0261aec2 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/VehicleRoutingProblemTest.java @@ -101,10 +101,10 @@ public class VehicleRoutingProblemTest { VehicleTypeImpl type1 = mock(VehicleTypeImpl.class); VehicleTypeImpl type2 = mock(VehicleTypeImpl.class); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("yo").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("yo").setType(type1).build(); - Vehicle v3 = VehicleImpl.Builder.newInstance("v3").setLocationId("yo").setType(type2).build(); - Vehicle v4 = VehicleImpl.Builder.newInstance("v4").setLocationId("yo").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("yo").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("yo").setType(type1).build(); + Vehicle v3 = VehicleImpl.Builder.newInstance("v3").setStartLocationId("yo").setType(type2).build(); + Vehicle v4 = VehicleImpl.Builder.newInstance("v4").setStartLocationId("yo").setType(type2).build(); builder.addVehicle(v1).addVehicle(v2).addVehicle(v3).addVehicle(v4); @@ -286,7 +286,7 @@ public class VehicleRoutingProblemTest { public void whenAddingAVehicle_getAddedVehicleTypesShouldReturnItsType(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); assertEquals(1,builder.getAddedVehicleTypes().size()); @@ -298,8 +298,8 @@ public class VehicleRoutingProblemTest { public void whenAddingTwoVehicleWithSameType_getAddedVehicleTypesShouldReturnOnlyOneType(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); @@ -314,8 +314,8 @@ public class VehicleRoutingProblemTest { VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); VehicleType type2 = VehicleTypeImpl.Builder.newInstance("type2", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type2).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); @@ -328,7 +328,7 @@ public class VehicleRoutingProblemTest { public void whenSettingAddPenaltyVehicleOptions_itShouldAddPenaltyVehicle(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); builder.setFleetSize(FleetSize.FINITE); @@ -350,7 +350,7 @@ public class VehicleRoutingProblemTest { public void whenSettingAddPenaltyVehicleOptionsAndFleetSizeIsInfinite_noPenaltyVehicleIsAdded(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); builder.addPenaltyVehicles(3.0); @@ -371,8 +371,8 @@ public class VehicleRoutingProblemTest { public void whenSettingAddPenaltyVehicleOptionsAndTwoVehiclesWithSameLocationAndType_onlyOnePenaltyVehicleIsAdded(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); @@ -395,8 +395,8 @@ public class VehicleRoutingProblemTest { public void whenSettingAddPenaltyVehicleOptionsWithAbsoluteFixedCostsAndTwoVehiclesWithSameLocationAndType_onePenaltyVehicleIsAddedWithTheCorrectPenaltyFixedCosts(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); @@ -421,8 +421,8 @@ public class VehicleRoutingProblemTest { public void whenSettingAddPenaltyVehicleOptionsAndTwoVehiclesWithDiffLocationAndType_twoPenaltyVehicleIsAdded(){ VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc2").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc2").setType(type).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); @@ -449,8 +449,8 @@ public class VehicleRoutingProblemTest { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 0).build(); VehicleType type2 = VehicleTypeImpl.Builder.newInstance("type2", 0).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(type).build(); - Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(type).build(); + Vehicle vehicle2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(vehicle); builder.addVehicle(vehicle2); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpWriterV2Test.java b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpWriterV2Test.java index 4011c074..6954f1ed 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/io/VrpWriterV2Test.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/io/VrpWriterV2Test.java @@ -51,7 +51,7 @@ public class VrpWriterV2Test { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); builder.setFleetSize(FleetSize.INFINITE); VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("myVehicle").setLocationId("loc").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("myVehicle").setStartLocationId("loc").setType(type).build(); builder.addVehicle(vehicle); VehicleRoutingProblem vrp = builder.build(); new VrpXMLWriter(vrp, null).write(infileName); @@ -63,8 +63,8 @@ public class VrpWriterV2Test { builder.setFleetSize(FleetSize.FINITE); VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); VehicleRoutingProblem vrp = builder.build(); @@ -77,8 +77,8 @@ public class VrpWriterV2Test { builder.setFleetSize(FleetSize.FINITE); VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); VehicleRoutingProblem vrp = builder.build(); @@ -94,8 +94,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -124,8 +124,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -155,8 +155,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -187,8 +187,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -218,8 +218,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -249,8 +249,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -278,8 +278,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -311,8 +311,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -339,8 +339,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -365,8 +365,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -391,8 +391,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build(); + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("loc").setType(type2).build(); builder.addVehicle(v1); builder.addVehicle(v2); @@ -419,8 +419,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setLocationCoord(Coordinate.newInstance(1, 2)) + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setStartLocationCoordinate(Coordinate.newInstance(1, 2)) .setEndLocationId("endLoc").setEndLocationCoordinate(Coordinate.newInstance(4, 5)).setType(type2).build(); builder.addVehicle(v1); @@ -447,8 +447,8 @@ public class VrpWriterV2Test { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build(); VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build(); - Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setLocationId("loc").setType(type1).build(); - Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setLocationCoord(Coordinate.newInstance(1, 2)) + Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setReturnToDepot(false).setStartLocationId("loc").setType(type1).build(); + Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setStartLocationId("startLoc").setStartLocationCoordinate(Coordinate.newInstance(1, 2)) .setEndLocationId("endLoc").setEndLocationCoordinate(Coordinate.newInstance(4, 5)).setType(type2).build(); builder.addVehicle(v1); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java index 15047e17..44307d44 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/TestVehicleRoute.java @@ -41,7 +41,7 @@ public class TestVehicleRoute { @Before public void doBefore(){ - vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("yo", 0).build()).build(); + vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("yo", 0).build()).build(); driver = DriverImpl.noDriver(); } @@ -194,14 +194,14 @@ public class TestVehicleRoute { @Test public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectStartLocationV2(){ - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); assertTrue(vRoute.getStart().getLocationId().equals("start")); } @Test public void whenBuildingRouteWithVehicleThatHasSameStartAndEndLocation_routeMustHaveCorrectEndLocationV2(){ - Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setLocationId("start").setEndLocationId("start").build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocationId("start").setEndLocationId("start").build(); VehicleRoute vRoute = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); assertTrue(vRoute.getEnd().getLocationId().equals("start")); } diff --git a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java index 6833be64..7a2800c6 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/TestVehicleFleetManagerImpl.java @@ -39,8 +39,8 @@ public class TestVehicleFleetManagerImpl extends TestCase{ public void setUp(){ List vehicles = new ArrayList(); - v1 = VehicleImpl.Builder.newInstance("standard").setLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("standard", 0).build()).build(); - v2 = VehicleImpl.Builder.newInstance("foo").setLocationId("fooLoc").setType(VehicleTypeImpl.Builder.newInstance("foo", 0).build()).build(); + v1 = VehicleImpl.Builder.newInstance("standard").setStartLocationId("loc").setType(VehicleTypeImpl.Builder.newInstance("standard", 0).build()).build(); + v2 = VehicleImpl.Builder.newInstance("foo").setStartLocationId("fooLoc").setType(VehicleTypeImpl.Builder.newInstance("foo", 0).build()).build(); // v1. vehicles.add(v1); @@ -75,7 +75,7 @@ public class TestVehicleFleetManagerImpl extends TestCase{ } public void testGetVehiclesWithout(){ - Collection vehicles = fleetManager.getAvailableVehicles(v1.getType().getTypeId(),v1.getLocationId()); + Collection vehicles = fleetManager.getAvailableVehicles(v1); assertEquals(v2, vehicles.iterator().next()); assertEquals(1, vehicles.size()); @@ -91,7 +91,7 @@ public class TestVehicleFleetManagerImpl extends TestCase{ } public void testWithPenalty_whenHavingOneRegularVehicleAvailable_noPenaltyVehicleIsReturn(){ - Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setLocationId("loc"). + Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc"). setType(VehicleTypeImpl.Builder.newInstance("standard", 0).build()).build(); List vehicles = new ArrayList(); @@ -108,10 +108,10 @@ public class TestVehicleFleetManagerImpl extends TestCase{ VehicleTypeImpl penaltyType = VehicleTypeImpl.Builder.newInstance("standard", 0).build(); PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType); - Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setLocationId("loc"). + Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc"). setType(penaltyVehicleType).build(); - Vehicle v3 = VehicleImpl.Builder.newInstance("standard_v3").setLocationId("loc"). + Vehicle v3 = VehicleImpl.Builder.newInstance("standard_v3").setStartLocationId("loc"). setType(penaltyType).build(); List vehicles = new ArrayList(); @@ -130,7 +130,7 @@ public class TestVehicleFleetManagerImpl extends TestCase{ public void testWithPenalty_whenHavingNoRegularVehicleAvailable_penaltyVehicleIsReturned(){ VehicleTypeImpl penaltyType = VehicleTypeImpl.Builder.newInstance("standard", 0).build(); - Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setLocationId("loc"). + Vehicle penalty4standard = VehicleImpl.Builder.newInstance("standard_penalty").setStartLocationId("loc"). setType(penaltyType).build(); List vehicles = new ArrayList(); diff --git a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleImplTest.java b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleImplTest.java index adb5344a..5080436e 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleImplTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/vehicle/VehicleImplTest.java @@ -7,7 +7,7 @@ import jsprit.core.util.Coordinate; import org.junit.Test; - +@SuppressWarnings("deprecation") // still tests whether deprecated methods work correctly - if deprecated methods are removed entirely, shift to setStartLocationId(..) and setStartLocationCoordinate() public class VehicleImplTest { @Test diff --git a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java index e3a13739..a0edf1fc 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java +++ b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java @@ -356,7 +356,7 @@ public class BicycleMessenger { if(firstLine) { firstLine = false; continue; } String[] tokens = line.split("\\s+"); //build your vehicle - Vehicle vehicle = VehicleImpl.Builder.newInstance(tokens[1]).setLocationCoord(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3]))) + Vehicle vehicle = VehicleImpl.Builder.newInstance(tokens[1]).setStartLocationCoordinate(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3]))) .setReturnToDepot(false).setType(messengerType).build(); problemBuilder.addVehicle(vehicle); //build the penalty vehicle diff --git a/jsprit-examples/src/main/java/jsprit/examples/ConfigureAlgorithmInCodeInsteadOfPerXml.java b/jsprit-examples/src/main/java/jsprit/examples/ConfigureAlgorithmInCodeInsteadOfPerXml.java index c81a58a7..4df216be 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/ConfigureAlgorithmInCodeInsteadOfPerXml.java +++ b/jsprit-examples/src/main/java/jsprit/examples/ConfigureAlgorithmInCodeInsteadOfPerXml.java @@ -63,7 +63,7 @@ public class ConfigureAlgorithmInCodeInsteadOfPerXml { * get a vehicle-builder and build a vehicle located at (10,10) with type "vehicleType" */ Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle"); - vehicleBuilder.setLocationCoord(Coordinate.newInstance(10, 10)); + vehicleBuilder.setStartLocationCoordinate(Coordinate.newInstance(10, 10)); vehicleBuilder.setType(vehicleType); Vehicle vehicle = vehicleBuilder.build(); diff --git a/jsprit-examples/src/main/java/jsprit/examples/CostMatrixExample.java b/jsprit-examples/src/main/java/jsprit/examples/CostMatrixExample.java index e03bb64a..2a1a0cae 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/CostMatrixExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/CostMatrixExample.java @@ -59,7 +59,7 @@ public class CostMatrixExample { if(result) System.out.println("./output created"); } VehicleType type = VehicleTypeImpl.Builder.newInstance("type", 2).setCostPerDistance(1).setCostPerTime(2).build(); - Vehicle vehicle = VehicleImpl.Builder.newInstance("vehicle").setLocationId("0").setType(type).build(); + Vehicle vehicle = VehicleImpl.Builder.newInstance("vehicle").setStartLocationId("0").setType(type).build(); Service s1 = Service.Builder.newInstance("1", 1).setLocationId("1").build(); Service s2 = Service.Builder.newInstance("2", 1).setLocationId("2").build(); diff --git a/jsprit-examples/src/main/java/jsprit/examples/HVRPExample.java b/jsprit-examples/src/main/java/jsprit/examples/HVRPExample.java index 3702d2be..dcc853f1 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/HVRPExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/HVRPExample.java @@ -81,17 +81,17 @@ public class HVRPExample { //add vehicle - finite fleet //2xtype1 VehicleType type1 = VehicleTypeImpl.Builder.newInstance("type_1", 120).setCostPerDistance(1.0).build(); - VehicleImpl vehicle1_1 = VehicleImpl.Builder.newInstance("1_1").setLocationCoord(Coordinate.newInstance(40, 40)).setType(type1).build(); + VehicleImpl vehicle1_1 = VehicleImpl.Builder.newInstance("1_1").setStartLocationCoordinate(Coordinate.newInstance(40, 40)).setType(type1).build(); vrpBuilder.addVehicle(vehicle1_1); - VehicleImpl vehicle1_2 = VehicleImpl.Builder.newInstance("1_2").setLocationCoord(Coordinate.newInstance(40, 40)).setType(type1).build(); + VehicleImpl vehicle1_2 = VehicleImpl.Builder.newInstance("1_2").setStartLocationCoordinate(Coordinate.newInstance(40, 40)).setType(type1).build(); vrpBuilder.addVehicle(vehicle1_2); //1xtype2 VehicleType type2 = VehicleTypeImpl.Builder.newInstance("type_2", 160).setCostPerDistance(1.1).build(); - VehicleImpl vehicle2_1 = VehicleImpl.Builder.newInstance("2_1").setLocationCoord(Coordinate.newInstance(40, 40)).setType(type2).build(); + VehicleImpl vehicle2_1 = VehicleImpl.Builder.newInstance("2_1").setStartLocationCoordinate(Coordinate.newInstance(40, 40)).setType(type2).build(); vrpBuilder.addVehicle(vehicle2_1); //1xtype3 VehicleType type3 = VehicleTypeImpl.Builder.newInstance("type_3", 300).setCostPerDistance(1.3).build(); - VehicleImpl vehicle3_1 = VehicleImpl.Builder.newInstance("3_1").setLocationCoord(Coordinate.newInstance(40, 40)).setType(type3).build(); + VehicleImpl vehicle3_1 = VehicleImpl.Builder.newInstance("3_1").setStartLocationCoordinate(Coordinate.newInstance(40, 40)).setType(type3).build(); vrpBuilder.addVehicle(vehicle3_1); //add penaltyVehicles to allow invalid solutions temporarily diff --git a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java index c26c8027..465531ae 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExample.java @@ -82,7 +82,7 @@ public class MultipleDepotExample { for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){ for(int i=0;i