1
0
Fork 0
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:
oblonski 2013-10-29 09:30:02 +01:00
parent 36e67f6ae6
commit d06f6ddc4b

View file

@ -111,45 +111,7 @@ public class VrpXMLReader{
@Override
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);
readVehiclesAndTheirTypes(xmlConfig);
// for(JobConfigReader jobConfigReader : jobConfigReaders){
// jobConfigReader.readConfig(xmlConfig);
// }
readShipments(xmlConfig);
readServices(xmlConfig);
readSolutions(xmlConfig);
}
@ -283,7 +242,7 @@ public class VrpXMLReader{
String type = actConfig.getString("[@type]");
if(type == null) throw new IllegalStateException("act[@type] is missing.");
String serviceId = actConfig.getString("serviceId");
if(serviceId == null) throw new IllegalStateException("act.serviceId is missing.");
if(serviceId != null) {
Service service = getService(serviceId);
String arrTime = actConfig.getString("arrTime");
if(arrTime == null) throw new IllegalStateException("act.arrTime is missing.");
@ -294,6 +253,12 @@ public class VrpXMLReader{
tourActivity.setEndTime(Double.parseDouble(endTime));
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());
}
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, cost);