mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added soft constraints
This commit is contained in:
parent
bb98df01f1
commit
86c168e428
13 changed files with 446 additions and 66 deletions
|
|
@ -32,6 +32,7 @@ import jsprit.core.algorithm.selector.SelectBest;
|
|||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.AdditionalTransportationCosts;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
|
|
@ -67,6 +68,7 @@ public class BuildCVRPAlgoFromScratch_IT {
|
|||
ConstraintManager cManager = new ConstraintManager(vrp, stateManager);
|
||||
cManager.addLoadConstraint();
|
||||
cManager.addTimeWindowConstraint();
|
||||
cManager.addConstraint(new AdditionalTransportationCosts(vrp.getTransportCosts()));
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
|
||||
|
|
@ -102,11 +104,7 @@ public class BuildCVRPAlgoFromScratch_IT {
|
|||
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
|
||||
vra.addListener(stateManager);
|
||||
vra.addListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
// vra.getAlgorithmListeners().addListener(stateManager);
|
||||
// vra.getSearchStrategyManager().addSearchStrategyModuleListener(stateManager);
|
||||
// vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
|
||||
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
|
||||
|
||||
vra.addInitialSolution(iniSolution);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
stateManager.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
JobCalculatorSwitcher switcher = new JobCalculatorSwitcher();
|
||||
ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager);
|
||||
ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, constraintManager);
|
||||
ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager);
|
||||
switcher.put(Pickup.class, serviceInsertionCalc);
|
||||
switcher.put(Delivery.class, serviceInsertionCalc);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
stateManager.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
JobCalculatorSwitcher switcher = new JobCalculatorSwitcher();
|
||||
ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager);
|
||||
ServiceInsertionCalculator serviceInsertionCalc = new ServiceInsertionCalculator(routingCosts, constraintManager);
|
||||
ShipmentInsertionCalculator insertionCalculator = new ShipmentInsertionCalculator(routingCosts, activityInsertionCostsCalculator, hardRouteLevelConstraint, constraintManager);
|
||||
switcher.put(Pickup.class, serviceInsertionCalc);
|
||||
switcher.put(Shipment.class, insertionCalculator);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.Collection;
|
|||
import jsprit.core.algorithm.ExampleActivityCostFunction;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.AdditionalTransportationCosts;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
|
|
@ -165,11 +166,9 @@ public class TestCalculatesServiceInsertion {
|
|||
ConstraintManager cManager = new ConstraintManager(vrp,states);
|
||||
cManager.addLoadConstraint();
|
||||
cManager.addTimeWindowConstraint();
|
||||
cManager.addConstraint(new AdditionalTransportationCosts(costs));
|
||||
|
||||
ExampleActivityCostFunction activityCosts = new ExampleActivityCostFunction();
|
||||
|
||||
|
||||
serviceInsertion = new ServiceInsertionCalculator(costs, new LocalActivityInsertionCostsCalculator(costs, activityCosts), cManager, cManager);
|
||||
serviceInsertion = new ServiceInsertionCalculator(costs, cManager);
|
||||
|
||||
|
||||
// stateUpdater = new UpdateStates(states, costs, activityCosts);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue