/** * 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()); }
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()); }
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; }
/** * 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()); }
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; }
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"); Location.Builder.newInstance().setId(service.getLocation().getId()) .setCoordinate(service.getLocation().getCoordinate()).build() ).setTimeWindow(service.getTimeWindow()) .addSizeDimension(0, service.getSize().get(0)); skillServiceBuilder.addRequiredSkill("skill1");
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(); }
/** * Creates (MATSim) CarrierShipment from a (jsprit) service * * @param service to be transformed to Shipment * @param depotLink as from-link for Shipment * @return CarrierShipment * @see CarrierShipment, Service */ static CarrierShipment createCarrierShipmentFromService(Service service, String depotLink){ return CarrierShipment.Builder.newInstance(Id.create(service.getId(), CarrierShipment.class), Id.create(depotLink, Link.class), Id.create(service.getLocation().getId(), Link.class), service.getSize().get(0)). setDeliveryServiceTime(service.getServiceDuration()). setDeliveryTimeWindow(TimeWindow.newInstance(service.getTimeWindow().getStart(),service.getTimeWindow().getEnd())).build(); }