1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

extend interface TransportDistance - breaking change

This commit is contained in:
oblonski 2016-06-14 19:53:19 +02:00
parent 3d84c714d2
commit 151754c79c
17 changed files with 188 additions and 174 deletions

View file

@ -340,7 +340,7 @@ public class SolutionAnalyser {
}
private double distance(TourActivity activity) {
return distanceCalculator.getDistance(prevAct.getLocation(), activity.getLocation());
return distanceCalculator.getDistance(prevAct.getLocation(), activity.getLocation(),prevActDeparture, route.getVehicle());
}
@Override
@ -381,7 +381,7 @@ public class SolutionAnalyser {
@Override
public void visit(TourActivity activity) {
double distance = distanceCalculator.getDistance(prevAct.getLocation(), activity.getLocation());
double distance = distanceCalculator.getDistance(prevAct.getLocation(), activity.getLocation(), prevAct.getEndTime(), route.getVehicle());
sum_distance += distance;
stateManager.putActivityState(activity, distance_id, sum_distance);
prevAct = activity;
@ -389,7 +389,7 @@ public class SolutionAnalyser {
@Override
public void finish() {
double distance = distanceCalculator.getDistance(prevAct.getLocation(), route.getEnd().getLocation());
double distance = distanceCalculator.getDistance(prevAct.getLocation(), route.getEnd().getLocation(),prevAct.getEndTime(), route.getVehicle());
sum_distance += distance;
stateManager.putRouteState(route, distance_id, sum_distance);
}

View file

@ -1,12 +1,13 @@
package com.graphhopper.jsprit.core.problem.cost;
import com.graphhopper.jsprit.core.problem.Location;
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
/**
* Created by schroeder on 23/12/14.
*/
public interface TransportDistance {
public double getDistance(Location from, Location to);
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle);
}

View file

@ -94,7 +94,7 @@ public class CrowFlyCosts extends AbstractForwardVehicleRoutingTransportCosts im
}
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return calculateDistance(from, to);
}
}

View file

@ -84,7 +84,7 @@ public class EuclideanCosts extends AbstractForwardVehicleRoutingTransportCosts
}
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return calculateDistance(from, to);
}
}

View file

@ -155,7 +155,7 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
}
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return getDistance(from.getIndex(), to.getIndex());
}

View file

@ -95,7 +95,7 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost
}
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return calculateDistance(from, to);
}
}

View file

@ -83,7 +83,7 @@ public class ManhattanCosts extends AbstractForwardVehicleRoutingTransportCosts
}
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return calculateDistance(from, to);
}
}

View file

@ -86,7 +86,7 @@ public class CVRPwithMatrix_IT {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), new TransportDistance() {
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
}
});

View file

@ -27,6 +27,7 @@ import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
import com.graphhopper.jsprit.core.problem.job.Delivery;
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
@ -95,8 +96,8 @@ public class CapacityConstraint_IT {
SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE);
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, new TransportDistance() {
@Override
public double getDistance(Location from, Location to) {
return new ManhattanCosts().getDistance(from,to);
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return new ManhattanCosts().getDistance(from,to, 0d, null);
}
});

View file

@ -66,7 +66,7 @@ public class VariableDepartureAndWaitingTime_IT {
public double getCosts(VehicleRoutingProblemSolution solution) {
SolutionAnalyser sa = new SolutionAnalyser(vrp, solution, new TransportDistance() {
@Override
public double getDistance(Location from, Location to) {
public double getDistance(Location from, Location to, double departureTime, Vehicle vehicle) {
return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null);
}
});

View file

@ -101,6 +101,8 @@
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
<service>0.0</service>
<wait>0.0</wait>
</costs>
</type>
<type>
@ -112,6 +114,8 @@
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
<service>0.0</service>
<wait>0.0</wait>
</costs>
</type>
<type>
@ -133,6 +137,8 @@
<fixed>0.0</fixed>
<distance>0.0</distance>
<time>0.0</time>
<service>0.0</service>
<wait>0.0</wait>
</costs>
</type>
</vehicleTypes>

View file

@ -31,6 +31,8 @@
<fixed>0.0</fixed>
<distance>1.0</distance>
<time>0.0</time>
<service>0.0</service>
<wait>0.0</wait>
</costs>
</type>
</vehicleTypes>