mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
modify SolomonExamply to comply with corresponding wiki-example
This commit is contained in:
parent
8f5ebf18e3
commit
a113a6cf18
1 changed files with 8 additions and 30 deletions
|
|
@ -23,7 +23,8 @@ package examples;
|
|||
import java.util.Collection;
|
||||
|
||||
import readers.SolomonReader;
|
||||
import algorithms.VehicleRoutingAlgorithms;
|
||||
import algorithms.GreedySchrimpfFactory;
|
||||
import algorithms.SchrimpfFactory;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import analysis.AlgorithmSearchProgressChartListener;
|
||||
import analysis.SolutionPlotter;
|
||||
|
|
@ -34,13 +35,12 @@ import basics.VehicleRoutingAlgorithm;
|
|||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
||||
import basics.io.AlgorithmConfig;
|
||||
import basics.io.AlgorithmConfigXmlReader;
|
||||
|
||||
public class SolomonExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
/*
|
||||
* Build the problem.
|
||||
*
|
||||
|
|
@ -58,29 +58,15 @@ public class SolomonExample {
|
|||
*/
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
SolutionPlotter.plotVrpAsPNG(vrp, "output/solomon_C101.png", "C101");
|
||||
|
||||
/*
|
||||
* Define the required vehicle-routing algorithms to solve the above problem.
|
||||
*
|
||||
* The algorithm can be defined and configured in an xml-file.
|
||||
*/
|
||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||
new AlgorithmConfigXmlReader(algorithmConfig).read("input/algorithmConfig_solomon.xml");
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.createAlgorithm(vrp, algorithmConfig);
|
||||
vra.setPrematureBreak(500);
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
|
||||
/*
|
||||
* Listen to the search-progress.
|
||||
*/
|
||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/searchProgress.png"));
|
||||
|
||||
/*
|
||||
* StopWatch to measure computation time.
|
||||
*/
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
vra.getAlgorithmListeners().addListener(stopWatch,Priority.HIGH);
|
||||
|
||||
// vra.setPrematureBreak(200);
|
||||
/*
|
||||
* Solve the problem.
|
||||
*
|
||||
|
|
@ -93,21 +79,13 @@ public class SolomonExample {
|
|||
*/
|
||||
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
|
||||
|
||||
/*
|
||||
* Print computation time.
|
||||
*/
|
||||
System.out.println(stopWatch);
|
||||
|
||||
/*
|
||||
* Print solution.
|
||||
*/
|
||||
|
||||
SolutionPrinter.print(solution, Print.VERBOSE);
|
||||
|
||||
/*
|
||||
* Plot solution.
|
||||
*/
|
||||
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomonSolution.png","C101");
|
||||
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_C101_solution.png","C101");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue