mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
fixed compile error
This commit is contained in:
parent
9f82dd122e
commit
e4858098cf
11 changed files with 36 additions and 94 deletions
|
|
@ -20,6 +20,7 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -36,7 +37,6 @@ import com.graphhopper.jsprit.core.util.Coordinate;
|
|||
import com.graphhopper.jsprit.core.util.EuclideanDistanceCalculator;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.core.util.VehicleRoutingTransportCostsMatrix;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -138,25 +138,17 @@ public class AdditionalDistanceConstraintExample {
|
|||
vrpBuilder.setRoutingCost(costMatrix);
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "input/algorithmConfig_solomon.xml");
|
||||
|
||||
// StateManager stateManager = new StateManager(vrp.getTransportCosts()); //v1.3.1
|
||||
StateManager stateManager = new StateManager(vrp); //head of development - upcoming release (v1.4)
|
||||
|
||||
// StateFactory.StateId distanceStateId = StateFactory.createId("distance"); //v1.3.1
|
||||
StateId distanceStateId = stateManager.createStateId("distance"); //head of development - upcoming release (v1.4)
|
||||
stateManager.addStateUpdater(new DistanceUpdater(distanceStateId, stateManager, costMatrix));
|
||||
// stateManager.updateLoadStates();
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
constraintManager.addConstraint(new DistanceConstraint(120., distanceStateId, stateManager, costMatrix), ConstraintManager.Priority.CRITICAL);
|
||||
// constraintManager.addLoadConstraint();
|
||||
|
||||
// vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setStateAndConstraintManager(stateManager,constraintManager)
|
||||
.buildAlgorithm();
|
||||
// vra.setMaxIterations(250); //v1.3.1
|
||||
vra.setMaxIterations(250); //head of development - upcoming release (v1.4)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -50,7 +51,6 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
|||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.CrowFlyCosts;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -266,13 +266,9 @@ public class BicycleMessenger {
|
|||
constraintManager.addConstraint(new ThreeTimesLessThanBestDirectRouteConstraint(latest_act_arrival_time_stateId, nearestMessengers, routingCosts, stateManager), ConstraintManager.Priority.CRITICAL);
|
||||
constraintManager.addConstraint(new IgnoreMessengerThatCanNeverMeetTimeRequirements(nearestMessengers, routingCosts));
|
||||
|
||||
//create your algorithm
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(bicycleMessengerProblem, "input/algorithmConfig.xml");
|
||||
// vraBuilder.setNuOfThreads(2);
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
// vraBuilder.setNuOfThreads(10);
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(bicycleMessengerProblem)
|
||||
.setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
|
||||
algorithm.setMaxIterations(2000);
|
||||
|
||||
// VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(bicycleMessengerProblem)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -37,7 +38,6 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
@ -254,10 +254,6 @@ public class JobAndActivityDependenciesExample {
|
|||
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "input/algorithmConfig.xml");
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.addCoreConstraints();
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
StateId keyPicked = stateManager.createStateId("key-picked");
|
||||
StateId keyUsed = stateManager.createStateId("key-used");
|
||||
|
|
@ -268,8 +264,7 @@ public class JobAndActivityDependenciesExample {
|
|||
constraintManager.addConstraint(new GetUseAndDeliverKeySimpleHardActivityConstraint(stateManager, keyPicked, keyUsed, keyDelivered), ConstraintManager.Priority.CRITICAL);
|
||||
constraintManager.addConstraint(new GetUseAndDeliverHardRouteContraint(stateManager, keyPicked, keyUsed, keyDelivered));
|
||||
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -33,7 +34,6 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLWriter;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
|
|
@ -84,10 +84,10 @@ public class SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample {
|
|||
* 3: (16,8)
|
||||
* 4: (16,12)
|
||||
*/
|
||||
Delivery delivery1 = (Delivery) Delivery.Builder.newInstance("5").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 8))).build();
|
||||
Delivery delivery2 = (Delivery) Delivery.Builder.newInstance("6").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 12))).build();
|
||||
Delivery delivery3 = (Delivery) Delivery.Builder.newInstance("7").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 8))).build();
|
||||
Delivery delivery4 = (Delivery) Delivery.Builder.newInstance("8").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 12))).build();
|
||||
Delivery delivery1 = Delivery.Builder.newInstance("5").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 8))).build();
|
||||
Delivery delivery2 = Delivery.Builder.newInstance("6").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(4, 12))).build();
|
||||
Delivery delivery3 = Delivery.Builder.newInstance("7").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 8))).build();
|
||||
Delivery delivery4 = Delivery.Builder.newInstance("8").addSizeDimension(0, 1).setLocation(loc(Coordinate.newInstance(16, 12))).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
|
|
@ -99,14 +99,12 @@ public class SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample {
|
|||
/*
|
||||
* build the algorithm
|
||||
*/
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem, "input/algorithmConfig.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
StateManager stateManager = new StateManager(problem);
|
||||
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
|
||||
constraintManager.addConstraint(new ServiceDeliveriesFirstConstraint(), ConstraintManager.Priority.CRITICAL);
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(problem).setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
|
||||
/*
|
||||
* and search a solution
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -31,7 +32,6 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLWriter;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -94,20 +94,8 @@ public class SimpleExampleWithSkills {
|
|||
/*
|
||||
* get the algorithm out-of-the-box.
|
||||
*/
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem, "input/algorithmConfig.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
//activate skill state update and constraints - it is NOT default
|
||||
StateManager stateManager = new StateManager(problem);
|
||||
stateManager.updateSkillStates();
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
|
||||
constraintManager.addSkillsConstraint();
|
||||
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem);
|
||||
|
||||
/*
|
||||
* and search a solution
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter.Label;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -33,7 +34,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLWriter;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
|
|
@ -79,14 +80,13 @@ public class SimpleVRPWithBackhaulsExample {
|
|||
|
||||
VehicleRoutingProblem problem = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem, "input/algorithmConfig.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
StateManager stateManager = new StateManager(problem);
|
||||
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
|
||||
constraintManager.addConstraint(new ServiceDeliveriesFirstConstraint(), ConstraintManager.Priority.CRITICAL);
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(problem).setStateAndConstraintManager(stateManager,constraintManager)
|
||||
.buildAlgorithm();
|
||||
|
||||
/*
|
||||
* and search a solution
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -34,7 +32,6 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.instance.reader.SolomonReader;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLWriter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -86,17 +83,7 @@ public class SolomonWithSkillsExample {
|
|||
skillProblemBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
|
||||
VehicleRoutingProblem skillProblem = skillProblemBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(skillProblem, "input/algorithmConfig_solomon.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
StateManager stateManager = new StateManager(skillProblem);
|
||||
stateManager.updateSkillStates();
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(skillProblem, stateManager);
|
||||
constraintManager.addSkillsConstraint();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(skillProblem).setStateAndConstraintManager(stateManager, constraintManager).buildAlgorithm();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(skillProblem).buildAlgorithm();
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
|
|
@ -37,7 +38,6 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -168,21 +168,8 @@ public class TransportOfDisabledPeople {
|
|||
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
|
||||
constraintManager.addConstraint(wheelchair_bus_passenger_pickup_constraint);
|
||||
|
||||
/*
|
||||
* get a sample algorithm.
|
||||
*
|
||||
* Note that you need to make sure to prohibit vehicle-switching by adding the insertion-tag <vehicleSwitchAllowed>false</vehicleSwitchAllowed>.
|
||||
* This way you make sure that no vehicle can take over a route that is employed by another. Allowing this might make sense when dealing with
|
||||
* a heterogeneous fleet and you want to employ a bigger vehicle on a still existing route. However, allowing it makes constraint-checking
|
||||
* bit more complicated and you cannot just add the above hard-constraint. Latter will be covered in another example.
|
||||
*
|
||||
*/
|
||||
VehicleRoutingAlgorithmBuilder algorithmBuilder = new VehicleRoutingAlgorithmBuilder(problem, "input/algorithmConfig_noVehicleSwitch.xml");
|
||||
algorithmBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
algorithmBuilder.addCoreConstraints();
|
||||
algorithmBuilder.addDefaultCostCalculators();
|
||||
|
||||
VehicleRoutingAlgorithm algorithm = algorithmBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(problem).setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -26,7 +27,6 @@ import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
|||
import com.graphhopper.jsprit.core.problem.constraint.ServiceDeliveriesFirstConstraint;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
|
|
@ -67,14 +67,12 @@ public class VRPWithBackhaulsExample {
|
|||
*
|
||||
* The algorithm can be defined and configured in an xml-file.
|
||||
*/
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "input/algorithmConfig_solomon.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
|
||||
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();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||
/*
|
||||
* Solve the problem.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue