From 6c57c8502d633c04c52a35e9212f789794200ccd Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 5 Dec 2013 12:15:01 +0100 Subject: [PATCH] play with examples --- .../src/main/java/jsprit/examples/BicycleMessenger.java | 5 +++-- .../examples/MultipleDepotExampleWithPenaltyVehicles.java | 5 +++-- .../SimpleEnRoutePickupAndDeliveryOpenRoutesExample.java | 3 ++- .../src/main/java/jsprit/examples/SolomonExample.java | 3 ++- .../main/java/jsprit/examples/VRPWithBackhaulsExample.java | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java index d1c23a52..00889a93 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java +++ b/jsprit-examples/src/main/java/jsprit/examples/BicycleMessenger.java @@ -10,6 +10,7 @@ import java.util.Map; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.SolutionPrinter; +import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.state.StateManager; @@ -209,14 +210,14 @@ public class BicycleMessenger { //if you want, terminate it after 1000 iterations with no change algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000)); // algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png")); - algorithm.setNuOfIterations(500); +// algorithm.setNuOfIterations(50); Collection solutions = algorithm.searchSolutions(); //this is just to ensure that solution meet the above constraints validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers); SolutionPrinter.print(Solutions.bestOf(solutions)); - SolutionPrinter.print(Solutions.bestOf(solutions), bicycleMessengerProblem); + SolutionPrinter.print(bicycleMessengerProblem, Solutions.bestOf(solutions), Print.VERBOSE); //you may want to plot the problem Plotter plotter = new Plotter(bicycleMessengerProblem); diff --git a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExampleWithPenaltyVehicles.java b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExampleWithPenaltyVehicles.java index 306128eb..df706ad7 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExampleWithPenaltyVehicles.java +++ b/jsprit-examples/src/main/java/jsprit/examples/MultipleDepotExampleWithPenaltyVehicles.java @@ -24,6 +24,7 @@ import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.StopWatch; +import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority; @@ -97,7 +98,7 @@ public class MultipleDepotExampleWithPenaltyVehicles { * to mark the penalty-type as penalty-type, wrap it with PenaltyVehicleType(Wrapper) * this is to tell the fleetManager that this is not a regular but a penalty vehicle */ - PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType); + PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType,3); String vehicleId = depotCounter + "_vehicle#penalty"; VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId); vehicleBuilder.setLocationCoord(depotCoord); @@ -137,7 +138,7 @@ public class MultipleDepotExampleWithPenaltyVehicles { vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png")); Collection solutions = vra.searchSolutions(); - SolutionPrinter.print(Solutions.bestOf(solutions)); + SolutionPrinter.print(vrp,Solutions.bestOf(solutions),Print.VERBOSE); SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p08_solution.png", "p08"); } diff --git a/jsprit-examples/src/main/java/jsprit/examples/SimpleEnRoutePickupAndDeliveryOpenRoutesExample.java b/jsprit-examples/src/main/java/jsprit/examples/SimpleEnRoutePickupAndDeliveryOpenRoutesExample.java index 4203e4aa..72ef8577 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/SimpleEnRoutePickupAndDeliveryOpenRoutesExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/SimpleEnRoutePickupAndDeliveryOpenRoutesExample.java @@ -22,6 +22,7 @@ import java.util.Collection; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.SolutionPrinter; +import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.box.SchrimpfFactory; import jsprit.core.problem.VehicleRoutingProblem; @@ -111,7 +112,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample { /* * print nRoutes and totalCosts of bestSolution */ - SolutionPrinter.print(bestSolution); + SolutionPrinter.print(problem,bestSolution,Print.VERBOSE); /* * plot problem without solution diff --git a/jsprit-examples/src/main/java/jsprit/examples/SolomonExample.java b/jsprit-examples/src/main/java/jsprit/examples/SolomonExample.java index 6cabfe27..dbd7dad3 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/SolomonExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/SolomonExample.java @@ -22,6 +22,7 @@ import java.util.Collection; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.SolutionPrinter; +import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; import jsprit.core.algorithm.selector.SelectBest; @@ -87,7 +88,7 @@ public class SolomonExample { /* * print solution */ - SolutionPrinter.print(solution); + SolutionPrinter.print(vrp,solution,Print.VERBOSE); /* * Plot solution. diff --git a/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample.java b/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample.java index defe942d..56d4e4a7 100644 --- a/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample.java +++ b/jsprit-examples/src/main/java/jsprit/examples/VRPWithBackhaulsExample.java @@ -22,6 +22,7 @@ import java.util.Collection; import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener; import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.Plotter.Label; +import jsprit.analysis.toolbox.SolutionPrinter.Print; import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.io.VehicleRoutingAlgorithms; @@ -93,7 +94,7 @@ public class VRPWithBackhaulsExample { /* * print solution */ - SolutionPrinter.print(solution); + SolutionPrinter.print(vrp,solution,Print.VERBOSE); /* * Plot solution.