From e4858098cfca0625d359071410732249d49faef9 Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 27 Jul 2016 20:59:05 +0200 Subject: [PATCH] fixed compile error --- jsprit-examples/pom.xml | 1 + .../AdditionalDistanceConstraintExample.java | 14 +++----------- .../jsprit/examples/BicycleMessenger.java | 12 ++++-------- .../JobAndActivityDependenciesExample.java | 9 ++------- ...iveryWithDepotBoundedDeliveriesExample.java | 18 ++++++++---------- .../examples/SimpleExampleWithSkills.java | 16 ++-------------- .../SimpleVRPWithBackhaulsExample.java | 12 ++++++------ .../examples/SolomonWithSkillsExample.java | 15 +-------------- .../examples/TransportOfDisabledPeople.java | 17 ++--------------- .../examples/VRPWithBackhaulsExample.java | 10 ++++------ pom.xml | 6 +++--- 11 files changed, 36 insertions(+), 94 deletions(-) diff --git a/jsprit-examples/pom.xml b/jsprit-examples/pom.xml index e4df05cc..f41734a2 100644 --- a/jsprit-examples/pom.xml +++ b/jsprit-examples/pom.xml @@ -21,6 +21,7 @@ jsprit-core ${project.version} + ${project.groupId} jsprit-analysis diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/AdditionalDistanceConstraintExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/AdditionalDistanceConstraintExample.java index a423d737..9f5958ab 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/AdditionalDistanceConstraintExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/AdditionalDistanceConstraintExample.java @@ -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) diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BicycleMessenger.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BicycleMessenger.java index 89a9cdc3..1dbaa888 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BicycleMessenger.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BicycleMessenger.java @@ -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) diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/JobAndActivityDependenciesExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/JobAndActivityDependenciesExample.java index b99e7e1a..e51c69c6 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/JobAndActivityDependenciesExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/JobAndActivityDependenciesExample.java @@ -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 solutions = vra.searchSolutions(); diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample.java index 1d1506df..8493c21e 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleEnRoutePickupAndDeliveryWithDepotBoundedDeliveriesExample.java @@ -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 diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleExampleWithSkills.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleExampleWithSkills.java index ecc4b679..865d90ca 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleExampleWithSkills.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleExampleWithSkills.java @@ -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 diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleVRPWithBackhaulsExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleVRPWithBackhaulsExample.java index 73b05e67..de809361 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleVRPWithBackhaulsExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SimpleVRPWithBackhaulsExample.java @@ -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 diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SolomonWithSkillsExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SolomonWithSkillsExample.java index 98f08290..4256c5c0 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SolomonWithSkillsExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/SolomonWithSkillsExample.java @@ -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 solutions = vra.searchSolutions(); VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions); diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/TransportOfDisabledPeople.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/TransportOfDisabledPeople.java index b812ba9e..70ca4105 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/TransportOfDisabledPeople.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/TransportOfDisabledPeople.java @@ -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 false. - * 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)); /* diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample.java index fcf3eadd..cdaf909c 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample.java @@ -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. diff --git a/pom.xml b/pom.xml index 084d6c26..9d17708b 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ - 3.0.4 + 3.3.0 @@ -75,9 +75,9 @@ jsprit-core jsprit-analysis + jsprit-io jsprit-examples jsprit-instances - jsprit-io @@ -88,7 +88,7 @@ 1.3 1.7.21 false - 3.0.4 + 3.3.0