mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
make VehicleRoutingTransportCosts implement TransportDistance
This commit is contained in:
parent
d95b1d2f14
commit
75e9b6f9dd
23 changed files with 222 additions and 1061 deletions
|
|
@ -34,16 +34,13 @@ import com.graphhopper.jsprit.core.algorithm.ruin.distance.AvgServiceAndShipment
|
|||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
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.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.FiniteFleetManagerFactory;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
|
|
@ -207,12 +204,7 @@ public class BuildAlgorithmFromScratch {
|
|||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
return analyser.getVariableTransportCosts() + solution.getUnassignedJobs().size() * 500.;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,8 @@ import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
|||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl.Builder;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
||||
|
|
@ -136,12 +134,7 @@ public class MultipleTimeWindowExample2 {
|
|||
*/
|
||||
new Plotter(problem,bestSolution).setLabel(Plotter.Label.ID).plot("output/plot", "mtw");
|
||||
|
||||
SolutionAnalyser a = new SolutionAnalyser(problem, bestSolution, new TransportDistance() {
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return problem.getTransportCosts().getTransportTime(from,to,0.,null,null);
|
||||
}
|
||||
});
|
||||
SolutionAnalyser a = new SolutionAnalyser(problem, bestSolution, problem.getTransportCosts());
|
||||
|
||||
System.out.println("distance: " + a.getDistance());
|
||||
System.out.println("ttime: " + a.getTransportTime());
|
||||
|
|
|
|||
|
|
@ -24,11 +24,8 @@ 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.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
|
@ -100,14 +97,7 @@ public class PickupAndDeliveryExample {
|
|||
plotter.plot("output/pd_solomon_r101_solution.png", "pd_r101");
|
||||
|
||||
//some stats
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
|
||||
System.out.println("tp_distance: " + analyser.getDistance());
|
||||
System.out.println("tp_time: " + analyser.getTransportTime());
|
||||
|
|
|
|||
|
|
@ -25,15 +25,12 @@ import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
|||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Capacity;
|
||||
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.constraint.ServiceDeliveriesFirstConstraint;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.problem.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
|
@ -125,14 +122,7 @@ public class VRPWithBackhaulsExample2 {
|
|||
// plotter.setLabel(Plotter.Label.SIZE);
|
||||
plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png", "vrpwbh_vrpnc1");
|
||||
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() {
|
||||
|
||||
@Override
|
||||
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
|
||||
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
|
||||
}
|
||||
|
||||
});
|
||||
SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, vrp.getTransportCosts());
|
||||
|
||||
for (VehicleRoute route : solution.getRoutes()) {
|
||||
System.out.println("------");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue