mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add and test new ruin strategy: cluster ruin based on dbscan clusterer
This commit is contained in:
parent
708400a34a
commit
f4dc5e3b8d
8 changed files with 356 additions and 30 deletions
|
|
@ -16,6 +16,7 @@
|
|||
******************************************************************************/
|
||||
package jsprit.examples;
|
||||
|
||||
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import jsprit.analysis.toolbox.Plotter;
|
||||
|
|
@ -272,13 +273,28 @@ public class BicycleMessenger {
|
|||
// vraBuilder.setNuOfThreads(2);
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
vraBuilder.setNuOfThreads(10);
|
||||
// vraBuilder.setNuOfThreads(10);
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
algorithm.setMaxIterations(10000);
|
||||
algorithm.setMaxIterations(2000);
|
||||
|
||||
// VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(bicycleMessengerProblem)
|
||||
// .setStateAndConstraintManager(stateManager, constraintManager)
|
||||
// .setProperty(Jsprit.Parameter.THREADS.toString(), "6")
|
||||
//// .setProperty(Jsprit.Strategy.RADIAL_BEST.toString(), "0.25")
|
||||
//// .setProperty(Jsprit.Strategy.WORST_BEST.toString(), "0.25")
|
||||
//// .setProperty(Jsprit.Strategy.CLUSTER_BEST.toString(), "0.25")
|
||||
//// .setProperty(Jsprit.Strategy.RANDOM_BEST.toString(), "0.")
|
||||
//// .setProperty(Jsprit.Strategy.RANDOM_REGRET.toString(), "1.")
|
||||
// .setProperty(Jsprit.Parameter.INSERTION_NOISE_LEVEL.toString(),"0.01")
|
||||
// .setProperty(Jsprit.Parameter.INSERTION_NOISE_PROB.toString(), "0.2")
|
||||
//// .setProperty(Jsprit.Parameter.THRESHOLD_ALPHA.toString(),"0.1")
|
||||
// .buildAlgorithm();
|
||||
// algorithm.setMaxIterations(5000);
|
||||
|
||||
// VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001);
|
||||
// algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
|
||||
// algorithm.addListener(prematureAlgorithmTermination);
|
||||
// algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
|
||||
//search
|
||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package jsprit.examples;
|
|||
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import jsprit.core.algorithm.box.Jsprit;
|
||||
import jsprit.core.algorithm.state.InternalStates;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.Capacity;
|
||||
|
|
@ -184,21 +184,13 @@ public class MultipleProductsWithLoadConstraintExample {
|
|||
.addVehicle(vehicle)
|
||||
.addJob(bananas).addJob(apples).addJob(bananas_2).addJob(bananas_3).addJob(apples_2).build();
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"input/algorithmConfig.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
StateManager stateManager = new StateManager(vrp); //1.3.2-SNAPSHOT & upcoming release v1.4
|
||||
// StateManager stateManager = new StateManager(vrp.getTransportCosts()); //v1.3.1
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addConstraint(new NoBananasANDApplesConstraint(stateManager), ConstraintManager.Priority.CRITICAL);
|
||||
// constraintManager.addConstraint(new BananasFirst(),ConstraintManager.Priority.CRITICAL);
|
||||
|
||||
vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
// vra.setMaxIterations(100); //1.3.2-SNAPSHOT
|
||||
// vra.setMaxIterations(100);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setStateAndConstraintManager(stateManager,constraintManager)
|
||||
.buildAlgorithm();
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -206,7 +198,6 @@ public class MultipleProductsWithLoadConstraintExample {
|
|||
|
||||
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).labelWith(GraphStreamViewer.Label.ID).setRenderShipments(true).display();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static Location loc(Coordinate coordinate) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import jsprit.analysis.toolbox.GraphStreamViewer;
|
|||
import jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import jsprit.analysis.toolbox.Plotter;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import jsprit.core.algorithm.box.Jsprit;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
|
|
@ -64,7 +64,8 @@ public class SolomonOpenExample {
|
|||
* The algorithm can be defined and configured in an xml-file.
|
||||
*/
|
||||
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_fix.xml");
|
||||
// VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_fix.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
// vra.setPrematureBreak(100);
|
||||
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package jsprit.examples;
|
|||
import jsprit.analysis.toolbox.Plotter;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import jsprit.core.algorithm.box.Jsprit;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
|
|
@ -90,9 +91,7 @@ public class SolomonWithSkillsExample {
|
|||
ConstraintManager constraintManager = new ConstraintManager(skillProblem,stateManager);
|
||||
constraintManager.addSkillsConstraint();
|
||||
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
// vra.setMaxIterations(500);
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(skillProblem).setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
******************************************************************************/
|
||||
package jsprit.examples;
|
||||
|
||||
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||
import jsprit.analysis.toolbox.Plotter;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import jsprit.core.algorithm.box.Jsprit;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.analysis.SolutionAnalyser;
|
||||
|
|
@ -73,16 +75,25 @@ public class VRPWithBackhaulsExample2 {
|
|||
*/
|
||||
// VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"input/algorithmConfig_solomon.xml");
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.addCoreConstraints();
|
||||
// VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"input/algorithmConfig_solomon.xml");
|
||||
// vraBuilder.addDefaultCostCalculators();
|
||||
// vraBuilder.addCoreConstraints();
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addConstraint(new ServiceDeliveriesFirstConstraint(), ConstraintManager.Priority.CRITICAL);
|
||||
|
||||
vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
// vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
|
||||
|
||||
// VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp)
|
||||
.setStateAndConstraintManager(stateManager, constraintManager)
|
||||
.setProperty(Jsprit.Parameter.FIXED_COST_PARAM.toString(),"0.")
|
||||
.buildAlgorithm();
|
||||
vra.setMaxIterations(2000);
|
||||
vra.addListener(new AlgorithmSearchProgressChartListener("output/search"));
|
||||
|
||||
|
||||
|
||||
|
|
@ -107,9 +118,9 @@ public class VRPWithBackhaulsExample2 {
|
|||
* Plot solution.
|
||||
*/
|
||||
// SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/pd_solomon_r101_solution.png","pd_r101");
|
||||
// Plotter plotter = new Plotter(vrp, solution);
|
||||
// plotter.setLabel(Label.SIZE);
|
||||
// plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png","vrpwbh_vrpnc1");
|
||||
Plotter plotter = new Plotter(vrp, solution);
|
||||
// plotter.setLabel(Plotter.Label.SIZE);
|
||||
plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png","vrpwbh_vrpnc1");
|
||||
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new SolutionAnalyser.DistanceCalculator() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue