diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVehicleDependentPracticalTimeWindows.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVehicleDependentPracticalTimeWindows.java index aa9f6f71..fab7dc9f 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVehicleDependentPracticalTimeWindows.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVehicleDependentPracticalTimeWindows.java @@ -21,7 +21,6 @@ import jsprit.core.problem.Location; import jsprit.core.problem.cost.VehicleRoutingTransportCosts; import jsprit.core.problem.solution.route.RouteVisitor; import jsprit.core.problem.solution.route.VehicleRoute; -import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.problem.solution.route.activity.TourActivity; import jsprit.core.problem.vehicle.Vehicle; diff --git a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java index 403ef815..aad52d1f 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/io/VrpXMLReader.java @@ -134,174 +134,6 @@ public class VrpXMLReader { this.solutions = null; } - public void read(String filename) { - logger.debug("read vrp: {}", filename); - XMLConfiguration xmlConfig = new XMLConfiguration(); - xmlConfig.setFileName(filename); - xmlConfig.setAttributeSplittingDisabled(true); - xmlConfig.setDelimiterParsingDisabled(true); - - if (schemaValidation) { - final InputStream resource = Resource.getAsInputStream("vrp_xml_schema.xsd"); - if (resource != null) { - EntityResolver resolver = new EntityResolver() { - - @Override - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - { - InputSource is = new InputSource(resource); - return is; - } - } - }; - xmlConfig.setEntityResolver(resolver); - xmlConfig.setSchemaValidation(true); - } else { - logger.debug("cannot find schema-xsd file (vrp_xml_schema.xsd). try to read xml without xml-file-validation."); - } - } - try { - xmlConfig.load(); - } catch (ConfigurationException e) { - throw new RuntimeException(e); - } - readProblemType(xmlConfig); - readVehiclesAndTheirTypes(xmlConfig); - - readShipments(xmlConfig); - readServices(xmlConfig); - - readInitialRoutes(xmlConfig); - readSolutions(xmlConfig); - - addJobsAndTheirLocationsToVrp(); - } - - private void addJobsAndTheirLocationsToVrp() { - for (Service service : serviceMap.values()) { - if (!freezedJobIds.contains(service.getId())) { - vrpBuilder.addJob(service); - } - } - for (Shipment shipment : shipmentMap.values()) { - if (!freezedJobIds.contains(shipment.getId())) { - vrpBuilder.addJob(shipment); - } - } - } - - private void readInitialRoutes(XMLConfiguration xmlConfig) { - List initialRouteConfigs = xmlConfig.configurationsAt("initialRoutes.route"); - for (HierarchicalConfiguration routeConfig : initialRouteConfigs) { - Driver driver = DriverImpl.noDriver(); - String vehicleId = routeConfig.getString("vehicleId"); - Vehicle vehicle = getVehicle(vehicleId); - if (vehicle == null) throw new IllegalStateException("vehicle is missing."); - String start = routeConfig.getString("start"); - if (start == null) throw new IllegalStateException("route start-time is missing."); - double departureTime = Double.parseDouble(start); - - VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); - routeBuilder.setDepartureTime(departureTime); - - List actConfigs = routeConfig.configurationsAt("act"); - for (HierarchicalConfiguration actConfig : actConfigs) { - String type = actConfig.getString("[@type]"); - if (type == null) throw new IllegalStateException("act[@type] is missing."); - double arrTime = 0.; - double endTime = 0.; - String arrTimeS = actConfig.getString("arrTime"); - if (arrTimeS != null) arrTime = Double.parseDouble(arrTimeS); - String endTimeS = actConfig.getString("endTime"); - if (endTimeS != null) endTime = Double.parseDouble(endTimeS); - - String serviceId = actConfig.getString("serviceId"); - if (serviceId != null) { - Service service = getService(serviceId); - if (service == null) - throw new IllegalStateException("service to serviceId " + serviceId + " is missing (reference in one of your initial routes). make sure you define the service you refer to here in ."); - //!!!since job is part of initial route, it does not belong to jobs in problem, i.e. variable jobs that can be assigned/scheduled - freezedJobIds.add(serviceId); - routeBuilder.addService(service); - } else { - String shipmentId = actConfig.getString("shipmentId"); - if (shipmentId == null) - throw new IllegalStateException("either serviceId or shipmentId is missing"); - Shipment shipment = getShipment(shipmentId); - if (shipment == null) - throw new IllegalStateException("shipment to shipmentId " + shipmentId + " is missing (reference in one of your initial routes). make sure you define the shipment you refer to here in ."); - freezedJobIds.add(shipmentId); - if (type.equals("pickupShipment")) { - routeBuilder.addPickup(shipment); - } else if (type.equals("deliverShipment")) { - routeBuilder.addDelivery(shipment); - } else - throw new IllegalStateException("type " + type + " is not supported. Use 'pickupShipment' or 'deliverShipment' here"); - } - } - VehicleRoute route = routeBuilder.build(); - vrpBuilder.addInitialVehicleRoute(route); - } - - } - - private void readSolutions(XMLConfiguration vrpProblem) { - if (solutions == null) return; - List solutionConfigs = vrpProblem.configurationsAt("solutions.solution"); - for (HierarchicalConfiguration solutionConfig : solutionConfigs) { - String totalCost = solutionConfig.getString("cost"); - double cost = -1; - if (totalCost != null) cost = Double.parseDouble(totalCost); - List routeConfigs = solutionConfig.configurationsAt("routes.route"); - List routes = new ArrayList(); - for (HierarchicalConfiguration routeConfig : routeConfigs) { - //! here, driverId is set to noDriver, no matter whats in driverId. - Driver driver = DriverImpl.noDriver(); - String vehicleId = routeConfig.getString("vehicleId"); - Vehicle vehicle = getVehicle(vehicleId); - if (vehicle == null) throw new IllegalStateException("vehicle is missing."); - String start = routeConfig.getString("start"); - if (start == null) throw new IllegalStateException("route start-time is missing."); - double departureTime = Double.parseDouble(start); - - String end = routeConfig.getString("end"); - if (end == null) throw new IllegalStateException("route end-time is missing."); - - VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); - routeBuilder.setDepartureTime(departureTime); - routeBuilder.setRouteEndArrivalTime(Double.parseDouble(end)); - List actConfigs = routeConfig.configurationsAt("act"); - for (HierarchicalConfiguration actConfig : actConfigs) { - String type = actConfig.getString("[@type]"); - if (type == null) throw new IllegalStateException("act[@type] is missing."); - double arrTime = 0.; - double endTime = 0.; - String arrTimeS = actConfig.getString("arrTime"); - if (arrTimeS != null) arrTime = Double.parseDouble(arrTimeS); - String endTimeS = actConfig.getString("endTime"); - if (endTimeS != null) endTime = Double.parseDouble(endTimeS); - - String serviceId = actConfig.getString("serviceId"); - if (serviceId != null) { - Service service = getService(serviceId); - routeBuilder.addService(service); - } else { - String shipmentId = actConfig.getString("shipmentId"); - if (shipmentId == null) - throw new IllegalStateException("either serviceId or shipmentId is missing"); - Shipment shipment = getShipment(shipmentId); - if (shipment == null) - throw new IllegalStateException("shipment with id " + shipmentId + " does not exist."); - if (type.equals("pickupShipment")) { - routeBuilder.addPickup(shipment); - } else if (type.equals("deliverShipment")) { - routeBuilder.addDelivery(shipment); - } else - throw new IllegalStateException("type " + type + " is not supported. Use 'pickupShipment' or 'deliverShipment' here"); - } - } - routes.add(routeBuilder.build()); - } public void read(String filename) { logger.debug("read vrp: {}", filename); XMLConfiguration xmlConfig = createXMLConfiguration(); diff --git a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java index 9c203736..eb0ad2b7 100644 --- a/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java +++ b/jsprit-core/src/main/java/jsprit/core/problem/solution/route/activity/ServiceActivity.java @@ -22,9 +22,6 @@ import jsprit.core.problem.Location; import jsprit.core.problem.job.Service; import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity; -import java.util.ArrayList; -import java.util.List; - public class ServiceActivity extends AbstractActivity implements JobActivity { @Deprecated diff --git a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java index abf0e942..d06fc3c2 100644 --- a/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java +++ b/jsprit-core/src/test/java/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java @@ -21,7 +21,6 @@ import jsprit.core.problem.Location; import jsprit.core.problem.driver.Driver; import jsprit.core.problem.job.Shipment; import jsprit.core.problem.solution.route.activity.TimeWindow; -import jsprit.core.problem.solution.route.activity.TimeWindow; import jsprit.core.problem.vehicle.Vehicle; import jsprit.core.problem.vehicle.VehicleImpl; import org.junit.Test;