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

Add service&wait costs + Replace TimeUnitCost

This commit is contained in:
braktar 2016-05-24 17:31:56 +02:00
parent 5dbb5ddae0
commit bc7fa35461
5 changed files with 14 additions and 4 deletions

View file

@ -583,10 +583,14 @@ public class VrpXMLReader {
Double fix = typeConfig.getDouble("costs.fixed"); Double fix = typeConfig.getDouble("costs.fixed");
Double timeC = typeConfig.getDouble("costs.time"); Double timeC = typeConfig.getDouble("costs.time");
Double distC = typeConfig.getDouble("costs.distance"); Double distC = typeConfig.getDouble("costs.distance");
Double serviceC = typeConfig.getDouble("costs.service");
Double waitC = typeConfig.getDouble("costs.wait");
if (fix != null) typeBuilder.setFixedCost(fix); if (fix != null) typeBuilder.setFixedCost(fix);
if (timeC != null) typeBuilder.setCostPerTime(timeC); if (timeC != null) typeBuilder.setCostPerTransportTime(timeC);
if (distC != null) typeBuilder.setCostPerDistance(distC); if (distC != null) typeBuilder.setCostPerDistance(distC);
if (serviceC != null) typeBuilder.setCostPerServiceTime(serviceC);
if (waitC != null) typeBuilder.setCostPerWaitingTime(waitC);
VehicleType type = typeBuilder.build(); VehicleType type = typeBuilder.build();
String id = type.getTypeId(); String id = type.getTypeId();
types.put(id, type); types.put(id, type);

View file

@ -383,7 +383,9 @@ public class VrpXMLWriter {
xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.fixed", type.getVehicleCostParams().fix); xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.fixed", type.getVehicleCostParams().fix);
xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.distance", type.getVehicleCostParams().perDistanceUnit); xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.distance", type.getVehicleCostParams().perDistanceUnit);
xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.time", type.getVehicleCostParams().perTimeUnit); xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.time", type.getVehicleCostParams().perTransportTimeUnit);
xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.service", type.getVehicleCostParams().perServiceTimeUnit);
xmlConfig.setProperty(typePathString + "(" + typeCounter + ").costs.wait", type.getVehicleCostParams().perWaitingTimeUnit);
typeCounter++; typeCounter++;
} }

View file

@ -165,7 +165,7 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 "); throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 ");
if (vehicle == null) return getDistance(from.getIndex(), to.getIndex()); if (vehicle == null) return getDistance(from.getIndex(), to.getIndex());
VehicleTypeImpl.VehicleCostParams costParams = vehicle.getType().getVehicleCostParams(); VehicleTypeImpl.VehicleCostParams costParams = vehicle.getType().getVehicleCostParams();
return costParams.perDistanceUnit * getDistance(from.getIndex(), to.getIndex()) + costParams.perTimeUnit * getTransportTime(from, to, departureTime, driver, vehicle); return costParams.perDistanceUnit * getDistance(from.getIndex(), to.getIndex()) + costParams.perTransportTimeUnit * getTransportTime(from, to, departureTime, driver, vehicle);
} }
} }

View file

@ -257,7 +257,7 @@ public class VehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRo
public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
if (vehicle == null) return getDistance(from.getId(), to.getId()); if (vehicle == null) return getDistance(from.getId(), to.getId());
VehicleCostParams costParams = vehicle.getType().getVehicleCostParams(); VehicleCostParams costParams = vehicle.getType().getVehicleCostParams();
return costParams.perDistanceUnit * getDistance(from.getId(), to.getId()) + costParams.perTimeUnit * getTime(from.getId(), to.getId()); return costParams.perDistanceUnit * getDistance(from.getId(), to.getId()) + costParams.perTransportTimeUnit * getTime(from.getId(), to.getId());
} }
} }

View file

@ -106,6 +106,10 @@
maxOccurs="1" default="0.0"/> maxOccurs="1" default="0.0"/>
<xs:element name="time" type="xs:decimal" minOccurs="0" <xs:element name="time" type="xs:decimal" minOccurs="0"
maxOccurs="1" default="0.0"/> maxOccurs="1" default="0.0"/>
<xs:element name="service" type="xs:decimal" minOccurs="0"
maxOccurs="1" default="0.0"/>
<xs:element name="wait" type="xs:decimal" minOccurs="0"
maxOccurs="1" default="0.0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>