mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add and test FastTransportCostMatrix based array
This commit is contained in:
parent
0a196f0abd
commit
56f170e593
6 changed files with 231 additions and 21 deletions
|
|
@ -114,4 +114,9 @@ public final class Location implements HasIndex, HasId{
|
|||
result = 31 * result + (id != null ? id.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id="+id+"][index="+index+"][coordinate="+coordinate+"]";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ public class VehicleRoute {
|
|||
}
|
||||
if(!vehicle.isReturnToDepot()){
|
||||
if(!tourActivities.isEmpty()){
|
||||
end.setLocationId(tourActivities.getActivities().get(tourActivities.getActivities().size()-1).getLocationId());
|
||||
end.setLocation(tourActivities.getActivities().get(tourActivities.getActivities().size() - 1).getLocation());
|
||||
}
|
||||
}
|
||||
return new VehicleRoute(this);
|
||||
|
|
@ -407,8 +407,8 @@ public class VehicleRoute {
|
|||
start.setEndTime(Math.max(vehicleDepTime, vehicle.getEarliestDeparture()));
|
||||
start.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
|
||||
start.setTheoreticalLatestOperationStartTime(vehicle.getLatestArrival());
|
||||
start.setLocationId(vehicle.getStartLocationId());
|
||||
end.setLocationId(vehicle.getEndLocationId());
|
||||
start.setLocation(vehicle.getStartLocation());
|
||||
end.setLocation(vehicle.getEndLocation());
|
||||
end.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
|
||||
end.setTheoreticalLatestOperationStartTime(vehicle.getLatestArrival());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
|||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
if(from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 ");
|
||||
return get(from.getIndex(),to.getIndex(),1);
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +143,8 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
|||
|
||||
@Override
|
||||
public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
if(vehicle == null) return getDistance(from.getIndex(), to.getIndex());
|
||||
if(from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 ");
|
||||
if(vehicle == null) return getDistance(from.getIndex(), to.getIndex());
|
||||
VehicleCostParams costParams = vehicle.getType().getVehicleCostParams();
|
||||
return costParams.perDistanceUnit * getDistance(from.getIndex(), to.getIndex()) + costParams.perTimeUnit * getTransportTime(from, to, departureTime, driver, vehicle);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue