mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
work at io
This commit is contained in:
parent
36e67f6ae6
commit
d06f6ddc4b
1 changed files with 18 additions and 53 deletions
|
|
@ -111,45 +111,7 @@ public class VrpXMLReader{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readConfig(XMLConfiguration config) {
|
public void readConfig(XMLConfiguration config) {
|
||||||
List<HierarchicalConfiguration> shipmentConfigs = config.configurationsAt("shipments.shipment");
|
|
||||||
for(HierarchicalConfiguration shipmentConfig : shipmentConfigs){
|
|
||||||
String id = shipmentConfig.getString("[@id]");
|
|
||||||
if(id == null) throw new IllegalStateException("shipment[@id] is missing.");
|
|
||||||
int cap = getCap(shipmentConfig);
|
|
||||||
Shipment.Builder builder = Shipment.Builder.newInstance(id, cap);
|
|
||||||
|
|
||||||
String pickupLocationId = shipmentConfig.getString("pickup.locationId");
|
|
||||||
builder.setPickupLocation(pickupLocationId);
|
|
||||||
|
|
||||||
Coordinate pickupCoord = getCoord(shipmentConfig,"pickup.");
|
|
||||||
builder.setPickupCoord(pickupCoord);
|
|
||||||
|
|
||||||
if(pickupCoord != null){
|
|
||||||
if(pickupLocationId != null){
|
|
||||||
vrpBuilder.addLocation(pickupLocationId,pickupCoord);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
vrpBuilder.addLocation(pickupCoord.toString(),pickupCoord);
|
|
||||||
builder.setPickupLocation(pickupCoord.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String deliveryLocationId = shipmentConfig.getString("delivery.locationId");
|
|
||||||
builder.setDeliveryLocation(deliveryLocationId);
|
|
||||||
|
|
||||||
Coordinate deliveryCoord = getCoord(shipmentConfig,"delivery.");
|
|
||||||
builder.setDeliveryCoord(deliveryCoord);
|
|
||||||
|
|
||||||
if(deliveryCoord != null){
|
|
||||||
if(deliveryLocationId != null){
|
|
||||||
vrpBuilder.addLocation(deliveryLocationId,deliveryCoord);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
vrpBuilder.addLocation(deliveryCoord.toString(),deliveryCoord);
|
|
||||||
builder.setPickupLocation(deliveryCoord.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -243,10 +205,7 @@ public class VrpXMLReader{
|
||||||
readProblemType(xmlConfig);
|
readProblemType(xmlConfig);
|
||||||
readVehiclesAndTheirTypes(xmlConfig);
|
readVehiclesAndTheirTypes(xmlConfig);
|
||||||
|
|
||||||
// for(JobConfigReader jobConfigReader : jobConfigReaders){
|
readShipments(xmlConfig);
|
||||||
// jobConfigReader.readConfig(xmlConfig);
|
|
||||||
// }
|
|
||||||
|
|
||||||
readServices(xmlConfig);
|
readServices(xmlConfig);
|
||||||
readSolutions(xmlConfig);
|
readSolutions(xmlConfig);
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +242,7 @@ public class VrpXMLReader{
|
||||||
String type = actConfig.getString("[@type]");
|
String type = actConfig.getString("[@type]");
|
||||||
if(type == null) throw new IllegalStateException("act[@type] is missing.");
|
if(type == null) throw new IllegalStateException("act[@type] is missing.");
|
||||||
String serviceId = actConfig.getString("serviceId");
|
String serviceId = actConfig.getString("serviceId");
|
||||||
if(serviceId == null) throw new IllegalStateException("act.serviceId is missing.");
|
if(serviceId != null) {
|
||||||
Service service = getService(serviceId);
|
Service service = getService(serviceId);
|
||||||
String arrTime = actConfig.getString("arrTime");
|
String arrTime = actConfig.getString("arrTime");
|
||||||
if(arrTime == null) throw new IllegalStateException("act.arrTime is missing.");
|
if(arrTime == null) throw new IllegalStateException("act.arrTime is missing.");
|
||||||
|
|
@ -294,6 +253,12 @@ public class VrpXMLReader{
|
||||||
tourActivity.setEndTime(Double.parseDouble(endTime));
|
tourActivity.setEndTime(Double.parseDouble(endTime));
|
||||||
routeBuilder.addActivity(tourActivity);
|
routeBuilder.addActivity(tourActivity);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
String shipmentId = actConfig.getString("shipmentId");
|
||||||
|
if(shipmentId == null) throw new IllegalStateException("either serviceId or shipmentId is missing");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
routes.add(routeBuilder.build());
|
routes.add(routeBuilder.build());
|
||||||
}
|
}
|
||||||
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost);
|
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue