mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
play with examples
This commit is contained in:
parent
685a2ad614
commit
6c57c8502d
5 changed files with 12 additions and 7 deletions
|
|
@ -10,6 +10,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
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.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||||
import jsprit.core.algorithm.state.StateManager;
|
import jsprit.core.algorithm.state.StateManager;
|
||||||
|
|
@ -209,14 +210,14 @@ public class BicycleMessenger {
|
||||||
//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(1000));
|
algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
|
||||||
// algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
// algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
algorithm.setNuOfIterations(500);
|
// algorithm.setNuOfIterations(50);
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||||
|
|
||||||
//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(Solutions.bestOf(solutions));
|
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
|
//you may want to plot the problem
|
||||||
Plotter plotter = new Plotter(bicycleMessengerProblem);
|
Plotter plotter = new Plotter(bicycleMessengerProblem);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||||
import jsprit.analysis.toolbox.SolutionPlotter;
|
import jsprit.analysis.toolbox.SolutionPlotter;
|
||||||
import jsprit.analysis.toolbox.SolutionPrinter;
|
import jsprit.analysis.toolbox.SolutionPrinter;
|
||||||
import jsprit.analysis.toolbox.StopWatch;
|
import jsprit.analysis.toolbox.StopWatch;
|
||||||
|
import jsprit.analysis.toolbox.SolutionPrinter.Print;
|
||||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||||
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
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)
|
* 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
|
* 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";
|
String vehicleId = depotCounter + "_vehicle#penalty";
|
||||||
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
||||||
vehicleBuilder.setLocationCoord(depotCoord);
|
vehicleBuilder.setLocationCoord(depotCoord);
|
||||||
|
|
@ -137,7 +138,7 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> 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");
|
SolutionPlotter.plotSolutionAsPNG(vrp, Solutions.bestOf(solutions), "output/p08_solution.png", "p08");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
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;
|
||||||
|
|
@ -111,7 +112,7 @@ public class SimpleEnRoutePickupAndDeliveryOpenRoutesExample {
|
||||||
/*
|
/*
|
||||||
* print nRoutes and totalCosts of bestSolution
|
* print nRoutes and totalCosts of bestSolution
|
||||||
*/
|
*/
|
||||||
SolutionPrinter.print(bestSolution);
|
SolutionPrinter.print(problem,bestSolution,Print.VERBOSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* plot problem without solution
|
* plot problem without solution
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
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.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||||
import jsprit.core.algorithm.selector.SelectBest;
|
import jsprit.core.algorithm.selector.SelectBest;
|
||||||
|
|
@ -87,7 +88,7 @@ public class SolomonExample {
|
||||||
/*
|
/*
|
||||||
* print solution
|
* print solution
|
||||||
*/
|
*/
|
||||||
SolutionPrinter.print(solution);
|
SolutionPrinter.print(vrp,solution,Print.VERBOSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plot solution.
|
* Plot solution.
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||||
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
import jsprit.analysis.toolbox.Plotter.Label;
|
import jsprit.analysis.toolbox.Plotter.Label;
|
||||||
|
import jsprit.analysis.toolbox.SolutionPrinter.Print;
|
||||||
import jsprit.analysis.toolbox.SolutionPrinter;
|
import jsprit.analysis.toolbox.SolutionPrinter;
|
||||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||||
|
|
@ -93,7 +94,7 @@ public class VRPWithBackhaulsExample {
|
||||||
/*
|
/*
|
||||||
* print solution
|
* print solution
|
||||||
*/
|
*/
|
||||||
SolutionPrinter.print(solution);
|
SolutionPrinter.print(vrp,solution,Print.VERBOSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plot solution.
|
* Plot solution.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue