/** * Adds a the delivery of the specified shipment. * * @param shipment to be delivered and add to this vehicleRoute * @return builder * @throws IllegalArgumentException if specified shipment has not been picked up yet (i.e. method addPickup(shipment) has not been called yet). */ public Builder addDelivery(Shipment shipment) { return addDelivery(shipment,shipment.getDeliveryTimeWindow()); }
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; }
/** * Adds a the delivery of the specified shipment. * * @param shipment to be delivered and add to this vehicleRoute * @return builder * @throws IllegalArgumentException if specified shipment has not been picked up yet (i.e. method addPickup(shipment) has not been called yet). */ public Builder addDelivery(Shipment shipment) { return addDelivery(shipment,shipment.getDeliveryTimeWindow()); }
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(); }