1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

replace SolutionPrinter to now print formatted solution

This commit is contained in:
Stefan Schroeder 2013-12-06 11:42:44 +01:00
parent 35b9c89375
commit 4da3b4390f
2 changed files with 5 additions and 3 deletions

View file

@ -219,7 +219,7 @@ public class BicycleMessenger {
//create your algorithm //create your algorithm
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(bicycleMessengerProblem,"input/algorithmConfig_open.xml", stateManager); VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(bicycleMessengerProblem,"input/algorithmConfig_open.xml", stateManager);
//if you want, terminate it after 1000 iterations with no change //if you want, terminate it after 1000 iterations with no change
algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100)); // algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png")); algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
algorithm.setNuOfIterations(2000); algorithm.setNuOfIterations(2000);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
@ -227,7 +227,6 @@ public class BicycleMessenger {
//this is just to ensure that solution meet the above constraints //this is just to ensure that solution meet the above constraints
validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers); validateSolution(Solutions.bestOf(solutions), bicycleMessengerProblem, nearestMessengers);
SolutionPrinter.print(bicycleMessengerProblem, Solutions.bestOf(solutions), Print.VERBOSE);
//you may want to plot the problem //you may want to plot the problem
Plotter plotter = new Plotter(bicycleMessengerProblem); Plotter plotter = new Plotter(bicycleMessengerProblem);
@ -245,6 +244,8 @@ public class BicycleMessenger {
//and write out your solution in xml //and write out your solution in xml
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml"); new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
SolutionPrinter.print(bicycleMessengerProblem, Solutions.bestOf(solutions), Print.VERBOSE);
} }

View file

@ -21,6 +21,7 @@ import java.util.Collection;
import jsprit.analysis.toolbox.SolutionPlotter; import jsprit.analysis.toolbox.SolutionPlotter;
import jsprit.analysis.toolbox.SolutionPrinter; import jsprit.analysis.toolbox.SolutionPrinter;
import jsprit.analysis.toolbox.SolutionPrinter.Print;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.box.SchrimpfFactory; import jsprit.core.algorithm.box.SchrimpfFactory;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
@ -97,7 +98,7 @@ public class SimpleExample {
new VrpXMLWriter(problem, solutions).write("output/problem-with-solution.xml"); new VrpXMLWriter(problem, solutions).write("output/problem-with-solution.xml");
SolutionPrinter.print(bestSolution); SolutionPrinter.print(problem,bestSolution,Print.VERBOSE);
/* /*
* plot * plot