mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added egress/access calc
This commit is contained in:
parent
9a471a58be
commit
dc24411802
7 changed files with 135 additions and 34 deletions
|
|
@ -40,7 +40,6 @@ import jsprit.core.algorithm.state.StateManager;
|
|||
import jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.AdditionalTransportationCosts;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
|
@ -135,7 +134,7 @@ public class BuildAlgorithmFromScratchWithHardAndSoftConstraints {
|
|||
* add an arbitrary number of hardConstraints by
|
||||
* constraintManager.addConstraint(...)
|
||||
*/
|
||||
constraintManager.addConstraint(new AdditionalTransportationCosts(vrp.getTransportCosts()));
|
||||
|
||||
|
||||
/*
|
||||
* define a fleetManager, here infinite vehicles can be used
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class MultipleDepotExample {
|
|||
/*
|
||||
* solve the problem
|
||||
*/
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfigWithSchrimpfAcceptance.xml");
|
||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import jsprit.core.problem.VehicleRoutingProblem;
|
|||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.vehicle.PenaltyVehicleType;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
|
|
@ -85,30 +84,13 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
Vehicle vehicle = vehicleBuilder.build();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
}
|
||||
/*
|
||||
* define penalty-type with the same id, but other higher fixed and variable costs
|
||||
*/
|
||||
VehicleType penaltyType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType,3);
|
||||
String vehicleId = depotCounter + "_vehicle#penalty";
|
||||
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
||||
vehicleBuilder.setLocationCoord(depotCoord);
|
||||
/*
|
||||
* set PenaltyVehicleType
|
||||
*/
|
||||
vehicleBuilder.setType(penaltyVehicleType);
|
||||
vehicleBuilder.setLatestArrival(maxDuration);
|
||||
Vehicle penaltyVehicle = vehicleBuilder.build();
|
||||
vrpBuilder.addVehicle(penaltyVehicle);
|
||||
|
||||
depotCounter++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* define penalty-type with the same id, but other higher fixed and variable costs
|
||||
*/
|
||||
vrpBuilder.addPenaltyVehicles(3, 50);
|
||||
|
||||
/*
|
||||
* define problem with finite fleet
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue