@Override public Location getLocation() { return shipment.getDeliveryLocation(); }
private void setEndLocation(VehicleRoute route, Shipment shipment) { route.getEnd().setLocation(shipment.getDeliveryLocation()); }
private double calcDist(Shipment i, Shipment j) { double c_i1j1 = calcDist(i.getPickupLocation(), j.getPickupLocation()); double c_i1j2 = calcDist(i.getPickupLocation(), j.getDeliveryLocation()); double c_i2j1 = calcDist(i.getDeliveryLocation(), j.getPickupLocation()); double c_i2j2 = calcDist(i.getDeliveryLocation(), j.getDeliveryLocation()); return (c_i1j1 + c_i1j2 + c_i2j1 + c_i2j2) / 4.0; }
private double calcDist(Service i, Shipment j) { double c_ij1 = calcDist(i.getLocation(), j.getPickupLocation()); double c_ij2 = calcDist(i.getLocation(), j.getDeliveryLocation()); return (c_ij1 + c_ij2) / 2.0; }
private void addLocationToTentativeLocations(Job job) { if (job instanceof Service) { Location location = ((Service) job).getLocation(); // tentative_coordinates.put(location.getId(), location.getCoordinate()); addLocationToTentativeLocations(location); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; Location pickupLocation = shipment.getPickupLocation(); addLocationToTentativeLocations(pickupLocation); // tentative_coordinates.put(pickupLocation.getId(), pickupLocation.getCoordinate()); Location deliveryLocation = shipment.getDeliveryLocation(); addLocationToTentativeLocations(deliveryLocation); // tentative_coordinates.put(deliveryLocation.getId(), deliveryLocation.getCoordinate()); } }
private double scoreShipment(InsertionData best, Job job) { Shipment shipment = (Shipment) job; double maxDepotDistance_1 = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), shipment.getPickupLocation()), getDistance(best.getSelectedVehicle().getStartLocation(), shipment.getDeliveryLocation()) ); double maxDepotDistance_2 = Math.max( getDistance(best.getSelectedVehicle().getEndLocation(), shipment.getPickupLocation()), getDistance(best.getSelectedVehicle().getEndLocation(), shipment.getDeliveryLocation()) ); double maxDepotDistance = Math.max(maxDepotDistance_1, maxDepotDistance_2); double minTimeToOperate = Math.min(shipment.getPickupTimeWindow().getEnd() - shipment.getPickupTimeWindow().getStart(), shipment.getDeliveryTimeWindow().getEnd() - shipment.getDeliveryTimeWindow().getStart()); return Math.max(timeWindowParam * minTimeToOperate, minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) { Shipment envelope = (Shipment) job; return routingCosts.getTransportTime(v.getStartLocation(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) + routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v); }
@Override public boolean fulfilled(JobInsertionContext insertionContext) { Shipment shipment2insert = ((Shipment) insertionContext.getJob()); if (insertionContext.getNewVehicle().getId().equals("wheelchair_bus")) { if (shipment2insert.getSize().get(PASSENGERSEATS_INDEX) > 0) { if (shipment2insert.getPickupLocation().getCoordinate().getX() > 15. || shipment2insert.getDeliveryLocation().getCoordinate().getX() > 15.) { return false; } } } return true; } };
@Override public Location getLocation() { return shipment.getDeliveryLocation(); }
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) { Node n1 = g.addNode(makeId(shipment.getId(), shipment.getPickupLocation().getId())); if (label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId()); n1.addAttribute("x", shipment.getPickupLocation().getCoordinate().getX()); n1.addAttribute("y", shipment.getPickupLocation().getCoordinate().getY()); n1.setAttribute("ui.class", "pickup"); Node n2 = g.addNode(makeId(shipment.getId(), shipment.getDeliveryLocation().getId())); if (label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId()); n2.addAttribute("x", shipment.getDeliveryLocation().getCoordinate().getX()); n2.addAttribute("y", shipment.getDeliveryLocation().getCoordinate().getY()); n2.setAttribute("ui.class", "delivery"); if (renderShipments) { Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(), shipment.getPickupLocation().getId()), makeId(shipment.getId(), shipment.getDeliveryLocation().getId()), true); s.addAttribute("ui.class", "shipment"); } }
if (shipment.getDeliveryLocation().getId() != null) xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.id", shipment.getDeliveryLocation().getId()); if (shipment.getDeliveryLocation().getCoordinate() != null) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.coord[@x]", shipment.getDeliveryLocation().getCoordinate().getX()); xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.coord[@y]", shipment.getDeliveryLocation().getCoordinate().getY()); if (shipment.getDeliveryLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty(shipmentPathString + "(" + counter + ").delivery.location.index", shipment.getDeliveryLocation().getIndex());
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 XYSeriesCollection makeShipmentSeries(Collection<Job> jobs) throws NoLocationFoundException { XYSeriesCollection coll = new XYSeriesCollection(); if (!plotShipments) return coll; int sCounter = 1; String ship = "shipment"; boolean first = true; for (Job job : jobs) { if (!(job instanceof Shipment)) { continue; } Shipment shipment = (Shipment) job; XYSeries shipmentSeries; if (first) { first = false; shipmentSeries = new XYSeries(ship, false, true); } else { shipmentSeries = new XYSeries(sCounter, false, true); sCounter++; } Coordinate pickupCoordinate = getCoordinate(shipment.getPickupLocation().getCoordinate()); Coordinate delCoordinate = getCoordinate(shipment.getDeliveryLocation().getCoordinate()); shipmentSeries.add(pickupCoordinate.getX() * scalingFactor, pickupCoordinate.getY() * scalingFactor); shipmentSeries.add(delCoordinate.getX() * scalingFactor, delCoordinate.getY() * scalingFactor); coll.addSeries(shipmentSeries); } return coll; }
containsPickupAct = true; Coordinate deliveryCoordinate = getCoordinate(s.getDeliveryLocation().getCoordinate()); XYDataItem dataItem2 = new XYDataItem(deliveryCoordinate.getX() * scalingFactor, deliveryCoordinate.getY() * scalingFactor); activities.add(dataItem2);
private double calcDist(Shipment i, Shipment j) { double c_i1j1 = calcDist(i.getPickupLocation(), j.getPickupLocation()); double c_i1j2 = calcDist(i.getPickupLocation(), j.getDeliveryLocation()); double c_i2j1 = calcDist(i.getDeliveryLocation(), j.getPickupLocation()); double c_i2j2 = calcDist(i.getDeliveryLocation(), j.getDeliveryLocation()); return (c_i1j1 + c_i1j2 + c_i2j1 + c_i2j2) / 4.0; }
private void setEndLocation(VehicleRoute route, Shipment shipment) { route.getEnd().setLocation(shipment.getDeliveryLocation()); }
private double calcDist(Service i, Shipment j) { double c_ij1 = calcDist(i.getLocation(), j.getPickupLocation()); double c_ij2 = calcDist(i.getLocation(), j.getDeliveryLocation()); return (c_ij1 + c_ij2) / 2.0; }
private void addLocationToTentativeLocations(Job job) { if (job instanceof Service) { Location location = ((Service) job).getLocation(); // tentative_coordinates.put(location.getId(), location.getCoordinate()); addLocationToTentativeLocations(location); } else if (job instanceof Shipment) { Shipment shipment = (Shipment) job; Location pickupLocation = shipment.getPickupLocation(); addLocationToTentativeLocations(pickupLocation); // tentative_coordinates.put(pickupLocation.getId(), pickupLocation.getCoordinate()); Location deliveryLocation = shipment.getDeliveryLocation(); addLocationToTentativeLocations(deliveryLocation); // tentative_coordinates.put(deliveryLocation.getId(), deliveryLocation.getCoordinate()); } }
private double scoreShipment(InsertionData best, Job job) { Shipment shipment = (Shipment) job; double maxDepotDistance_1 = Math.max( getDistance(best.getSelectedVehicle().getStartLocation(), shipment.getPickupLocation()), getDistance(best.getSelectedVehicle().getStartLocation(), shipment.getDeliveryLocation()) ); double maxDepotDistance_2 = Math.max( getDistance(best.getSelectedVehicle().getEndLocation(), shipment.getPickupLocation()), getDistance(best.getSelectedVehicle().getEndLocation(), shipment.getDeliveryLocation()) ); double maxDepotDistance = Math.max(maxDepotDistance_1, maxDepotDistance_2); double minTimeToOperate = Math.min(shipment.getPickupTimeWindow().getEnd() - shipment.getPickupTimeWindow().getStart(), shipment.getDeliveryTimeWindow().getEnd() - shipment.getDeliveryTimeWindow().getStart()); return Math.max(timeWindowParam * minTimeToOperate, minTimeWindowScore) + depotDistanceParam * maxDepotDistance; }
/** * Creates (MATSim) {@link CarrierShipment} from a (jsprit) {@link Shipment} * * @param shipment to be transformed to MATSim * @return CarrierShipment * @see CarrierShipment, Shipment */ static CarrierShipment createCarrierShipment(Shipment shipment) { return CarrierShipment.Builder.newInstance(Id.create(shipment.getId(), CarrierShipment.class), Id.createLinkId(shipment.getPickupLocation().getId()), Id.createLinkId(shipment.getDeliveryLocation().getId()), shipment.getSize().get(0)) .setDeliveryServiceTime(shipment.getDeliveryServiceTime()) .setDeliveryTimeWindow(TimeWindow.newInstance(shipment.getDeliveryTimeWindow().getStart(), shipment.getDeliveryTimeWindow().getEnd())) .setPickupServiceTime(shipment.getPickupServiceTime()) .setPickupTimeWindow(TimeWindow.newInstance(shipment.getPickupTimeWindow().getStart(), shipment.getPickupTimeWindow().getEnd())) .build(); }