From 6099a315ee344b4ff3935018105145f71d91fe85 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 14 Nov 2013 10:00:17 +0100 Subject: [PATCH 01/11] make plotter plot shipments --- .../src/main/java/analysis/Plotter.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/jsprit-analysis/src/main/java/analysis/Plotter.java b/jsprit-analysis/src/main/java/analysis/Plotter.java index 8de712fd..ff259b45 100644 --- a/jsprit-analysis/src/main/java/analysis/Plotter.java +++ b/jsprit-analysis/src/main/java/analysis/Plotter.java @@ -85,6 +85,8 @@ public class Plotter { private boolean plotSolutionAsWell = false; private boolean plotShipments = true; + + private Collection routes; public void setShowFirstActivity(boolean show){ showFirstActivity = show; @@ -102,13 +104,20 @@ public class Plotter { public Plotter(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) { super(); this.vrp = vrp; - this.solution = solution; + this.routes = solution.getRoutes(); plotSolutionAsWell = true; } + public Plotter(VehicleRoutingProblem vrp, Collection routes) { + super(); + this.vrp = vrp; + this.routes = routes; + plotSolutionAsWell = true; + } + public void plot(String pngFileName, String plotTitle){ if(plotSolutionAsWell){ - plotSolutionAsPNG(vrp, solution, pngFileName, plotTitle); + plotSolutionAsPNG(vrp, routes, pngFileName, plotTitle); } else{ plotVrpAsPNG(vrp, pngFileName, plotTitle); @@ -149,7 +158,7 @@ public class Plotter { save(chart,pngFile); } - private void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){ + private void plotSolutionAsPNG(VehicleRoutingProblem vrp, Collection routes, String pngFile, String title){ log.info("plot solution to " + pngFile); XYSeriesCollection problem; XYSeriesCollection solutionColl; @@ -158,7 +167,7 @@ public class Plotter { try { problem = makeVrpSeries(vrp, labels); shipments = makeShipmentSeries(vrp.getJobs().values(), null); - solutionColl = makeSolutionSeries(vrp, solution); + solutionColl = makeSolutionSeries(vrp, routes); } catch (NoLocationFoundException e) { log.warn("cannot plot vrp, since coord is missing"); return; @@ -305,11 +314,11 @@ public class Plotter { } } - private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution) throws NoLocationFoundException{ + private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, Collection routes) throws NoLocationFoundException{ Locations locations = retrieveLocations(vrp); XYSeriesCollection coll = new XYSeriesCollection(); int counter = 1; - for(VehicleRoute route : solution.getRoutes()){ + for(VehicleRoute route : routes){ if(route.isEmpty()) continue; XYSeries series = new XYSeries(counter, false, true); From 8010e0f2c22d10097a91e9f6b0c747a2eccd27bd Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 14 Nov 2013 10:00:43 +0100 Subject: [PATCH 02/11] add priorities to constraints --- .../main/java/algorithms/ConstraintManager.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jsprit-core/src/main/java/algorithms/ConstraintManager.java b/jsprit-core/src/main/java/algorithms/ConstraintManager.java index 030e2b8b..1bc7c3b9 100644 --- a/jsprit-core/src/main/java/algorithms/ConstraintManager.java +++ b/jsprit-core/src/main/java/algorithms/ConstraintManager.java @@ -1,10 +1,15 @@ package algorithms; import basics.VehicleRoutingProblem; +import basics.VehicleRoutingProblem.Constraint; import basics.route.TourActivity; public class ConstraintManager implements HardActivityStateLevelConstraint, HardRouteStateLevelConstraint{ + public static enum Priority { + CRITICAL, HIGH, LOW + } + private HardActivityLevelConstraintManager actLevelConstraintManager = new HardActivityLevelConstraintManager(); private HardRouteLevelConstraintManager routeLevelConstraintManager = new HardRouteLevelConstraintManager(); @@ -24,7 +29,7 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard public void addTimeWindowConstraint(){ if(!timeWindowConstraintsSet){ - addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts())); + addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts()),Priority.HIGH); stateManager.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts())); timeWindowConstraintsSet = true; } @@ -32,8 +37,12 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard public void addLoadConstraint(){ if(!loadConstraintsSet){ + if(vrp.getProblemConstraints().contains(Constraint.DELIVERIES_FIRST)){ + addConstraint(new ServiceBackhaulConstraint(),Priority.HIGH); + } + addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL); addConstraint(new ServiceLoadRouteLevelConstraint(stateManager)); - addConstraint(new ServiceLoadActivityLevelConstraint(stateManager)); + addConstraint(new ServiceLoadActivityLevelConstraint(stateManager),Priority.LOW); UpdateLoads updateLoads = new UpdateLoads(stateManager); stateManager.addActivityVisitor(updateLoads); stateManager.addListener(updateLoads); @@ -43,8 +52,8 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard } } - public void addConstraint(HardActivityStateLevelConstraint actLevelConstraint){ - actLevelConstraintManager.addConstraint(actLevelConstraint); + public void addConstraint(HardActivityStateLevelConstraint actLevelConstraint, Priority priority){ + actLevelConstraintManager.addConstraint(actLevelConstraint,priority); } public void addConstraint(HardRouteStateLevelConstraint routeLevelConstraint){ From a853ad56723dc9e3c595f10d79f30c2c1c5fbdc2 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Thu, 14 Nov 2013 10:01:32 +0100 Subject: [PATCH 03/11] pd-contraints stuff and tests --- .../HardActivityLevelConstraintManager.java | 49 +- ...liveryShipmentActivityLevelConstraint.java | 76 -- ...erShipmentLoadActivityLevelConstraint.java | 66 + .../ServiceLoadActivityLevelConstraint.java | 8 +- .../ShipmentPickupsFirstConstraint.java | 16 + .../java/algorithms/UpdateFuturePickups.java | 4 +- .../algorithms/UpdateOccuredDeliveries.java | 4 +- .../algorithms/VehicleRoutingAlgorithms.java | 33 +- .../BuildPDVRPAlgoFromScratchTest.java | 5 +- ...PDVRPWithShipmentsAlgoFromScratchTest.java | 4 +- ...eliveryShipmentActivityConstraintTest.java | 4 +- .../ShipmentInsertionCalculatorTest.java | 6 +- jsprit-core/src/test/resources/pdp_sol.xml | 1058 ++++++++--------- 13 files changed, 683 insertions(+), 650 deletions(-) delete mode 100644 jsprit-core/src/main/java/algorithms/HardPickupAndDeliveryShipmentActivityLevelConstraint.java create mode 100644 jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java create mode 100644 jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java diff --git a/jsprit-core/src/main/java/algorithms/HardActivityLevelConstraintManager.java b/jsprit-core/src/main/java/algorithms/HardActivityLevelConstraintManager.java index 42a041c8..c69ef325 100644 --- a/jsprit-core/src/main/java/algorithms/HardActivityLevelConstraintManager.java +++ b/jsprit-core/src/main/java/algorithms/HardActivityLevelConstraintManager.java @@ -3,24 +3,65 @@ package algorithms; import java.util.ArrayList; import java.util.Collection; +import algorithms.ConstraintManager.Priority; import basics.route.TourActivity; class HardActivityLevelConstraintManager implements HardActivityStateLevelConstraint { - private Collection hardConstraints = new ArrayList(); + private Collection criticalConstraints = new ArrayList(); - public void addConstraint(HardActivityStateLevelConstraint constraint){ - hardConstraints.add(constraint); + private Collection highPrioConstraints = new ArrayList(); + + private Collection lowPrioConstraints = new ArrayList(); + + public void addConstraint(HardActivityStateLevelConstraint constraint, Priority priority){ + if(priority.equals(Priority.CRITICAL)){ + criticalConstraints.add(constraint); + } + else if(priority.equals(Priority.HIGH)){ + highPrioConstraints.add(constraint); + } + else{ + lowPrioConstraints.add(constraint); + } } @Override public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { - for(HardActivityStateLevelConstraint constraint : hardConstraints){ + ConstraintsStatus notFulfilled = null; + for(HardActivityStateLevelConstraint c : criticalConstraints){ + ConstraintsStatus status = c.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime); + if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK)){ + return status; + } + else{ + if(status.equals(ConstraintsStatus.NOT_FULFILLED)){ + notFulfilled = status; + } + } + } + if(notFulfilled != null) return notFulfilled; + + for(HardActivityStateLevelConstraint c : highPrioConstraints){ + ConstraintsStatus status = c.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime); + if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK)){ + return status; + } + else{ + if(status.equals(ConstraintsStatus.NOT_FULFILLED)){ + notFulfilled = status; + } + } + } + if(notFulfilled != null) return notFulfilled; + + for(HardActivityStateLevelConstraint constraint : lowPrioConstraints){ ConstraintsStatus status = constraint.fulfilled(iFacts, prevAct, newAct, nextAct, prevActDepTime); if(status.equals(ConstraintsStatus.NOT_FULFILLED_BREAK) || status.equals(ConstraintsStatus.NOT_FULFILLED)){ return status; } } + return ConstraintsStatus.FULFILLED; } diff --git a/jsprit-core/src/main/java/algorithms/HardPickupAndDeliveryShipmentActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/HardPickupAndDeliveryShipmentActivityLevelConstraint.java deleted file mode 100644 index d96c1e37..00000000 --- a/jsprit-core/src/main/java/algorithms/HardPickupAndDeliveryShipmentActivityLevelConstraint.java +++ /dev/null @@ -1,76 +0,0 @@ -package algorithms; - -import org.apache.log4j.Logger; - -import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus; -import basics.route.DeliverShipment; -import basics.route.PickupShipment; -import basics.route.Start; -import basics.route.TourActivity; - -public class HardPickupAndDeliveryShipmentActivityLevelConstraint implements HardActivityStateLevelConstraint { - - private static Logger logger = Logger.getLogger(HardPickupAndDeliveryShipmentActivityLevelConstraint.class); - - private StateManager stateManager; - - private boolean backhaul = false; - - public HardPickupAndDeliveryShipmentActivityLevelConstraint(StateManager stateManager) { - super(); - this.stateManager = stateManager; - } - - public HardPickupAndDeliveryShipmentActivityLevelConstraint(StateManager stateManager, boolean backhaul) { - super(); - this.stateManager = stateManager; - this.backhaul = backhaul; - } - - @Override - public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { -// logger.info(prevAct + " - " + newAct + " - " + nextAct); - if(!(newAct instanceof PickupShipment) && !(newAct instanceof DeliverShipment)){ - return ConstraintsStatus.FULFILLED; - } - if(backhaul){ - if(newAct instanceof PickupShipment && prevAct instanceof DeliverShipment){ -// logger.info("NOT_FULFILLED_BREAK"); - return ConstraintsStatus.NOT_FULFILLED_BREAK; } - if(newAct instanceof DeliverShipment && nextAct instanceof PickupShipment){ -// logger.info("NOT_FULFILLED"); - return ConstraintsStatus.NOT_FULFILLED; } - } - int loadAtPrevAct; -// int futurePicks; -// int pastDeliveries; - - if(prevAct instanceof Start){ - loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING).toDouble(); -// futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateTypes.LOAD).toDouble(); -// pastDeliveries = 0; - } - else{ - loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateFactory.LOAD).toDouble(); -// futurePicks = (int) stateManager.getActivityState(prevAct, StateTypes.FUTURE_PICKS).toDouble(); -// pastDeliveries = (int) stateManager.getActivityState(prevAct, StateTypes.PAST_DELIVERIES).toDouble(); - } - if(newAct instanceof PickupShipment){ - if(loadAtPrevAct + newAct.getCapacityDemand() > iFacts.getNewVehicle().getCapacity()){ -// logger.info("NOT_FULFILLED"); - return ConstraintsStatus.NOT_FULFILLED; - } - } - if(newAct instanceof DeliverShipment){ - if(loadAtPrevAct + Math.abs(newAct.getCapacityDemand()) > iFacts.getNewVehicle().getCapacity()){ -// logger.info("NOT_FULFILLED_BREAK"); - return ConstraintsStatus.NOT_FULFILLED_BREAK; - } - - } -// logger.info("FULFILLED"); - return ConstraintsStatus.FULFILLED; - } - - -} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java new file mode 100644 index 00000000..60c7ac8b --- /dev/null +++ b/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java @@ -0,0 +1,66 @@ +package algorithms; + +import org.apache.log4j.Logger; + +import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus; +import basics.route.DeliverShipment; +import basics.route.PickupShipment; +import basics.route.Start; +import basics.route.TourActivity; + +/** + * Constraint that ensures capacity constraint at each activity. + * + *

This is critical to consistently calculate pd-problems with capacity constraints. Critical means + * that is MUST be visited. It also assumes that pd-activities are visited in the order they occur in a tour. + * + * @author schroeder + * + */ +public class PickupAndDeliverShipmentLoadActivityLevelConstraint implements HardActivityStateLevelConstraint { + + private static Logger logger = Logger.getLogger(PickupAndDeliverShipmentLoadActivityLevelConstraint.class); + + private StateManager stateManager; + + /** + * Constructs the constraint ensuring capacity constraint at each activity. + * + *

This is critical to consistently calculate pd-problems with capacity constraints. Critical means + * that is MUST be visited. It also assumes that pd-activities are visited in the order they occur in a tour. + * + * + * @param stateManager + */ + public PickupAndDeliverShipmentLoadActivityLevelConstraint(StateManager stateManager) { + super(); + this.stateManager = stateManager; + } + + @Override + public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { + if(!(newAct instanceof PickupShipment) && !(newAct instanceof DeliverShipment)){ + return ConstraintsStatus.FULFILLED; + } + int loadAtPrevAct; + if(prevAct instanceof Start){ + loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING).toDouble(); + } + else{ + loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateFactory.LOAD).toDouble(); + } + if(newAct instanceof PickupShipment){ + if(loadAtPrevAct + newAct.getCapacityDemand() > iFacts.getNewVehicle().getCapacity()){ + return ConstraintsStatus.NOT_FULFILLED; + } + } + if(newAct instanceof DeliverShipment){ + if(loadAtPrevAct + Math.abs(newAct.getCapacityDemand()) > iFacts.getNewVehicle().getCapacity()){ + return ConstraintsStatus.NOT_FULFILLED_BREAK; + } + } + return ConstraintsStatus.FULFILLED; + } + + +} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java index 73a9f085..5ce70594 100644 --- a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java @@ -1,7 +1,7 @@ package algorithms; -import basics.route.DeliveryActivity; -import basics.route.PickupActivity; +import basics.route.DeliverService; +import basics.route.PickupService; import basics.route.ServiceActivity; import basics.route.Start; import basics.route.TourActivity; @@ -39,12 +39,12 @@ class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstr futurePicks = (int) stateManager.getActivityState(prevAct, StateFactory.FUTURE_PICKS).toDouble(); pastDeliveries = (int) stateManager.getActivityState(prevAct, StateFactory.PAST_DELIVERIES).toDouble(); } - if(newAct instanceof PickupActivity || newAct instanceof ServiceActivity){ + if(newAct instanceof PickupService || newAct instanceof ServiceActivity){ if(loadAtPrevAct + newAct.getCapacityDemand() + futurePicks > iFacts.getNewVehicle().getCapacity()){ return ConstraintsStatus.NOT_FULFILLED; } } - if(newAct instanceof DeliveryActivity){ + if(newAct instanceof DeliverService){ if(loadAtPrevAct + Math.abs(newAct.getCapacityDemand()) + pastDeliveries > iFacts.getNewVehicle().getCapacity()){ return ConstraintsStatus.NOT_FULFILLED; } diff --git a/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java b/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java new file mode 100644 index 00000000..971f3e27 --- /dev/null +++ b/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java @@ -0,0 +1,16 @@ +package algorithms; + +import basics.route.DeliverShipment; +import basics.route.PickupShipment; +import basics.route.TourActivity; + +public class ShipmentPickupsFirstConstraint implements HardActivityStateLevelConstraint { + + @Override + public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { + if(newAct instanceof DeliverShipment && nextAct instanceof PickupShipment){ return ConstraintsStatus.NOT_FULFILLED; } + if(newAct instanceof PickupShipment && prevAct instanceof DeliverShipment){ return ConstraintsStatus.NOT_FULFILLED_BREAK; } + return ConstraintsStatus.FULFILLED; + } + +} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java b/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java index 7ebcfd8e..fa3d0850 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java +++ b/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java @@ -1,6 +1,6 @@ package algorithms; -import basics.route.PickupActivity; +import basics.route.PickupService; import basics.route.ReverseActivityVisitor; import basics.route.ServiceActivity; import basics.route.TourActivity; @@ -24,7 +24,7 @@ class UpdateFuturePickups implements ReverseActivityVisitor, StateUpdater { @Override public void visit(TourActivity act) { stateManager.putActivityState(act, StateFactory.FUTURE_PICKS, StateFactory.createState(futurePicks)); - if(act instanceof PickupActivity || act instanceof ServiceActivity){ + if(act instanceof PickupService || act instanceof ServiceActivity){ futurePicks += act.getCapacityDemand(); } assert futurePicks <= route.getVehicle().getCapacity() : "sum of pickups must not be > vehicleCap"; diff --git a/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java b/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java index a2cf8237..d4022c4f 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java +++ b/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java @@ -1,7 +1,7 @@ package algorithms; import basics.route.ActivityVisitor; -import basics.route.DeliveryActivity; +import basics.route.DeliverService; import basics.route.TourActivity; import basics.route.VehicleRoute; @@ -22,7 +22,7 @@ class UpdateOccuredDeliveries implements ActivityVisitor, StateUpdater { @Override public void visit(TourActivity act) { - if(act instanceof DeliveryActivity){ + if(act instanceof DeliverService){ deliveries += Math.abs(act.getCapacityDemand()); } stateManager.putActivityState(act, StateFactory.PAST_DELIVERIES, StateFactory.createState(deliveries)); diff --git a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java index 85ea8752..120104f1 100644 --- a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java +++ b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java @@ -446,16 +446,8 @@ public class VehicleRoutingAlgorithms { */ //constraint manager ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); - constraintManager.addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts())); - - if(vrp.getProblemConstraints().contains(Constraint.DELIVERIES_FIRST)){ - constraintManager.addConstraint(new ServiceBackhaulConstraint()); - } - else{ - constraintManager.addConstraint(new ServiceLoadActivityLevelConstraint(stateManager)); - } - - constraintManager.addConstraint(new ServiceLoadRouteLevelConstraint(stateManager)); + constraintManager.addTimeWindowConstraint(); + constraintManager.addLoadConstraint(); //construct initial solution creator AlgorithmStartsListener createInitialSolution = createInitialSolution(config,vrp,vehicleFleetManager,stateManager,algorithmListeners,definedClasses,executorService,nuOfThreads,constraintManager); @@ -492,24 +484,15 @@ public class VehicleRoutingAlgorithms { /* * define stateUpdates */ - -// stateManager.addListener(new UpdateLoadsAtStartAndEndOfRouteWhenInsertionStarts(stateManager)); -// stateManager.addListener(new UpdateLoadsAtStartAndEndOfRouteWhenJobHasBeenInserted(stateManager)); -// - - UpdateLoads loadUpdater = new UpdateLoads(stateManager); - stateManager.addListener(loadUpdater); - stateManager.addActivityVisitor(loadUpdater); - +// UpdateLoads loadUpdater = new UpdateLoads(stateManager); +// stateManager.addListener(loadUpdater); +// stateManager.addActivityVisitor(loadUpdater); stateManager.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts())); - - stateManager.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager)); - stateManager.addActivityVisitor(new UpdateOccuredDeliveries(stateManager)); - stateManager.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts())); - stateManager.addActivityVisitor(new UpdateFuturePickups(stateManager)); - +// stateManager.addActivityVisitor(new UpdateOccuredDeliveries(stateManager)); +// stateManager.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts())); +// stateManager.addActivityVisitor(new UpdateFuturePickups(stateManager)); metaAlgorithm.getSearchStrategyManager().addSearchStrategyModuleListener(stateManager); metaAlgorithm.getAlgorithmListeners().addListener(stateManager); diff --git a/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java b/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java index 15154413..0df78be4 100644 --- a/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java +++ b/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java @@ -23,6 +23,7 @@ import org.junit.Before; import org.junit.Test; import util.Solutions; +import algorithms.ConstraintManager.Priority; import algorithms.StateManager.StateImpl; import algorithms.acceptors.AcceptNewIfBetterThanWorst; import algorithms.selectors.SelectBest; @@ -62,8 +63,8 @@ public class BuildPDVRPAlgoFromScratchTest { final StateManager stateManager = new StateManager(); ConstraintManager actLevelConstraintAccumulator = new ConstraintManager(vrp,stateManager); - actLevelConstraintAccumulator.addConstraint(new ServiceLoadActivityLevelConstraint(stateManager)); - actLevelConstraintAccumulator.addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts())); + actLevelConstraintAccumulator.addConstraint(new ServiceLoadActivityLevelConstraint(stateManager),Priority.LOW); + actLevelConstraintAccumulator.addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts()),Priority.HIGH); ActivityInsertionCostsCalculator marginalCalculus = new LocalActivityInsertionCostsCalculator(vrp.getTransportCosts(), vrp.getActivityCosts()); diff --git a/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java b/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java index 353ed0ba..a13ee633 100644 --- a/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java +++ b/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java @@ -80,7 +80,7 @@ public class BuildPDVRPWithShipmentsAlgoFromScratchTest { ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); constraintManager.addTimeWindowConstraint(); constraintManager.addLoadConstraint(); - constraintManager.addConstraint(new HardPickupAndDeliveryShipmentActivityLevelConstraint(stateManager,true)); +// constraintManager.addConstraint(new HardPickupAndDeliveryShipmentActivityLevelConstraint(stateManager)); ActivityInsertionCostsCalculator marginalCalculus = new LocalActivityInsertionCostsCalculator(vrp.getTransportCosts(), vrp.getActivityCosts()); @@ -176,7 +176,7 @@ public class BuildPDVRPWithShipmentsAlgoFromScratchTest { // System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size()); vra.addInitialSolution(iniSolution); - vra.setNuOfIterations(1000); + vra.setNuOfIterations(100); // vra.setPrematureBreak(500); } diff --git a/jsprit-core/src/test/java/algorithms/HardPickupAndDeliveryShipmentActivityConstraintTest.java b/jsprit-core/src/test/java/algorithms/HardPickupAndDeliveryShipmentActivityConstraintTest.java index 75982219..9c5d86c6 100644 --- a/jsprit-core/src/test/java/algorithms/HardPickupAndDeliveryShipmentActivityConstraintTest.java +++ b/jsprit-core/src/test/java/algorithms/HardPickupAndDeliveryShipmentActivityConstraintTest.java @@ -23,7 +23,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest { Shipment shipment; - HardPickupAndDeliveryShipmentActivityLevelConstraint constraint; + PickupAndDeliverShipmentLoadActivityLevelConstraint constraint; InsertionContext iFacts; @@ -35,7 +35,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest { shipment = mock(Shipment.class); when(shipment.getCapacityDemand()).thenReturn(1); iFacts = new InsertionContext(null, null, vehicle, null, 0.0); - constraint = new HardPickupAndDeliveryShipmentActivityLevelConstraint(stateManager); + constraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager); } @Test diff --git a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java index ff0ffb07..a683a577 100644 --- a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java +++ b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import util.Coordinate; import util.Locations; import util.ManhattanCosts; +import algorithms.ConstraintManager.Priority; import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus; import basics.Shipment; import basics.VehicleRoutingProblem; @@ -188,8 +189,9 @@ public class ShipmentInsertionCalculatorTest { VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class); ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); - - constraintManager.addConstraint(new HardPickupAndDeliveryShipmentActivityLevelConstraint(stateManager,true)); + constraintManager.addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL); + constraintManager.addConstraint(new ShipmentPickupsFirstConstraint(),Priority.CRITICAL); + ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager); diff --git a/jsprit-core/src/test/resources/pdp_sol.xml b/jsprit-core/src/test/resources/pdp_sol.xml index 29b1096f..3ed7bcdb 100644 --- a/jsprit-core/src/test/resources/pdp_sol.xml +++ b/jsprit-core/src/test/resources/pdp_sol.xml @@ -2534,318 +2534,104 @@ - 828.9368669428338 + 828.936866942834 - 50.80359030264955 + 95.94313062205805 noDriver solomonVehicle 0.0 - 24 + 98 0.0 0.0 - 20 + 94 0.0 0.0 - 28 + 97 0.0 0.0 - 26 + 95 0.0 0.0 - 29 + 100 0.0 0.0 - 23 + 99 0.0 0.0 - 30 + 96 0.0 0.0 - 22 + 93 0.0 0.0 - 25 - 0.0 - 0.0 - - - 27 - 0.0 - 0.0 - - - 21 + 92 0.0 0.0 - 20 - 10.0 - 10.0 - - - 24 - 15.0 - 65.0 - - - 25 - 67.0 - 169.0 - - - 27 - 171.0 - 261.0 - - - 29 - 264.605551275464 - 358.0 - - - 30 - 363.0 - 449.0 - - - 28 - 452.0 - 546.0 - - - 26 - 548.0 - 622.0 - - - 23 - 625.0 - 732.0 - - - 22 - 735.0 - 812.0 - - - 21 - 814.0 - 914.0 - - 924.1980390271856 - - - 95.88470913081827 - noDriver - solomonVehicle - 0.0 - - 16 - 0.0 - 0.0 - - - 19 - 0.0 - 0.0 - - - 12 - 0.0 - 0.0 - - - 15 - 0.0 - 0.0 - - - 17 - 0.0 - 0.0 - - - 13 - 0.0 - 0.0 - - - 18 - 0.0 - 0.0 - - - 14 - 0.0 - 0.0 - - - 13 + 98 30.805843601498726 30.805843601498726 - 17 - 34.80584360149872 - 99.0 + 96 + 36.19100840863323 + 95.0 - 18 - 102.0 - 179.0 + 95 + 97.0 + 196.0 - 19 - 184.0 - 278.0 + 94 + 199.605551275464 + 285.0 - 15 - 283.0 - 384.0 + 92 + 288.605551275464 + 368.0 - 16 - 389.0 + 93 + 370.0 475.0 - 14 - 477.0 - 567.0 + 97 + 480.0 + 561.0 - 12 - 570.0 - 652.0 - - 690.0788655293195 - - - 76.06956532288787 - noDriver - solomonVehicle - 0.0 - - 83 - 0.0 - 0.0 - - - 87 - 0.0 - 0.0 - - - 85 - 0.0 - 0.0 - - - 88 - 0.0 - 0.0 - - - 86 - 0.0 - 0.0 - - - 90 - 0.0 - 0.0 - - - 91 - 0.0 - 0.0 - - - 89 - 0.0 - 0.0 - - - 84 - 0.0 - 0.0 - - - 82 - 0.0 - 0.0 + 100 + 566.0 + 647.0 - 90 - 20.615528128088304 - 20.615528128088304 + 99 + 652.0 + 743.0 - - 87 - 25.615528128088304 - 85.0 - - - 86 - 86.0 - 173.0 - - - 83 - 179.0 - 265.0 - - - 82 - 268.0 - 369.0 - - - 84 - 374.8309518948453 - 458.0 - - - 85 - 460.8284271247462 - 555.0 - - - 88 - 558.0 - 645.0 - - - 89 - 647.8284271247462 - 737.0 - - - 91 - 740.605551275464 - 836.0 - - 858.360679774998 + 776.5410196624969 59.403108723710105 @@ -2857,28 +2643,18 @@ 0.0 0.0 - - 62 - 0.0 - 0.0 - - - 61 - 0.0 - 0.0 - 74 0.0 0.0 - 67 + 62 0.0 0.0 - 64 + 65 0.0 0.0 @@ -2888,12 +2664,12 @@ 0.0 - 72 + 67 0.0 0.0 - 68 + 61 0.0 0.0 @@ -2903,7 +2679,17 @@ 0.0 - 65 + 64 + 0.0 + 0.0 + + + 68 + 0.0 + 0.0 + + + 72 0.0 0.0 @@ -2964,13 +2750,294 @@ 931.8113883008419 + + 95.88470913081827 + noDriver + solomonVehicle + 0.0 + + 17 + 0.0 + 0.0 + + + 12 + 0.0 + 0.0 + + + 14 + 0.0 + 0.0 + + + 15 + 0.0 + 0.0 + + + 18 + 0.0 + 0.0 + + + 19 + 0.0 + 0.0 + + + 13 + 0.0 + 0.0 + + + 16 + 0.0 + 0.0 + + + 13 + 30.805843601498726 + 30.805843601498726 + + + 17 + 34.80584360149872 + 99.0 + + + 18 + 102.0 + 179.0 + + + 19 + 184.0 + 278.0 + + + 15 + 283.0 + 384.0 + + + 16 + 389.0 + 475.0 + + + 14 + 477.0 + 567.0 + + + 12 + 570.0 + 652.0 + + 690.0788655293195 + + + 127.29748041459519 + noDriver + solomonVehicle + 0.0 + + 80 + 0.0 + 0.0 + + + 76 + 0.0 + 0.0 + + + 79 + 0.0 + 0.0 + + + 77 + 0.0 + 0.0 + + + 73 + 0.0 + 0.0 + + + 78 + 0.0 + 0.0 + + + 70 + 0.0 + 0.0 + + + 81 + 0.0 + 0.0 + + + 71 + 0.0 + 0.0 + + + 81 + 47.43416490252569 + 47.43416490252569 + + + 78 + 50.43416490252569 + 109.0 + + + 76 + 111.0 + 203.0 + + + 71 + 208.0 + 293.0 + + + 70 + 298.0 + 387.0 + + + 73 + 390.0 + 478.0 + + + 77 + 482.0 + 574.0 + + + 79 + 575.0 + 668.0 + + + 80 + 673.3851648071345 + 769.0 + + 820.478150704935 + + + 97.2271627850669 + noDriver + solomonVehicle + 0.0 + + 31 + 0.0 + 0.0 + + + 38 + 0.0 + 0.0 + + + 37 + 0.0 + 0.0 + + + 33 + 0.0 + 0.0 + + + 32 + 0.0 + 0.0 + + + 36 + 0.0 + 0.0 + + + 35 + 0.0 + 0.0 + + + 39 + 0.0 + 0.0 + + + 34 + 0.0 + 0.0 + + + 32 + 31.622776601683793 + 31.622776601683793 + + + 33 + 33.622776601683796 + 87.0 + + + 31 + 92.3851648071345 + 200.0 + + + 35 + 205.0 + 283.0 + + + 37 + 288.8309518948453 + 383.0 + + + 38 + 385.0 + 479.0 + + + 39 + 484.0 + 567.0 + + + 36 + 572.0 + 665.0 + + + 34 + 668.0 + 751.0 + + 783.3882694814033 + 101.88256760196126 noDriver solomonVehicle 0.0 - 53 + 56 0.0 0.0 @@ -2984,16 +3051,6 @@ 0.0 0.0 - - 58 - 0.0 - 0.0 - - - 56 - 0.0 - 0.0 - 59 0.0 @@ -3004,11 +3061,21 @@ 0.0 0.0 + + 58 + 0.0 + 0.0 + 60 0.0 0.0 + + 53 + 0.0 + 0.0 + 57 35.0 @@ -3052,131 +3119,111 @@ 686.0570962859163 - 59.618077542105574 + 76.06956532288787 noDriver solomonVehicle 0.0 - 3 + 87 0.0 0.0 - 10 + 86 0.0 0.0 - 75 + 84 0.0 0.0 - 2 + 83 0.0 0.0 - 9 + 90 0.0 0.0 - 11 + 91 0.0 0.0 - 6 + 82 0.0 0.0 - 5 + 85 0.0 0.0 - 7 + 89 0.0 0.0 - 1 - 0.0 - 0.0 - - - 8 - 0.0 - 0.0 - - - 4 + 88 0.0 0.0 - 5 - 15.132745950421556 - 15.132745950421556 + 90 + 20.615528128088304 + 20.615528128088304 - 3 - 16.13274595042156 - 65.0 + 87 + 25.615528128088304 + 85.0 - 7 - 67.0 - 170.0 + 86 + 86.0 + 173.0 - 8 - 172.82842712474618 - 255.0 + 83 + 179.0 + 265.0 - 10 - 258.605551275464 - 357.0 + 82 + 268.0 + 369.0 - 11 - 360.0 - 448.0 + 84 + 374.8309518948453 + 458.0 - 9 - 451.1622776601684 - 534.0 + 85 + 460.8284271247462 + 555.0 - 6 - 536.2360679774998 - 621.0 + 88 + 558.0 + 645.0 - 4 - 623.2360679774998 - 727.0 + 89 + 647.8284271247462 + 737.0 - 2 - 730.605551275464 - 825.0 + 91 + 740.605551275464 + 836.0 - - 1 - 827.0 - 912.0 - - - 75 - 915.0 - 997.0 - - 1012.8113883008419 + 858.360679774998 64.80747449698114 @@ -3184,27 +3231,17 @@ solomonVehicle 0.0 - 42 + 45 0.0 0.0 - 48 + 49 0.0 0.0 - 40 - 0.0 - 0.0 - - - 46 - 0.0 - 0.0 - - - 43 + 47 0.0 0.0 @@ -3214,7 +3251,32 @@ 0.0 - 47 + 46 + 0.0 + 0.0 + + + 44 + 0.0 + 0.0 + + + 43 + 0.0 + 0.0 + + + 42 + 0.0 + 0.0 + + + 40 + 0.0 + 0.0 + + + 52 0.0 0.0 @@ -3229,22 +3291,7 @@ 0.0 - 52 - 0.0 - 0.0 - - - 49 - 0.0 - 0.0 - - - 45 - 0.0 - 0.0 - - - 44 + 48 0.0 0.0 @@ -3316,295 +3363,248 @@ 1072.02775637732 - 127.29748041459519 + 50.80359030264955 noDriver solomonVehicle 0.0 - 78 + 20 0.0 0.0 - 80 + 21 0.0 0.0 - 81 + 23 0.0 0.0 - 70 + 27 0.0 0.0 - 71 + 30 0.0 0.0 - 77 + 25 0.0 0.0 - 76 + 24 0.0 0.0 - 79 + 26 0.0 0.0 - 73 + 28 + 0.0 + 0.0 + + + 29 + 0.0 + 0.0 + + + 22 0.0 0.0 - 81 - 47.43416490252569 - 47.43416490252569 + 20 + 10.0 + 10.0 - 78 - 50.43416490252569 - 109.0 + 24 + 15.0 + 65.0 - 76 - 111.0 - 203.0 + 25 + 67.0 + 169.0 - 71 - 208.0 - 293.0 + 27 + 171.0 + 261.0 - 70 - 298.0 - 387.0 + 29 + 264.605551275464 + 358.0 - 73 - 390.0 - 478.0 + 30 + 363.0 + 449.0 - 77 - 482.0 - 574.0 + 28 + 452.0 + 546.0 - 79 - 575.0 - 668.0 + 26 + 548.0 + 622.0 - 80 - 673.3851648071345 - 769.0 + 23 + 625.0 + 732.0 - 820.478150704935 + + 22 + 735.0 + 812.0 + + + 21 + 814.0 + 914.0 + + 924.1980390271856 - 95.94313062205805 + 59.618077542105574 noDriver solomonVehicle 0.0 - 94 + 8 0.0 0.0 - 100 + 7 0.0 0.0 - 97 + 4 0.0 0.0 - 98 + 2 0.0 0.0 - 93 + 5 0.0 0.0 - 92 + 10 0.0 0.0 - 96 + 3 0.0 0.0 - 95 + 75 0.0 0.0 - 99 - 0.0 - 0.0 - - - 98 - 30.805843601498726 - 30.805843601498726 - - - 96 - 36.19100840863323 - 95.0 - - - 95 - 97.0 - 196.0 - - - 94 - 199.605551275464 - 285.0 - - - 92 - 288.605551275464 - 368.0 - - - 93 - 370.0 - 475.0 - - - 97 - 480.0 - 561.0 - - - 100 - 566.0 - 647.0 - - - 99 - 652.0 - 743.0 - - 776.5410196624969 - - - 97.2271627850669 - noDriver - solomonVehicle - 0.0 - - 34 + 6 0.0 0.0 - 36 + 11 0.0 0.0 - 39 + 1 0.0 0.0 - 38 - 0.0 - 0.0 - - - 33 - 0.0 - 0.0 - - - 35 - 0.0 - 0.0 - - - 32 - 0.0 - 0.0 - - - 37 - 0.0 - 0.0 - - - 31 + 9 0.0 0.0 - 32 - 31.622776601683793 - 31.622776601683793 + 5 + 15.132745950421556 + 15.132745950421556 - 33 - 33.622776601683796 - 87.0 + 3 + 16.13274595042156 + 65.0 - 31 - 92.3851648071345 - 200.0 + 7 + 67.0 + 170.0 - 35 - 205.0 - 283.0 + 8 + 172.82842712474618 + 255.0 - 37 - 288.8309518948453 - 383.0 + 10 + 258.605551275464 + 357.0 - 38 - 385.0 - 479.0 + 11 + 360.0 + 448.0 - 39 - 484.0 - 567.0 + 9 + 451.1622776601684 + 534.0 - 36 - 572.0 - 665.0 + 6 + 536.2360679774998 + 621.0 - 34 - 668.0 - 751.0 + 4 + 623.2360679774998 + 727.0 - 783.3882694814033 + + 2 + 730.605551275464 + 825.0 + + + 1 + 827.0 + 912.0 + + + 75 + 915.0 + 997.0 + + 1012.8113883008419 From 491d7a9738cab9a886ac36c00acd8d9a19a3c8f4 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Fri, 15 Nov 2013 07:07:43 +0100 Subject: [PATCH 04/11] add CalcSwitcher for pickups and deliveries --- jsprit-core/src/main/java/algorithms/CalculatorBuilder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java b/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java index 57c0ff3a..c4c00b47 100644 --- a/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java +++ b/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java @@ -19,6 +19,8 @@ package algorithms; import java.util.ArrayList; import java.util.List; +import basics.Delivery; +import basics.Pickup; import basics.Service; import basics.Shipment; import basics.VehicleRoutingProblem; @@ -238,6 +240,8 @@ class CalculatorBuilder { JobCalculatorSwitcher switcher = new JobCalculatorSwitcher(); switcher.put(Shipment.class, shipmentInsertion); switcher.put(Service.class, serviceInsertion); + switcher.put(Pickup.class, serviceInsertion); + switcher.put(Delivery.class, serviceInsertion); // JobInsertionCostsCalculator standardServiceInsertion = new ServiceInsertionCalculator(vrp.getTransportCosts(), actInsertionCalc, constraintManager, constraintManager); // ((ServiceInsertionCalculator) standardServiceInsertion).setNeighborhood(vrp.getNeighborhood()); From 2c0366135cf47efe41ceb7c6e643a3afe0725912 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:44:14 +0100 Subject: [PATCH 05/11] add state-updaters and constraints --- .../java/algorithms/ConstraintManager.java | 5 +- .../algorithms/ServiceBackhaulConstraint.java | 13 ++-- .../ServiceLoadActivityLevelConstraint.java | 33 +++++---- .../java/algorithms/UpdateFuturePickups.java | 39 ----------- .../src/main/java/algorithms/UpdateLoads.java | 14 ++++ .../main/java/algorithms/UpdateMaxLoad.java | 61 ++++++----------- .../main/java/algorithms/UpdateMaxLoad_.java | 67 +++++++++++++++++++ .../algorithms/UpdateOccuredDeliveries.java | 38 ----------- .../java/algorithms/UpdatePrevMaxLoad.java | 42 ++++++++++++ 9 files changed, 170 insertions(+), 142 deletions(-) delete mode 100644 jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java create mode 100644 jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java delete mode 100644 jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java create mode 100644 jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java diff --git a/jsprit-core/src/main/java/algorithms/ConstraintManager.java b/jsprit-core/src/main/java/algorithms/ConstraintManager.java index 1bc7c3b9..e13be088 100644 --- a/jsprit-core/src/main/java/algorithms/ConstraintManager.java +++ b/jsprit-core/src/main/java/algorithms/ConstraintManager.java @@ -46,8 +46,9 @@ public class ConstraintManager implements HardActivityStateLevelConstraint, Hard UpdateLoads updateLoads = new UpdateLoads(stateManager); stateManager.addActivityVisitor(updateLoads); stateManager.addListener(updateLoads); - stateManager.addActivityVisitor(new UpdateFuturePickups(stateManager)); - stateManager.addActivityVisitor(new UpdateOccuredDeliveries(stateManager)); + stateManager.addActivityVisitor(new UpdateMaxLoad(stateManager)); + stateManager.addActivityVisitor(new UpdateMaxLoad_(stateManager)); + stateManager.addActivityVisitor(new UpdatePrevMaxLoad(stateManager)); loadConstraintsSet=true; } } diff --git a/jsprit-core/src/main/java/algorithms/ServiceBackhaulConstraint.java b/jsprit-core/src/main/java/algorithms/ServiceBackhaulConstraint.java index 548c6395..7ebf7669 100644 --- a/jsprit-core/src/main/java/algorithms/ServiceBackhaulConstraint.java +++ b/jsprit-core/src/main/java/algorithms/ServiceBackhaulConstraint.java @@ -1,19 +1,18 @@ package algorithms; -import basics.route.DeliveryActivity; -import basics.route.PickupActivity; +import basics.route.DeliverService; +import basics.route.PickupService; import basics.route.ServiceActivity; -import basics.route.Start; import basics.route.TourActivity; public class ServiceBackhaulConstraint implements HardActivityStateLevelConstraint { @Override public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { - if(newAct instanceof PickupActivity && nextAct instanceof DeliveryActivity){ return ConstraintsStatus.NOT_FULFILLED; } - if(newAct instanceof ServiceActivity && nextAct instanceof DeliveryActivity){ return ConstraintsStatus.NOT_FULFILLED; } - if(newAct instanceof DeliveryActivity && prevAct instanceof PickupActivity){ return ConstraintsStatus.NOT_FULFILLED; } - if(newAct instanceof DeliveryActivity && prevAct instanceof ServiceActivity){ return ConstraintsStatus.NOT_FULFILLED; } + if(newAct instanceof PickupService && nextAct instanceof DeliverService){ return ConstraintsStatus.NOT_FULFILLED; } + if(newAct instanceof ServiceActivity && nextAct instanceof DeliverService){ return ConstraintsStatus.NOT_FULFILLED; } + if(newAct instanceof DeliverService && prevAct instanceof PickupService){ return ConstraintsStatus.NOT_FULFILLED_BREAK; } + if(newAct instanceof DeliverService && prevAct instanceof ServiceActivity){ return ConstraintsStatus.NOT_FULFILLED_BREAK; } return ConstraintsStatus.FULFILLED; } diff --git a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java index 5ce70594..9e23f68c 100644 --- a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java @@ -1,10 +1,13 @@ package algorithms; +import org.apache.log4j.Logger; + import basics.route.DeliverService; import basics.route.PickupService; import basics.route.ServiceActivity; import basics.route.Start; import basics.route.TourActivity; +import basics.route.VehicleRoute; /** * Ensures load constraint for inserting ServiceActivity. @@ -17,6 +20,8 @@ import basics.route.TourActivity; */ class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstraint { + private static Logger log = Logger.getLogger(ServiceLoadActivityLevelConstraint.class); + private StateGetter stateManager; public ServiceLoadActivityLevelConstraint(StateGetter stateManager) { @@ -26,31 +31,31 @@ class ServiceLoadActivityLevelConstraint implements HardActivityStateLevelConstr @Override public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) { - int loadAtPrevAct; - int futurePicks; - int pastDeliveries; + int futureMaxLoad; + int prevMaxLoad; if(prevAct instanceof Start){ - loadAtPrevAct = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING).toDouble(); - futurePicks = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_END).toDouble(); - pastDeliveries = 0; + futureMaxLoad = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.MAXLOAD).toDouble(); + prevMaxLoad = (int)stateManager.getRouteState(iFacts.getRoute(), StateFactory.LOAD_AT_BEGINNING).toDouble(); } else{ - loadAtPrevAct = (int) stateManager.getActivityState(prevAct, StateFactory.LOAD).toDouble(); - futurePicks = (int) stateManager.getActivityState(prevAct, StateFactory.FUTURE_PICKS).toDouble(); - pastDeliveries = (int) stateManager.getActivityState(prevAct, StateFactory.PAST_DELIVERIES).toDouble(); + futureMaxLoad = (int) stateManager.getActivityState(prevAct, StateFactory.FUTURE_PICKS).toDouble(); + prevMaxLoad = (int) stateManager.getActivityState(prevAct, StateFactory.PAST_DELIVERIES).toDouble(); + } if(newAct instanceof PickupService || newAct instanceof ServiceActivity){ - if(loadAtPrevAct + newAct.getCapacityDemand() + futurePicks > iFacts.getNewVehicle().getCapacity()){ + if(newAct.getCapacityDemand() + futureMaxLoad > iFacts.getNewVehicle().getCapacity()){ +// log.debug("insertionOf("+newAct+").BETWEEN("+prevAct+").AND("+nextAct+")=NOT_POSSIBLE"); return ConstraintsStatus.NOT_FULFILLED; } } if(newAct instanceof DeliverService){ - if(loadAtPrevAct + Math.abs(newAct.getCapacityDemand()) + pastDeliveries > iFacts.getNewVehicle().getCapacity()){ - return ConstraintsStatus.NOT_FULFILLED; + if(Math.abs(newAct.getCapacityDemand()) + prevMaxLoad > iFacts.getNewVehicle().getCapacity()){ +// log.debug("insertionOf("+newAct+").BETWEEN("+prevAct+").AND("+nextAct+")=NOT_POSSIBLE[break=neverBePossibleAnymore]"); + return ConstraintsStatus.NOT_FULFILLED_BREAK; } } +// log.debug("insertionOf("+newAct+").BETWEEN("+prevAct+").AND("+nextAct+")=POSSIBLE"); return ConstraintsStatus.FULFILLED; - } - + } } \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java b/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java deleted file mode 100644 index fa3d0850..00000000 --- a/jsprit-core/src/main/java/algorithms/UpdateFuturePickups.java +++ /dev/null @@ -1,39 +0,0 @@ -package algorithms; - -import basics.route.PickupService; -import basics.route.ReverseActivityVisitor; -import basics.route.ServiceActivity; -import basics.route.TourActivity; -import basics.route.VehicleRoute; - -class UpdateFuturePickups implements ReverseActivityVisitor, StateUpdater { - private StateManager stateManager; - private int futurePicks = 0; - private VehicleRoute route; - - public UpdateFuturePickups(StateManager stateManager) { - super(); - this.stateManager = stateManager; - } - - @Override - public void begin(VehicleRoute route) { - this.route = route; - } - - @Override - public void visit(TourActivity act) { - stateManager.putActivityState(act, StateFactory.FUTURE_PICKS, StateFactory.createState(futurePicks)); - if(act instanceof PickupService || act instanceof ServiceActivity){ - futurePicks += act.getCapacityDemand(); - } - assert futurePicks <= route.getVehicle().getCapacity() : "sum of pickups must not be > vehicleCap"; - assert futurePicks >= 0 : "sum of pickups must not < 0"; - } - - @Override - public void finish() { - futurePicks = 0; - route = null; - } -} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateLoads.java b/jsprit-core/src/main/java/algorithms/UpdateLoads.java index 9b17f35b..ebd6076d 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateLoads.java +++ b/jsprit-core/src/main/java/algorithms/UpdateLoads.java @@ -2,6 +2,8 @@ package algorithms; import java.util.Collection; +import org.apache.log4j.Logger; + import basics.Delivery; import basics.Job; import basics.Pickup; @@ -27,6 +29,7 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe private StateManager stateManager; private int currentLoad = 0; private VehicleRoute route; + private static Logger log = Logger.getLogger(UpdateLoads.class); /** * Updates load at activity level. @@ -89,6 +92,8 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe @Override public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { +// log.debug("insert("+job2insert+").into("+inRoute+")"); +// log(inRoute); if(job2insert instanceof Delivery){ int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING).toDouble(); // log.info("loadAtDepot="+loadAtDepot); @@ -101,4 +106,13 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe } } +// private void log(VehicleRoute inRoute) { +// log.debug(inRoute.getStart()); +// for(TourActivity act : inRoute.getTourActivities().getActivities()){ +// log.debug(act); +// } +// log.debug(inRoute.getEnd()); +// +// } + } \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java b/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java index 9bd3b800..7f33bf3f 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java +++ b/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java @@ -1,67 +1,44 @@ package algorithms; -import basics.route.ActivityVisitor; +import org.apache.log4j.Logger; + +import basics.route.ReverseActivityVisitor; import basics.route.TourActivity; import basics.route.VehicleRoute; -/** - * Updates load at activity level. - * - *

Note that this assumes that StateTypes.LOAD_AT_DEPOT is already updated, i.e. it starts by setting loadAtDepot to StateTypes.LOAD_AT_DEPOT. - * If StateTypes.LOAD_AT_DEPOT is not set, it starts with 0 load at depot. - * - *

Thus it DEPENDS on StateTypes.LOAD_AT_DEPOT - * - * @author stefan - * - */ -class UpdateMaxLoad implements ActivityVisitor, StateUpdater { +class UpdateMaxLoad implements ReverseActivityVisitor, StateUpdater { + private static Logger log = Logger.getLogger(UpdateMaxLoad.class); private StateManager stateManager; - private int currentLoad = 0; private VehicleRoute route; - private int maxLoad = 0; + private double maxLoad; + private double currLoad; - /** - * Updates load at activity level. - * - *

Note that this assumes that StateTypes.LOAD_AT_DEPOT is already updated, i.e. it starts by setting loadAtDepot to StateTypes.LOAD_AT_DEPOT. - * If StateTypes.LOAD_AT_DEPOT is not set, it starts with 0 load at depot. - * - *

Thus it DEPENDS on StateTypes.LOAD_AT_DEPOT - * - * - * - *

The loads can be retrieved by
- * stateManager.getActivityState(activity,StateTypes.LOAD); - * - * - * @author stefan - * - */ public UpdateMaxLoad(StateManager stateManager) { super(); this.stateManager = stateManager; } - + @Override public void begin(VehicleRoute route) { - currentLoad = (int) stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING).toDouble(); - maxLoad = currentLoad; this.route = route; + maxLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_END).toDouble(); +// currLoad = maxLoad; +// log.debug("maxLoad@end="+maxLoad); } @Override public void visit(TourActivity act) { - currentLoad += act.getCapacityDemand(); - maxLoad = Math.max(maxLoad, currentLoad); - assert currentLoad <= route.getVehicle().getCapacity() : "currentLoad at activity must not be > vehicleCapacity"; - assert currentLoad >= 0 : "currentLoad at act must not be < 0"; + maxLoad = Math.max(maxLoad, stateManager.getActivityState(act, StateFactory.LOAD).toDouble()); +// currLoad -= act.getCapacityDemand(); +// log.debug("maxLoad@"+act+"="+maxLoad); + stateManager.putActivityState(act, StateFactory.FUTURE_PICKS, StateFactory.createState(maxLoad)); + assert maxLoad <= route.getVehicle().getCapacity() : "maxLoad can never be bigger than vehicleCap"; + assert maxLoad >= 0 : "maxLoad can never be smaller than 0"; } @Override public void finish() { - stateManager.putRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad)); - currentLoad = 0; - maxLoad = 0; +// stateManager.putRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad)); +// log.debug("maxLoad@start="+maxLoad); } } \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java b/jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java new file mode 100644 index 00000000..382d4811 --- /dev/null +++ b/jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java @@ -0,0 +1,67 @@ +package algorithms; + +import basics.route.ActivityVisitor; +import basics.route.TourActivity; +import basics.route.VehicleRoute; + +/** + * Updates load at activity level. + * + *

Note that this assumes that StateTypes.LOAD_AT_DEPOT is already updated, i.e. it starts by setting loadAtDepot to StateTypes.LOAD_AT_DEPOT. + * If StateTypes.LOAD_AT_DEPOT is not set, it starts with 0 load at depot. + * + *

Thus it DEPENDS on StateTypes.LOAD_AT_DEPOT + * + * @author stefan + * + */ +class UpdateMaxLoad_ implements ActivityVisitor, StateUpdater { + private StateManager stateManager; + private int currentLoad = 0; + private VehicleRoute route; + private int maxLoad = 0; + + /** + * Updates load at activity level. + * + *

Note that this assumes that StateTypes.LOAD_AT_DEPOT is already updated, i.e. it starts by setting loadAtDepot to StateTypes.LOAD_AT_DEPOT. + * If StateTypes.LOAD_AT_DEPOT is not set, it starts with 0 load at depot. + * + *

Thus it DEPENDS on StateTypes.LOAD_AT_DEPOT + * + * + * + *

The loads can be retrieved by
+ * stateManager.getActivityState(activity,StateTypes.LOAD); + * + * + * @author stefan + * + */ + public UpdateMaxLoad_(StateManager stateManager) { + super(); + this.stateManager = stateManager; + } + + @Override + public void begin(VehicleRoute route) { + currentLoad = (int) stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING).toDouble(); + maxLoad = currentLoad; + this.route = route; + } + + @Override + public void visit(TourActivity act) { + currentLoad += act.getCapacityDemand(); + maxLoad = Math.max(maxLoad, currentLoad); + assert currentLoad <= route.getVehicle().getCapacity() : "currentLoad at activity must not be > vehicleCapacity"; + assert currentLoad >= 0 : "currentLoad at act must not be < 0"; + } + + @Override + public void finish() { + stateManager.putRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad)); + currentLoad = 0; + maxLoad = 0; + } +} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java b/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java deleted file mode 100644 index d4022c4f..00000000 --- a/jsprit-core/src/main/java/algorithms/UpdateOccuredDeliveries.java +++ /dev/null @@ -1,38 +0,0 @@ -package algorithms; - -import basics.route.ActivityVisitor; -import basics.route.DeliverService; -import basics.route.TourActivity; -import basics.route.VehicleRoute; - -class UpdateOccuredDeliveries implements ActivityVisitor, StateUpdater { - private StateManager stateManager; - private int deliveries = 0; - private VehicleRoute route; - - public UpdateOccuredDeliveries(StateManager stateManager) { - super(); - this.stateManager = stateManager; - } - - @Override - public void begin(VehicleRoute route) { - this.route = route; - } - - @Override - public void visit(TourActivity act) { - if(act instanceof DeliverService){ - deliveries += Math.abs(act.getCapacityDemand()); - } - stateManager.putActivityState(act, StateFactory.PAST_DELIVERIES, StateFactory.createState(deliveries)); - assert deliveries >= 0 : "deliveries < 0"; - assert deliveries <= route.getVehicle().getCapacity() : "deliveries > vehicleCap"; - } - - @Override - public void finish() { - deliveries = 0; - route = null; - } -} \ No newline at end of file diff --git a/jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java b/jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java new file mode 100644 index 00000000..1536f1bb --- /dev/null +++ b/jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java @@ -0,0 +1,42 @@ +package algorithms; + +import org.apache.log4j.Logger; + +import basics.route.ActivityVisitor; +import basics.route.TourActivity; +import basics.route.VehicleRoute; + +class UpdatePrevMaxLoad implements ActivityVisitor, StateUpdater { + private static Logger log = Logger.getLogger(UpdatePrevMaxLoad.class); + private StateManager stateManager; + private VehicleRoute route; + private double currLoad; + private double prevMaxLoad; + + public UpdatePrevMaxLoad(StateManager stateManager) { + super(); + this.stateManager = stateManager; + } + + @Override + public void begin(VehicleRoute route) { + this.route = route; + currLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING).toDouble(); + prevMaxLoad = currLoad; +// log.debug("prevMaxLoad@start="+prevMaxLoad); + } + + @Override + public void visit(TourActivity act) { + prevMaxLoad = Math.max(prevMaxLoad, stateManager.getActivityState(act, StateFactory.LOAD).toDouble()); +// log.debug("prevMaxLoad@"+act+"="+prevMaxLoad); + stateManager.putActivityState(act, StateFactory.PAST_DELIVERIES, StateFactory.createState(prevMaxLoad)); + assert prevMaxLoad >= 0 : "maxLoad can never be smaller than 0"; + assert prevMaxLoad <= route.getVehicle().getCapacity() : "maxLoad can never be bigger than vehicleCap"; + } + + @Override + public void finish() { +// log.debug("prevMaxLoad@end="+prevMaxLoad); + } +} \ No newline at end of file From 42abaea24e07663894857710166d3db6bc3730a6 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:45:04 +0100 Subject: [PATCH 06/11] test vrp with shipments and services --- .../BuildPDVRPAlgoFromScratchTest.java | 101 ++----------- ...PDVRPWithShipmentsAlgoFromScratchTest.java | 4 +- ...erviceInsertionAndLoadConstraintsTest.java | 139 ++++++++++++++++++ .../ShipmentInsertionCalculatorTest.java | 52 ++++++- 4 files changed, 200 insertions(+), 96 deletions(-) create mode 100644 jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java diff --git a/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java b/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java index 0df78be4..02076ca1 100644 --- a/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java +++ b/jsprit-core/src/test/java/algorithms/BuildPDVRPAlgoFromScratchTest.java @@ -23,25 +23,16 @@ import org.junit.Before; import org.junit.Test; import util.Solutions; -import algorithms.ConstraintManager.Priority; -import algorithms.StateManager.StateImpl; import algorithms.acceptors.AcceptNewIfBetterThanWorst; import algorithms.selectors.SelectBest; -import basics.Delivery; -import basics.Job; -import basics.Pickup; import basics.VehicleRoutingAlgorithm; import basics.VehicleRoutingProblem; import basics.VehicleRoutingProblemSolution; -import basics.algo.InsertionStartsListener; -import basics.algo.JobInsertedListener; import basics.algo.SearchStrategy; import basics.algo.SearchStrategyManager; import basics.algo.SolutionCostCalculator; import basics.io.VrpXMLReader; import basics.route.InfiniteFleetManagerFactory; -import basics.route.ReverseRouteActivityVisitor; -import basics.route.RouteActivityVisitor; import basics.route.VehicleFleetManager; import basics.route.VehicleRoute; @@ -62,22 +53,16 @@ public class BuildPDVRPAlgoFromScratchTest { final StateManager stateManager = new StateManager(); - ConstraintManager actLevelConstraintAccumulator = new ConstraintManager(vrp,stateManager); - actLevelConstraintAccumulator.addConstraint(new ServiceLoadActivityLevelConstraint(stateManager),Priority.LOW); - actLevelConstraintAccumulator.addConstraint(new TimeWindowConstraint(stateManager, vrp.getTransportCosts()),Priority.HIGH); - - ActivityInsertionCostsCalculator marginalCalculus = new LocalActivityInsertionCostsCalculator(vrp.getTransportCosts(), vrp.getActivityCosts()); - - - ServiceInsertionCalculator serviceInsertion = new ServiceInsertionCalculator(vrp.getTransportCosts(), marginalCalculus, new ServiceLoadRouteLevelConstraint(stateManager), actLevelConstraintAccumulator); - -// CalculatesServiceInsertion serviceInsertion = new CalculatesServiceInsertion(vrp.getTransportCosts(), marginalCalculus, new HardConstraints.HardLoadConstraint(stateManager)); + ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); + constraintManager.addTimeWindowConstraint(); + constraintManager.addLoadConstraint(); VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager(); - JobInsertionCostsCalculator finalServiceInsertion = new VehicleTypeDependentJobInsertionCalculator(fleetManager, serviceInsertion); - - BestInsertion bestInsertion = new BestInsertion(finalServiceInsertion); + BestInsertionBuilder iBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager); +// iBuilder.setConstraintManager(constraintManger); + InsertionStrategy bestInsertion = iBuilder.build(); + RuinRadial radial = new RuinRadial(vrp, 0.15, new JobDistanceAvgCosts(vrp.getTransportCosts())); RuinRandom random = new RuinRandom(vrp, 0.25); @@ -105,80 +90,14 @@ public class BuildPDVRPAlgoFromScratchTest { strategyManager.addStrategy(radialStrategy, 0.5); strategyManager.addStrategy(randomStrategy, 0.5); - vra = new VehicleRoutingAlgorithm(vrp, strategyManager); - - vra.getAlgorithmListeners().addListener(stateManager); - - final RouteActivityVisitor iterateForward = new RouteActivityVisitor(); - - iterateForward.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts())); -// iterateForward.addActivityVisitor(new UpdateEarliestStartTime(stateManager, vrp.getTransportCosts())); - iterateForward.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager)); - - iterateForward.addActivityVisitor(new UpdateOccuredDeliveries(stateManager)); - iterateForward.addActivityVisitor(new UpdateLoads(stateManager)); - - final ReverseRouteActivityVisitor iterateBackward = new ReverseRouteActivityVisitor(); - iterateBackward.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts())); - iterateBackward.addActivityVisitor(new UpdateFuturePickups(stateManager)); - - - InsertionStartsListener loadVehicleInDepot = new InsertionStartsListener() { - - @Override - public void informInsertionStarts(Collection vehicleRoutes, Collection unassignedJobs) { - for(VehicleRoute route : vehicleRoutes){ - int loadAtDepot = 0; - int loadAtEnd = 0; - for(Job j : route.getTourActivities().getJobs()){ - if(j instanceof Delivery){ - loadAtDepot += j.getCapacityDemand(); - } - if(j instanceof Pickup){ - loadAtEnd += j.getCapacityDemand(); - } - } - stateManager.putRouteState(route, StateFactory.LOAD_AT_BEGINNING, new StateImpl(loadAtDepot)); - stateManager.putRouteState(route, StateFactory.LOAD, new StateImpl(loadAtEnd)); - iterateForward.visit(route); - iterateBackward.visit(route); - } - } - - }; - - vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager)); - - JobInsertedListener updateLoadAfterJobHasBeenInserted = new JobInsertedListener() { - - @Override - public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) { -// log.info("insert job " + job2insert.getClass().toString() + " job " + job2insert + "" + job2insert.getCapacityDemand() + " in route " + inRoute.getTourActivities()); - - if(job2insert instanceof Delivery){ - int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING).toDouble(); -// log.info("loadAtDepot="+loadAtDepot); - stateManager.putRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, StateFactory.createState(loadAtDepot + job2insert.getCapacityDemand())); - } - if(job2insert instanceof Pickup){ - int loadAtEnd = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_END).toDouble(); -// log.info("loadAtEnd="+loadAtEnd); - stateManager.putRouteState(inRoute, StateFactory.LOAD_AT_END, StateFactory.createState(loadAtEnd + job2insert.getCapacityDemand())); - } - iterateForward.visit(inRoute); - iterateBackward.visit(inRoute); - } - }; - - bestInsertion.addListener(loadVehicleInDepot); - bestInsertion.addListener(updateLoadAfterJobHasBeenInserted); + vra = new VehicleRoutingAlgorithmFactoryImpl(strategyManager, stateManager, fleetManager).createAlgorithm(vrp); VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp); // System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size()); vra.addInitialSolution(iniSolution); - vra.setNuOfIterations(10000); - vra.setPrematureBreak(1000); + vra.setNuOfIterations(1000); + vra.setPrematureBreak(100); } diff --git a/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java b/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java index a13ee633..e1330595 100644 --- a/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java +++ b/jsprit-core/src/test/java/algorithms/BuildPDVRPWithShipmentsAlgoFromScratchTest.java @@ -137,12 +137,12 @@ public class BuildPDVRPWithShipmentsAlgoFromScratchTest { iterateForward.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts())); iterateForward.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager)); - iterateForward.addActivityVisitor(new UpdateOccuredDeliveries(stateManager)); + iterateForward.addActivityVisitor(new UpdatePrevMaxLoad(stateManager)); iterateForward.addActivityVisitor(new UpdateLoads(stateManager)); final ReverseRouteActivityVisitor iterateBackward = new ReverseRouteActivityVisitor(); iterateBackward.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts())); - iterateBackward.addActivityVisitor(new UpdateFuturePickups(stateManager)); + iterateBackward.addActivityVisitor(new UpdateMaxLoad(stateManager)); JobInsertedListener updateWhenJobHasBeenInserted = new JobInsertedListener() { diff --git a/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java b/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java new file mode 100644 index 00000000..3d28bfe0 --- /dev/null +++ b/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java @@ -0,0 +1,139 @@ +package algorithms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import java.util.Arrays; + +import org.junit.Before; +import org.junit.Test; + +import util.Coordinate; +import util.Locations; +import util.ManhattanCosts; +import algorithms.ConstraintManager.Priority; +import basics.Delivery; +import basics.Pickup; +import basics.Service; +import basics.Shipment; +import basics.VehicleRoutingProblem; +import basics.costs.VehicleRoutingActivityCosts; +import basics.costs.VehicleRoutingTransportCosts; +import basics.route.Driver; +import basics.route.DriverImpl; +import basics.route.RouteActivityVisitor; +import basics.route.TourActivity; +import basics.route.Vehicle; +import basics.route.VehicleImpl; +import basics.route.VehicleRoute; +import basics.route.VehicleType; +import basics.route.VehicleTypeImpl; + +public class ServiceInsertionAndLoadConstraintsTest { + + VehicleRoutingTransportCosts routingCosts; + + VehicleRoutingActivityCosts activityCosts = new VehicleRoutingActivityCosts(){ + + @Override + public double getActivityCost(TourActivity tourAct, double arrivalTime,Driver driver, Vehicle vehicle) { + return 0; + } + + }; + + HardActivityStateLevelConstraint hardActivityLevelConstraint = new HardActivityStateLevelConstraint() { + + @Override + public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) { + return ConstraintsStatus.FULFILLED; + } + }; + + HardRouteStateLevelConstraint hardRouteLevelConstraint = new HardRouteStateLevelConstraint(){ + + @Override + public boolean fulfilled(InsertionContext insertionContext) { + return true; + } + + }; + + ActivityInsertionCostsCalculator activityInsertionCostsCalculator; + + ShipmentInsertionCalculator insertionCalculator; + + Vehicle vehicle; + + @Before + public void doBefore(){ + Locations locations = new Locations(){ + + @Override + public Coordinate getCoord(String id) { + //assume: locationId="x,y" + String[] splitted = id.split(","); + return Coordinate.newInstance(Double.parseDouble(splitted[0]), + Double.parseDouble(splitted[1])); + } + + }; + 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(); + activityInsertionCostsCalculator = new LocalActivityInsertionCostsCalculator(routingCosts, activityCosts); + createInsertionCalculator(hardRouteLevelConstraint); + } + + private void createInsertionCalculator(HardRouteStateLevelConstraint hardRouteLevelConstraint) { + insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, hardActivityLevelConstraint); + } + + @Test + public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnTheCorrectInsertionIndex(){ + Delivery delivery = (Delivery) Delivery.Builder.newInstance("del", 41).setLocationId("10,10").build(); + 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(); + + VehicleRoute route = VehicleRoute.emptyRoute(); + route.setVehicle(vehicle, 0.0); + + Inserter inserter = new Inserter(new InsertionListeners()); + + inserter.insertJob(delivery, new InsertionData(0,0,0,vehicle,null), route); +// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route); +// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route); + + StateManager stateManager = new StateManager(); + +// RouteActivityVisitor routeActVisitor = new RouteActivityVisitor(); +// routeActVisitor.addActivityVisitor(new UpdateLoads(stateManager)); +// routeActVisitor.visit(route); + + VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class); + + ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); + constraintManager.addLoadConstraint(); +// constraintManager.addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL); +// constraintManager.addConstraint(new ShipmentPickupsFirstConstraint(),Priority.CRITICAL); + + stateManager.informInsertionStarts(Arrays.asList(route), null); + + JobCalculatorSwitcher switcher = new JobCalculatorSwitcher(); + ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager); + ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager); + switcher.put(Pickup.class, serviceInsertionCalc); + switcher.put(Delivery.class, serviceInsertionCalc); + switcher.put(Shipment.class, insertionCalculator); + +// Pickup service = (Pickup)Pickup.Builder.newInstance("pick", 1).setLocationId("5,5").build(); + InsertionData iData = switcher.getInsertionData(route, pickup, vehicle, 0, DriverImpl.noDriver(), Double.MAX_VALUE); +// routeActVisitor.visit(route); + + assertEquals(1, iData.getDeliveryInsertionIndex()); + } + +} diff --git a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java index a683a577..37d46f5b 100644 --- a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java +++ b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java @@ -2,9 +2,9 @@ package algorithms; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; + +import java.util.Arrays; import org.junit.Before; import org.junit.Test; @@ -13,7 +13,9 @@ import util.Coordinate; import util.Locations; import util.ManhattanCosts; import algorithms.ConstraintManager.Priority; -import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus; +import basics.Delivery; +import basics.Pickup; +import basics.Service; import basics.Shipment; import basics.VehicleRoutingProblem; import basics.costs.VehicleRoutingActivityCosts; @@ -201,4 +203,48 @@ public class ShipmentInsertionCalculatorTest { } + @Test + public void whenInsertingServiceWhileNoCapIsAvailable_itMustReturnNoInsertionData(){ + Shipment shipment = Shipment.Builder.newInstance("s", 1).setPickupLocation("0,10").setDeliveryLocation("0,0").build(); + Shipment shipment2 = Shipment.Builder.newInstance("s2", 1).setPickupLocation("10,10").setDeliveryLocation("0,0").build(); + Shipment shipment3 = Shipment.Builder.newInstance("s3", 1).setPickupLocation("10,10").setDeliveryLocation("0,").build(); + + VehicleRoute route = VehicleRoute.emptyRoute(); + route.setVehicle(vehicle, 0.0); + + Inserter inserter = new Inserter(new InsertionListeners()); + + inserter.insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route); + inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route); +// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route); + + StateManager stateManager = new StateManager(); + +// RouteActivityVisitor routeActVisitor = new RouteActivityVisitor(); +// routeActVisitor.addActivityVisitor(new UpdateLoads(stateManager)); +// routeActVisitor.visit(route); + + VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class); + + ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); + constraintManager.addLoadConstraint(); +// constraintManager.addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL); +// constraintManager.addConstraint(new ShipmentPickupsFirstConstraint(),Priority.CRITICAL); + + stateManager.informInsertionStarts(Arrays.asList(route), null); + + JobCalculatorSwitcher switcher = new JobCalculatorSwitcher(); + ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager); + ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager); + switcher.put(Pickup.class, serviceInsertionCalc); + switcher.put(Shipment.class, insertionCalculator); + + Pickup service = (Pickup)Pickup.Builder.newInstance("pick", 1).setLocationId("5,5").build(); + InsertionData iData = switcher.getInsertionData(route, service, vehicle, 0, DriverImpl.noDriver(), Double.MAX_VALUE); +// routeActVisitor.visit(route); + + assertEquals(3, iData.getDeliveryInsertionIndex()); + } + + } From 7522b5b89d4bc4f158420fd60824a9c222b18052 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:45:44 +0100 Subject: [PATCH 07/11] modify toString --- jsprit-core/src/main/java/basics/Service.java | 2 +- jsprit-core/src/main/java/basics/route/DeliverService.java | 2 +- jsprit-core/src/main/java/basics/route/PickupService.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jsprit-core/src/main/java/basics/Service.java b/jsprit-core/src/main/java/basics/Service.java index 985e0b21..82c781f2 100644 --- a/jsprit-core/src/main/java/basics/Service.java +++ b/jsprit-core/src/main/java/basics/Service.java @@ -139,7 +139,7 @@ public class Service implements Job { @Override public String toString() { - return "[id=" + id + "][locationId=" + locationId + "][coord="+coord+"][size=" + demand + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]"; + return "[id=" + id + "][type="+type+"][locationId=" + locationId + "][coord="+coord+"][size=" + demand + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]"; } /* (non-Javadoc) diff --git a/jsprit-core/src/main/java/basics/route/DeliverService.java b/jsprit-core/src/main/java/basics/route/DeliverService.java index 12ad4adb..92ce6148 100644 --- a/jsprit-core/src/main/java/basics/route/DeliverService.java +++ b/jsprit-core/src/main/java/basics/route/DeliverService.java @@ -83,6 +83,6 @@ public final class DeliverService implements DeliveryActivity{ @Override public String toString() { - return "[act="+getName()+"][loc="+getLocationId()+"]"; + return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]"; } } diff --git a/jsprit-core/src/main/java/basics/route/PickupService.java b/jsprit-core/src/main/java/basics/route/PickupService.java index 26139e95..200cd7bf 100644 --- a/jsprit-core/src/main/java/basics/route/PickupService.java +++ b/jsprit-core/src/main/java/basics/route/PickupService.java @@ -88,7 +88,7 @@ public final class PickupService implements PickupActivity{ @Override public String toString() { - return "[act="+getName()+"][loc="+getLocationId()+"]"; + return "[act="+getName()+"][capDemand="+getCapacityDemand()+"][loc="+getLocationId()+"]"; } } From b3e9ce84be14d4f9fe2843816575d485acc73683 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:46:19 +0100 Subject: [PATCH 08/11] move constraintManager var setting to constructor --- .../src/main/java/algorithms/BestInsertionBuilder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java b/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java index d51c4eef..3c97faca 100644 --- a/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java +++ b/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java @@ -35,11 +35,11 @@ public class BestInsertionBuilder implements InsertionStrategyBuilder{ private int nuOfThreads; - public BestInsertionBuilder(VehicleRoutingProblem vrp, VehicleFleetManager vehicleFleetManager, StateManager stateManager) { + public BestInsertionBuilder(VehicleRoutingProblem vrp, VehicleFleetManager vehicleFleetManager, StateManager stateManager, ConstraintManager constraintManager) { super(); this.vrp = vrp; this.stateManager = stateManager; - this.constraintManager = new ConstraintManager(vrp,stateManager); + this.constraintManager = constraintManager; this.fleetManager = vehicleFleetManager; } @@ -105,8 +105,8 @@ public class BestInsertionBuilder implements InsertionStrategyBuilder{ return bestInsertion; } - public void setConstraintManager(ConstraintManager constraintManager) { - this.constraintManager = constraintManager; - } +// public void setConstraintManager(ConstraintManager constraintManager) { +// this.constraintManager = constraintManager; +// } } From f455b4c9f2b3277f36ae51938cd4825f4b84a6f7 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:46:59 +0100 Subject: [PATCH 09/11] remove updater --- .../java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java index c7cbe92b..9ca3d81a 100644 --- a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java +++ b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java @@ -25,7 +25,7 @@ public class VehicleRoutingAlgorithmFactoryImpl implements VehicleRoutingAlgorit @Override public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp) { this.stateManager.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), this.stateManager)); - this.stateManager.addActivityVisitor(new UpdateMaxLoad(this.stateManager)); +// this.stateManager.addActivityVisitor(new UpdateMaxLoad_(this.stateManager)); VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(vrp, searchStrategyManager); algorithm.getAlgorithmListeners().addListener(stateManager); algorithm.getSearchStrategyManager().addSearchStrategyModuleListener(stateManager); From 787ad50298b7f618483dfe5169b1de48331bc8a2 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 17:47:59 +0100 Subject: [PATCH 10/11] some internals --- .../test/java/algorithms/StateUpdates.java | 2 +- jsprit-core/src/test/resources/pdp_sol.xml | 1754 ++++++++--------- .../examples/PickupAndDeliveryExample2.java | 5 + 3 files changed, 883 insertions(+), 878 deletions(-) diff --git a/jsprit-core/src/test/java/algorithms/StateUpdates.java b/jsprit-core/src/test/java/algorithms/StateUpdates.java index 4d6af67c..64041cf2 100644 --- a/jsprit-core/src/test/java/algorithms/StateUpdates.java +++ b/jsprit-core/src/test/java/algorithms/StateUpdates.java @@ -45,7 +45,7 @@ class UpdateStates implements JobInsertedListener, InsertionStartsListener{ routeActivityVisitor.addActivityVisitor(new UpdateActivityTimes(routingCosts)); routeActivityVisitor.addActivityVisitor(new UpdateVariableCosts(activityCosts, routingCosts, states)); routeActivityVisitor.addActivityVisitor(new UpdateLoads(states)); - routeActivityVisitor.addActivityVisitor(new UpdateMaxLoad(states)); + routeActivityVisitor.addActivityVisitor(new UpdateMaxLoad_(states)); revRouteActivityVisitor = new ReverseRouteActivityVisitor(); revRouteActivityVisitor.addActivityVisitor(new TimeWindowUpdater(states, routingCosts)); insertionListeners.addListener(new UpdateLoads(states)); diff --git a/jsprit-core/src/test/resources/pdp_sol.xml b/jsprit-core/src/test/resources/pdp_sol.xml index 3ed7bcdb..fbea3a8b 100644 --- a/jsprit-core/src/test/resources/pdp_sol.xml +++ b/jsprit-core/src/test/resources/pdp_sol.xml @@ -2534,264 +2534,55 @@ - 828.936866942834 + 1206.8889718907435 - 95.94313062205805 + 123.00615945405636 noDriver solomonVehicle 0.0 - - 98 - 0.0 - 0.0 - - - 94 - 0.0 - 0.0 - - - 97 - 0.0 - 0.0 - - - 95 - 0.0 - 0.0 - - - 100 - 0.0 - 0.0 - - - 99 - 0.0 - 0.0 - - - 96 - 0.0 - 0.0 - - - 93 - 0.0 - 0.0 - - - 92 - 0.0 - 0.0 - - - 98 - 30.805843601498726 - 30.805843601498726 - - - 96 - 36.19100840863323 - 95.0 - - - 95 - 97.0 - 196.0 - - - 94 - 199.605551275464 - 285.0 - - - 92 - 288.605551275464 - 368.0 - - - 93 - 370.0 - 475.0 - - - 97 - 480.0 - 561.0 - - - 100 - 566.0 - 647.0 - - - 99 - 652.0 - 743.0 - - 776.5410196624969 - - - 59.403108723710105 - noDriver - solomonVehicle - 0.0 - - 63 - 0.0 - 0.0 - - - 74 - 0.0 - 0.0 - - - 62 - 0.0 - 0.0 - - - 65 - 0.0 - 0.0 - - - 69 - 0.0 - 0.0 - - - 67 - 0.0 - 0.0 - - - 61 - 0.0 - 0.0 - - - 66 - 0.0 - 0.0 - - - 64 - 0.0 - 0.0 - - - 68 - 0.0 - 0.0 - - - 72 - 0.0 - 0.0 - - - 67 - 12.206555615733702 - 12.206555615733702 - - - 65 - 13.206555615733702 - 76.0 - - - 63 - 78.0 - 171.0 - - - 62 - 176.0 - 262.0 - - - 74 - 265.0 - 353.0 - - - 72 - 358.0 - 450.0 - - - 61 - 453.0 - 531.0 - - - 64 - 533.0 - 632.0 - - - 68 - 635.0 - 734.0 - - - 66 - 739.3851648071345 - 826.0 - - - 69 - 828.0 - 916.0 - - 931.8113883008419 - - - 95.88470913081827 - noDriver - solomonVehicle - 0.0 - - 17 - 0.0 - 0.0 - - - 12 - 0.0 - 0.0 - 14 0.0 0.0 + + 2 + 0.0 + 0.0 + + + 1 + 0.0 + 0.0 + + + 18 + 0.0 + 0.0 + + + 16 + 0.0 + 0.0 + 15 0.0 0.0 - - 18 - 0.0 - 0.0 - - - 19 - 0.0 - 0.0 - 13 0.0 0.0 - 16 + 99 + 0.0 + 0.0 + + + 19 0.0 0.0 @@ -2800,14 +2591,9 @@ 30.805843601498726 30.805843601498726 - - 17 - 34.80584360149872 - 99.0 - 18 - 102.0 + 37.80584360149872 179.0 @@ -2831,335 +2617,34 @@ 567.0 - 12 - 570.0 - 652.0 + 99 + 600.3766385365573 + 743.0 - 690.0788655293195 + + 2 + 757.142135623731 + 825.0 + + + 1 + 827.0 + 912.0 + + 930.6815416922694 - 127.29748041459519 + 129.13652582380297 noDriver solomonVehicle 0.0 - - 80 - 0.0 - 0.0 - - - 76 - 0.0 - 0.0 - - - 79 - 0.0 - 0.0 - - - 77 - 0.0 - 0.0 - - - 73 - 0.0 - 0.0 - - - 78 - 0.0 - 0.0 - - - 70 - 0.0 - 0.0 - - - 81 - 0.0 - 0.0 - - - 71 - 0.0 - 0.0 - - - 81 - 47.43416490252569 - 47.43416490252569 - - - 78 - 50.43416490252569 - 109.0 - - - 76 - 111.0 - 203.0 - - - 71 - 208.0 - 293.0 - - - 70 - 298.0 - 387.0 - - - 73 - 390.0 - 478.0 - - - 77 - 482.0 - 574.0 - - - 79 - 575.0 - 668.0 - - - 80 - 673.3851648071345 - 769.0 - - 820.478150704935 - - - 97.2271627850669 - noDriver - solomonVehicle - 0.0 - - 31 - 0.0 - 0.0 - - - 38 - 0.0 - 0.0 - - - 37 - 0.0 - 0.0 - - - 33 - 0.0 - 0.0 - - - 32 - 0.0 - 0.0 - - - 36 - 0.0 - 0.0 - - - 35 - 0.0 - 0.0 - - - 39 - 0.0 - 0.0 - - - 34 - 0.0 - 0.0 - - - 32 - 31.622776601683793 - 31.622776601683793 - - - 33 - 33.622776601683796 - 87.0 - - - 31 - 92.3851648071345 - 200.0 - - - 35 - 205.0 - 283.0 - - - 37 - 288.8309518948453 - 383.0 - - - 38 - 385.0 - 479.0 - - - 39 - 484.0 - 567.0 - - - 36 - 572.0 - 665.0 - - - 34 - 668.0 - 751.0 - - 783.3882694814033 - - - 101.88256760196126 - noDriver - solomonVehicle - 0.0 - - 56 - 0.0 - 0.0 - - - 54 - 0.0 - 0.0 - - - 57 - 0.0 - 0.0 - - - 59 - 0.0 - 0.0 - - - 55 - 0.0 - 0.0 - - - 58 - 0.0 - 0.0 - - - 60 - 0.0 - 0.0 - - - 53 - 0.0 - 0.0 - - - 57 - 35.0 - 35.0 - - - 55 - 37.0 - 95.0 - - - 54 - 100.0 - 186.0 - - - 53 - 191.38516480713452 - 286.0 - - - 56 - 290.0 - 385.0 - - - 58 - 387.0 - 471.0 - - - 60 - 474.0 - 562.0 - - - 59 - 572.4403065089106 - 651.0 - - 686.0570962859163 - - - 76.06956532288787 - noDriver - solomonVehicle - 0.0 - - 87 - 0.0 - 0.0 - - - 86 - 0.0 - 0.0 - 84 0.0 0.0 - 83 - 0.0 - 0.0 - - - 90 - 0.0 - 0.0 - - - 91 - 0.0 - 0.0 - - - 82 - 0.0 - 0.0 - - - 85 + 78 0.0 0.0 @@ -3168,11 +2653,158 @@ 0.0 0.0 + + 81 + 0.0 + 0.0 + + + 65 + 0.0 + 0.0 + + + 76 + 0.0 + 0.0 + + + 67 + 0.0 + 0.0 + + + 91 + 0.0 + 0.0 + + + 85 + 0.0 + 0.0 + 88 0.0 0.0 + + 71 + 0.0 + 0.0 + + + 67 + 12.206555615733702 + 12.206555615733702 + + + 65 + 13.206555615733702 + 76.0 + + + 81 + 113.33630940518894 + 113.33630940518894 + + + 78 + 116.33630940518894 + 116.33630940518894 + + + 76 + 118.33630940518894 + 203.0 + + + 71 + 208.0 + 293.0 + + + 84 + 326.97057550292607 + 458.0 + + + 85 + 460.8284271247462 + 555.0 + + + 88 + 558.0 + 645.0 + + + 89 + 647.8284271247462 + 737.0 + + + 91 + 740.605551275464 + 836.0 + + 858.360679774998 + + + 149.25708620100252 + noDriver + solomonVehicle + 0.0 + + 68 + 0.0 + 0.0 + + + 86 + 0.0 + 0.0 + + + 83 + 0.0 + 0.0 + + + 56 + 0.0 + 0.0 + + + 87 + 0.0 + 0.0 + + + 90 + 0.0 + 0.0 + + + 59 + 0.0 + 0.0 + + + 58 + 0.0 + 0.0 + + + 60 + 0.0 + 0.0 + + + 82 + 0.0 + 0.0 + 90 20.615528128088304 @@ -3199,84 +2831,54 @@ 369.0 - 84 - 374.8309518948453 - 458.0 + 56 + 430.0327780786685 + 430.0327780786685 - 85 - 460.8284271247462 - 555.0 + 58 + 432.0327780786685 + 471.0 - 88 - 558.0 - 645.0 + 60 + 474.0 + 562.0 - 89 - 647.8284271247462 - 737.0 + 59 + 572.4403065089106 + 651.0 - 91 - 740.605551275464 - 836.0 + 68 + 667.5529453572468 + 734.0 - 858.360679774998 + 754.6155281280883 - 64.80747449698114 + 111.83817397895926 noDriver solomonVehicle 0.0 - 45 + 31 0.0 0.0 - 49 + 34 0.0 0.0 - 47 + 32 0.0 0.0 - 51 - 0.0 - 0.0 - - - 46 - 0.0 - 0.0 - - - 44 - 0.0 - 0.0 - - - 43 - 0.0 - 0.0 - - - 42 - 0.0 - 0.0 - - - 40 - 0.0 - 0.0 - - - 52 + 24 0.0 0.0 @@ -3285,11 +2887,673 @@ 0.0 0.0 + + 33 + 0.0 + 0.0 + + + 35 + 0.0 + 0.0 + + + 51 + 0.0 + 0.0 + + + 52 + 0.0 + 0.0 + + + 38 + 0.0 + 0.0 + + + 36 + 0.0 + 0.0 + + + 24 + 15.0 + 65.0 + + + 32 + 83.02775637731995 + 83.02775637731995 + + + 33 + 85.02775637731995 + 87.0 + + + 31 + 92.3851648071345 + 200.0 + + + 35 + 205.0 + 283.0 + + + 38 + 290.0710678118655 + 479.0 + + + 36 + 486.0710678118655 + 665.0 + + + 34 + 668.0 + 751.0 + + + 51 + 773.6715680975093 + 773.6715680975093 + + + 50 + 775.9076360750091 + 815.0 + + + 52 + 818.1622776601683 + 912.0 + + 933.2132034355964 + + + 55.052543438165635 + noDriver + solomonVehicle + 0.0 + + 74 + 0.0 + 0.0 + + + 64 + 0.0 + 0.0 + + + 63 + 0.0 + 0.0 + + + 61 + 0.0 + 0.0 + + + 62 + 0.0 + 0.0 + + + 69 + 0.0 + 0.0 + + + 66 + 0.0 + 0.0 + + + 72 + 0.0 + 0.0 + + + 63 + 14.142135623730951 + 171.0 + + + 62 + 176.0 + 262.0 + + + 74 + 265.0 + 353.0 + + + 72 + 358.0 + 450.0 + + + 61 + 453.0 + 531.0 + + + 64 + 533.0 + 632.0 + + + 66 + 637.0990195135928 + 826.0 + + + 69 + 828.0 + 916.0 + + 931.8113883008419 + + + 132.6513166024448 + noDriver + solomonVehicle + 0.0 + + 29 + 0.0 + 0.0 + + + 39 + 0.0 + 0.0 + + + 22 + 0.0 + 0.0 + + + 20 + 0.0 + 0.0 + + + 27 + 0.0 + 0.0 + + + 21 + 0.0 + 0.0 + + + 23 + 0.0 + 0.0 + + + 28 + 0.0 + 0.0 + + + 25 + 0.0 + 0.0 + + + 26 + 0.0 + 0.0 + + + 37 + 0.0 + 0.0 + + + 30 + 0.0 + 0.0 + + + 20 + 10.0 + 10.0 + + + 25 + 15.385164807134505 + 169.0 + + + 27 + 171.0 + 261.0 + + + 29 + 264.605551275464 + 358.0 + + + 37 + 378.591260281974 + 383.0 + + + 30 + 406.43074902771997 + 449.0 + + + 39 + 471.3606797749979 + 567.0 + + + 28 + 592.0798724079689 + 592.0798724079689 + + + 26 + 594.0798724079689 + 622.0 + + + 23 + 625.0 + 732.0 + + + 22 + 735.0 + 812.0 + + + 21 + 814.0 + 914.0 + + 924.1980390271856 + + + 171.7443518305339 + noDriver + solomonVehicle + 0.0 + + 54 + 0.0 + 0.0 + + + 80 + 0.0 + 0.0 + + + 53 + 0.0 + 0.0 + + + 57 + 0.0 + 0.0 + + + 55 + 0.0 + 0.0 + + + 42 + 0.0 + 0.0 + + + 77 + 0.0 + 0.0 + + + 79 + 0.0 + 0.0 + + + 73 + 0.0 + 0.0 + + + 70 + 0.0 + 0.0 + + + 42 + 19.313207915827967 + 68.0 + + + 57 + 86.38477631085024 + 86.38477631085024 + + + 55 + 88.38477631085024 + 95.0 + + + 54 + 100.0 + 186.0 + + + 53 + 191.38516480713452 + 286.0 + + + 70 + 342.7978872846517 + 387.0 + + + 73 + 390.0 + 478.0 + + + 77 + 482.0 + 574.0 + + + 79 + 575.0 + 668.0 + + + 80 + 673.3851648071345 + 769.0 + + 820.478150704935 + + + 136.307638647898 + noDriver + solomonVehicle + 0.0 + + 100 + 0.0 + 0.0 + + + 17 + 0.0 + 0.0 + + + 94 + 0.0 + 0.0 + + + 92 + 0.0 + 0.0 + + + 95 + 0.0 + 0.0 + + + 4 + 0.0 + 0.0 + + + 97 + 0.0 + 0.0 + + + 93 + 0.0 + 0.0 + + + 17 + 33.301651610693426 + 99.0 + + + 95 + 143.28317965096906 + 196.0 + + + 94 + 199.605551275464 + 285.0 + + + 92 + 288.605551275464 + 368.0 + + + 93 + 370.0 + 475.0 + + + 97 + 480.0 + 561.0 + + + 100 + 566.0 + 647.0 + + + 4 + 668.4009345590327 + 727.0 + + 745.1107702762748 + + + 140.88049577910311 + noDriver + solomonVehicle + 0.0 + + 98 + 0.0 + 0.0 + + + 9 + 0.0 + 0.0 + + + 11 + 0.0 + 0.0 + + + 8 + 0.0 + 0.0 + + + 3 + 0.0 + 0.0 + + + 5 + 0.0 + 0.0 + + + 96 + 0.0 + 0.0 + + + 75 + 0.0 + 0.0 + + + 7 + 0.0 + 0.0 + + + 6 + 0.0 + 0.0 + + + 10 + 0.0 + 0.0 + + + 12 + 0.0 + 0.0 + + + 5 + 15.132745950421556 + 15.132745950421556 + + + 3 + 16.13274595042156 + 65.0 + + + 98 + 83.35755975068582 + 83.35755975068582 + + + 96 + 88.74272455782032 + 95.0 + + + 7 + 119.41311123146741 + 170.0 + + + 8 + 172.82842712474618 + 255.0 + + + 10 + 258.605551275464 + 357.0 + + + 11 + 360.0 + 448.0 + + + 9 + 451.1622776601684 + 534.0 + + + 12 + 553.8494332412793 + 652.0 + + + 6 + 673.9317121994613 + 673.9317121994613 + + + 75 + 680.3348364368942 + 997.0 + + 1012.8113883008419 + + + 57.014680134776974 + noDriver + solomonVehicle + 0.0 + + 40 + 0.0 + 0.0 + + + 47 + 0.0 + 0.0 + + + 44 + 0.0 + 0.0 + 41 0.0 0.0 + + 43 + 0.0 + 0.0 + + + 45 + 0.0 + 0.0 + + + 46 + 0.0 + 0.0 + + + 49 + 0.0 + 0.0 + 48 0.0 @@ -3300,14 +3564,9 @@ 16.55294535724685 16.55294535724685 - - 42 - 19.55294535724685 - 68.0 - 41 - 70.0 + 20.158496632710836 166.0 @@ -3335,24 +3594,9 @@ 543.0 632.0 - - 51 - 635.0 - 725.0 - - - 50 - 727.2360679774998 - 815.0 - - - 52 - 818.1622776601683 - 912.0 - 49 - 915.0 + 637.0 1001.0 @@ -3362,250 +3606,6 @@ 1072.02775637732 - - 50.80359030264955 - noDriver - solomonVehicle - 0.0 - - 20 - 0.0 - 0.0 - - - 21 - 0.0 - 0.0 - - - 23 - 0.0 - 0.0 - - - 27 - 0.0 - 0.0 - - - 30 - 0.0 - 0.0 - - - 25 - 0.0 - 0.0 - - - 24 - 0.0 - 0.0 - - - 26 - 0.0 - 0.0 - - - 28 - 0.0 - 0.0 - - - 29 - 0.0 - 0.0 - - - 22 - 0.0 - 0.0 - - - 20 - 10.0 - 10.0 - - - 24 - 15.0 - 65.0 - - - 25 - 67.0 - 169.0 - - - 27 - 171.0 - 261.0 - - - 29 - 264.605551275464 - 358.0 - - - 30 - 363.0 - 449.0 - - - 28 - 452.0 - 546.0 - - - 26 - 548.0 - 622.0 - - - 23 - 625.0 - 732.0 - - - 22 - 735.0 - 812.0 - - - 21 - 814.0 - 914.0 - - 924.1980390271856 - - - 59.618077542105574 - noDriver - solomonVehicle - 0.0 - - 8 - 0.0 - 0.0 - - - 7 - 0.0 - 0.0 - - - 4 - 0.0 - 0.0 - - - 2 - 0.0 - 0.0 - - - 5 - 0.0 - 0.0 - - - 10 - 0.0 - 0.0 - - - 3 - 0.0 - 0.0 - - - 75 - 0.0 - 0.0 - - - 6 - 0.0 - 0.0 - - - 11 - 0.0 - 0.0 - - - 1 - 0.0 - 0.0 - - - 9 - 0.0 - 0.0 - - - 5 - 15.132745950421556 - 15.132745950421556 - - - 3 - 16.13274595042156 - 65.0 - - - 7 - 67.0 - 170.0 - - - 8 - 172.82842712474618 - 255.0 - - - 10 - 258.605551275464 - 357.0 - - - 11 - 360.0 - 448.0 - - - 9 - 451.1622776601684 - 534.0 - - - 6 - 536.2360679774998 - 621.0 - - - 4 - 623.2360679774998 - 727.0 - - - 2 - 730.605551275464 - 825.0 - - - 1 - 827.0 - 912.0 - - - 75 - 915.0 - 997.0 - - 1012.8113883008419 - diff --git a/jsprit-examples/src/main/java/examples/PickupAndDeliveryExample2.java b/jsprit-examples/src/main/java/examples/PickupAndDeliveryExample2.java index 8d5929c9..e3e92132 100644 --- a/jsprit-examples/src/main/java/examples/PickupAndDeliveryExample2.java +++ b/jsprit-examples/src/main/java/examples/PickupAndDeliveryExample2.java @@ -19,6 +19,9 @@ package examples; import java.io.File; import java.util.Collection; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + import algorithms.VehicleRoutingAlgorithms; import algorithms.selectors.SelectBest; import analysis.AlgorithmSearchProgressChartListener; @@ -37,6 +40,8 @@ public class PickupAndDeliveryExample2 { public static void main(String[] args) { + Logger.getRootLogger().setLevel(Level.INFO); + /* * some preparation - create output folder */ From 9ecdde00e658f515bb59b250995a5421031f8de7 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Sun, 17 Nov 2013 18:00:10 +0100 Subject: [PATCH 11/11] internals --- jsprit-core/src/main/java/algorithms/Gendreau.java | 2 +- jsprit-core/src/main/java/algorithms/Inserter.java | 2 -- .../PickupAndDeliverShipmentLoadActivityLevelConstraint.java | 1 - .../java/algorithms/ServiceLoadActivityLevelConstraint.java | 1 - .../src/main/java/algorithms/UpdateActivityTimes.java | 1 - .../src/main/java/algorithms/UpdateVariableCosts.java | 2 -- .../src/main/java/algorithms/VehicleRoutingAlgorithms.java | 1 - jsprit-core/src/main/java/basics/route/DeliveryActivity.java | 1 - .../algorithms/ServiceInsertionAndLoadConstraintsTest.java | 4 ---- .../java/algorithms/ShipmentInsertionCalculatorTest.java | 2 -- .../src/test/java/basics/route/VehicleRouteBuilderTest.java | 5 +++-- 11 files changed, 4 insertions(+), 18 deletions(-) diff --git a/jsprit-core/src/main/java/algorithms/Gendreau.java b/jsprit-core/src/main/java/algorithms/Gendreau.java index 7c46473d..b2b76cd8 100644 --- a/jsprit-core/src/main/java/algorithms/Gendreau.java +++ b/jsprit-core/src/main/java/algorithms/Gendreau.java @@ -36,8 +36,8 @@ import basics.algo.RuinListener; import basics.algo.SearchStrategyModule; import basics.algo.SearchStrategyModuleListener; import basics.route.TourActivity; -import basics.route.VehicleFleetManager; import basics.route.TourActivity.JobActivity; +import basics.route.VehicleFleetManager; import basics.route.VehicleRoute; final class Gendreau implements SearchStrategyModule{ diff --git a/jsprit-core/src/main/java/algorithms/Inserter.java b/jsprit-core/src/main/java/algorithms/Inserter.java index a649bdc2..afe677ba 100644 --- a/jsprit-core/src/main/java/algorithms/Inserter.java +++ b/jsprit-core/src/main/java/algorithms/Inserter.java @@ -16,8 +16,6 @@ ******************************************************************************/ package algorithms; -import org.apache.log4j.Logger; - import algorithms.InsertionData.NoInsertionFound; import basics.Job; import basics.Service; diff --git a/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java index 60c7ac8b..d54653ff 100644 --- a/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/algorithms/PickupAndDeliverShipmentLoadActivityLevelConstraint.java @@ -2,7 +2,6 @@ package algorithms; import org.apache.log4j.Logger; -import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus; import basics.route.DeliverShipment; import basics.route.PickupShipment; import basics.route.Start; diff --git a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java index 9e23f68c..65ede0ec 100644 --- a/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java +++ b/jsprit-core/src/main/java/algorithms/ServiceLoadActivityLevelConstraint.java @@ -7,7 +7,6 @@ import basics.route.PickupService; import basics.route.ServiceActivity; import basics.route.Start; import basics.route.TourActivity; -import basics.route.VehicleRoute; /** * Ensures load constraint for inserting ServiceActivity. diff --git a/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java b/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java index 860504c0..8d18d0c9 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java +++ b/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java @@ -3,7 +3,6 @@ package algorithms; import org.apache.log4j.Logger; import util.ActivityTimeTracker; - import basics.costs.ForwardTransportTime; import basics.route.ActivityVisitor; import basics.route.TourActivity; diff --git a/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java b/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java index 893813b4..f8383b50 100644 --- a/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java +++ b/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java @@ -3,14 +3,12 @@ package algorithms; import org.apache.log4j.Logger; import util.ActivityTimeTracker; - import algorithms.StateManager.StateImpl; import basics.costs.ForwardTransportCost; import basics.costs.VehicleRoutingActivityCosts; import basics.costs.VehicleRoutingTransportCosts; import basics.route.ActivityVisitor; import basics.route.TourActivity; -import basics.route.Vehicle; import basics.route.VehicleRoute; /** diff --git a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java index 120104f1..11c4740e 100644 --- a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java +++ b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java @@ -46,7 +46,6 @@ import algorithms.selectors.SelectRandomly; import algorithms.selectors.SolutionSelector; import basics.VehicleRoutingAlgorithm; import basics.VehicleRoutingProblem; -import basics.VehicleRoutingProblem.Constraint; import basics.VehicleRoutingProblem.FleetSize; import basics.VehicleRoutingProblemSolution; import basics.algo.AlgorithmStartsListener; diff --git a/jsprit-core/src/main/java/basics/route/DeliveryActivity.java b/jsprit-core/src/main/java/basics/route/DeliveryActivity.java index fc859139..4c49f0fc 100644 --- a/jsprit-core/src/main/java/basics/route/DeliveryActivity.java +++ b/jsprit-core/src/main/java/basics/route/DeliveryActivity.java @@ -16,7 +16,6 @@ ******************************************************************************/ package basics.route; -import basics.Delivery; import basics.route.TourActivity.JobActivity; public interface DeliveryActivity extends JobActivity{ diff --git a/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java b/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java index 3d28bfe0..31af1b45 100644 --- a/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java +++ b/jsprit-core/src/test/java/algorithms/ServiceInsertionAndLoadConstraintsTest.java @@ -1,7 +1,6 @@ package algorithms; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import java.util.Arrays; @@ -12,17 +11,14 @@ import org.junit.Test; import util.Coordinate; import util.Locations; import util.ManhattanCosts; -import algorithms.ConstraintManager.Priority; import basics.Delivery; import basics.Pickup; -import basics.Service; import basics.Shipment; import basics.VehicleRoutingProblem; import basics.costs.VehicleRoutingActivityCosts; import basics.costs.VehicleRoutingTransportCosts; import basics.route.Driver; import basics.route.DriverImpl; -import basics.route.RouteActivityVisitor; import basics.route.TourActivity; import basics.route.Vehicle; import basics.route.VehicleImpl; diff --git a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java index 37d46f5b..46a5912a 100644 --- a/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java +++ b/jsprit-core/src/test/java/algorithms/ShipmentInsertionCalculatorTest.java @@ -13,9 +13,7 @@ import util.Coordinate; import util.Locations; import util.ManhattanCosts; import algorithms.ConstraintManager.Priority; -import basics.Delivery; import basics.Pickup; -import basics.Service; import basics.Shipment; import basics.VehicleRoutingProblem; import basics.costs.VehicleRoutingActivityCosts; diff --git a/jsprit-core/src/test/java/basics/route/VehicleRouteBuilderTest.java b/jsprit-core/src/test/java/basics/route/VehicleRouteBuilderTest.java index 6cc7bcc9..f8c5862e 100644 --- a/jsprit-core/src/test/java/basics/route/VehicleRouteBuilderTest.java +++ b/jsprit-core/src/test/java/basics/route/VehicleRouteBuilderTest.java @@ -1,10 +1,11 @@ package basics.route; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + import org.junit.Test; import basics.Shipment; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; public class VehicleRouteBuilderTest {