@Override public Location getLocation() { return service.getLocation(); }
private void renderService(Graph g, Service service, Label label) { Node n = g.addNode(makeId(service.getId(), service.getLocation().getId())); if (label.equals(Label.ID)) n.addAttribute("ui.label", service.getId()); n.addAttribute("x", service.getLocation().getCoordinate().getX()); n.addAttribute("y", service.getLocation().getCoordinate().getY()); if (service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup"); if (service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery"); }
@Override public double getOperationTime() { return pickup.getServiceDuration(); }
private double scoreService(InsertionData best, Job job) { Location location = ((Service) job).getLocation(); double maxDepotDistance = 0; if (location != null) { maxDepotDistance = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), location), getDistance(best.getSelectedVehicle().getEndLocation(), location) ); } return Math.max(timeWindowParam * (((Service) job).getTimeWindow().getEnd() - ((Service) job).getTimeWindow().getStart()), minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
Service service = (Service) job; Service.Builder skillServiceBuilder; if (service.getLocation().getCoordinate().getY() < 50.) { skillServiceBuilder = Service.Builder.newInstance(service.getId() + "_skill2").setServiceTime(service.getServiceDuration()) .setLocation(Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build()).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0)); skillServiceBuilder.addRequiredSkill("skill2"); } else { skillServiceBuilder = Service.Builder.newInstance(service.getId() + "_skill1").setServiceTime(service.getServiceDuration()) .setLocation( Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build() ).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0)); skillServiceBuilder.addRequiredSkill("skill1");
if (!(j instanceof Service)) continue; Service service = (Service) j; xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@id]", service.getId()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@type]", service.getType()); if (service.getLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.id", service.getLocation().getId()); if (service.getLocation().getCoordinate() != null) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@x]", service.getLocation().getCoordinate().getX()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@y]", service.getLocation().getCoordinate().getY()); if (service.getLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.index", service.getLocation().getIndex()); for (int i = 0; i < service.getSize().getNuOfDimensions(); i++) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").capacity-dimensions.dimension(" + i + ")[@index]", i); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").capacity-dimensions.dimension(" + i + ")", service.getSize().get(i)); Collection<TimeWindow> tws = service.getTimeWindows(); int index = 0; xmlConfig.setProperty(shipmentPathString + "(" + counter + ").duration", service.getServiceDuration()); for(TimeWindow tw : tws) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").timeWindows.timeWindow(" + index + ").start", tw.getStart()); if (service.getName() != null) { if (!service.getName().equals("no-name")) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").name", service.getName());
private void addJob(Job job) { if (job instanceof Service) { Service service = (Service) job; addNode(service.getId(), service.getLocation().getCoordinate()); markService(service); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; String fromNodeId = getFromNodeId(shipment); addNode(fromNodeId, shipment.getPickupLocation().getCoordinate()); String toNodeId = getToNodeId(shipment); addNode(toNodeId, shipment.getDeliveryLocation().getCoordinate()); markShipment(shipment); if (renderShipments) { Edge e = graph.addEdge("shipment_" + fromNodeId + "_" + toNodeId, fromNodeId, toNodeId, true); e.addAttribute("ui.class", "shipment"); } } }
private Builder addService(Service service) { // tentative_coordinates.put(service.getLocation().getId(), service.getLocation().getCoordinate()); addLocationToTentativeLocations(service); if (jobs.containsKey(service.getId())) { logger.warn("The service " + service + " has already been added to job list. This overrides existing job."); } jobs.put(service.getId(), service); return this; }
@Override public Capacity getSize() { return pickup.getSize(); }
/** * Adds a service to this route. Activity is initialized with .getTimeWindow(). If you want to explicitly set another time window * use .addService(Service service, TimeWindow timeWindow) * <p> * <p>This implies that for this service a serviceActivity is created with {@link TourActivityFactory} and added to the sequence of tourActivities. * <p> * <p>The resulting activity occurs in the activity-sequence in the order adding/inserting. * * @param service to be added * @return this builder * @throws IllegalArgumentException if service is null */ public Builder addService(Service service) { return addService(service,service.getTimeWindow()); }
@Override public String getName() { return service.getType(); }
for(TimeWindow timeWindow : service.getTimeWindows()) { deliveryAct2Insert.setTheoreticalEarliestOperationStartTime(timeWindow.getStart()); deliveryAct2Insert.setTheoreticalLatestOperationStartTime(timeWindow.getEnd());
static CarrierService createCarrierService(Service service) { CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create(service.getId(), CarrierService.class), Id.create(service.getLocation().getId(), Link.class)); serviceBuilder.setCapacityDemand(service.getSize().get(0)); serviceBuilder.setServiceDuration(service.getServiceDuration()); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(service.getTimeWindow().getStart(), service.getTimeWindow().getEnd())); return serviceBuilder.build(); }
if (!(j instanceof Service)) continue; Service service = (Service) j; xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@id]", service.getId()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ")[@type]", service.getType()); if (service.getLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.id", service.getLocation().getId()); if (service.getLocation().getCoordinate() != null) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@x]", service.getLocation().getCoordinate().getX()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.coord[@y]", service.getLocation().getCoordinate().getY()); if (service.getLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").location.index", service.getLocation().getIndex()); for (int i = 0; i < service.getSize().getNuOfDimensions(); i++) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").capacity-dimensions.dimension(" + i + ")[@index]", i); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").capacity-dimensions.dimension(" + i + ")", service.getSize().get(i)); Collection<TimeWindow> tws = service.getTimeWindows(); int index = 0; xmlConfig.setProperty(shipmentPathString + "(" + counter + ").duration", service.getServiceDuration()); for(TimeWindow tw : tws) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").timeWindows.timeWindow(" + index + ").start", tw.getStart()); if (service.getName() != null) { if (!service.getName().equals("no-name")) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").name", service.getName());
private void addJob(Job job) { if (job instanceof Service) { Service service = (Service) job; addNode(service.getId(), service.getLocation().getCoordinate()); markService(service); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; String fromNodeId = getFromNodeId(shipment); addNode(fromNodeId, shipment.getPickupLocation().getCoordinate()); String toNodeId = getToNodeId(shipment); addNode(toNodeId, shipment.getDeliveryLocation().getCoordinate()); markShipment(shipment); if (renderShipments) { Edge e = graph.addEdge("shipment_" + fromNodeId + "_" + toNodeId, fromNodeId, toNodeId, true); e.addAttribute("ui.class", "shipment"); } } }
private double scoreService(InsertionData best, Job job) { Location location = ((Service) job).getLocation(); double maxDepotDistance = 0; if (location != null) { maxDepotDistance = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), location), getDistance(best.getSelectedVehicle().getEndLocation(), location) ); } return Math.max(timeWindowParam * (((Service) job).getTimeWindow().getEnd() - ((Service) job).getTimeWindow().getStart()), minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
@Override public Capacity getSize() { return service.getSize(); }
public static void main(String[] args) { VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance(); new LopezIbanezBlumReader(builder).read("input/Dumas/n20w20.001.txt"); VehicleRoutingProblem vrp = builder.build(); System.out.println("0->1: " + vrp.getTransportCosts().getTransportCost(Location.newInstance(0), Location.newInstance(1), 0, null, null)); System.out.println("0->20: " + vrp.getTransportCosts().getTransportCost(Location.newInstance(0), Location.newInstance(20), 0, null, null)); System.out.println("4->18: " + vrp.getTransportCosts().getTransportCost(Location.newInstance(4), Location.newInstance(18), 0, null, null)); System.out.println("20->8: " + vrp.getTransportCosts().getTransportCost(Location.newInstance(20), Location.newInstance(8), 0, null, null)); System.out.println("18: " + ((Service) vrp.getJobs().get("" + 18)).getTimeWindow().getStart() + " " + ((Service) vrp.getJobs().get("" + 18)).getTimeWindow().getEnd()); System.out.println("20: " + ((Service) vrp.getJobs().get("" + 20)).getTimeWindow().getStart() + " " + ((Service) vrp.getJobs().get("" + 20)).getTimeWindow().getEnd()); System.out.println("1: " + ((Service) vrp.getJobs().get("" + 1)).getTimeWindow().getStart() + " " + ((Service) vrp.getJobs().get("" + 1)).getTimeWindow().getEnd()); }
@Override public String getName() { return pickup.getType(); }