diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index aeb26ce729f..a8f59daad9e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -47,35 +47,40 @@ private Builder(Id id, Id serviceLinkId) { this.serviceLinkId = serviceLinkId; } + public CarrierService build(){ + return new CarrierService(this); + } + /** - * By default, it is [0.0,Integer.MaxValue]. + * Sets a time-window for the beginning of the service + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that + * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). * - * @param serviceDuration duration of the service + * @param startTimeWindow time-window for the beginning of the service acti * @return the builder */ - public Builder setServiceDuration(double serviceDuration){ - this.serviceDuration = serviceDuration; + public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ + this.serviceStartsTimeWindow = startTimeWindow; return this; } /** - * Sets a time-window for the service. - * - *

Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that - * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * Sets the duration for the pickup activity. + * When not set, it is by default 0.0. * - * @param startTimeWindow time-window for the service + * @param serviceDuration duration of the service * @return the builder */ - public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ - this.serviceStartsTimeWindow = startTimeWindow; + public Builder setServiceDuration(double serviceDuration){ + this.serviceDuration = serviceDuration; return this; } - public CarrierService build(){ - return new CarrierService(this); - } + + public Builder setCapacityDemand(int value) { this.demand = value; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 3955d7b1756..f6af6a28d55 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -77,17 +77,17 @@ public static Builder newInstance(Id from, Id to, int size){ /** * Returns a new shipment builder. - *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's size. + *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's demand. * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. * * @param id the id of the shipment * @param from the origin * @param to the destination - * @param size size of the shipment + * @param demand demand of the shipment * @return the builder */ - public static Builder newInstance(Id id, Id from, Id to, int size){ - return new Builder(id, from,to,size); + public static Builder newInstance(Id id, Id from, Id to, int demand){ + return new Builder(id, from, to, demand); } /** @@ -110,29 +110,101 @@ private Builder(Id id, Id pickupLinkId, Id delivery this.demand = demand; } - public Builder setPickupTimeWindow(TimeWindow pickupTW){ - this.pickupStartsTimeWindow = pickupTW; + /** + * Sets a time-window for the beginning of the pickup + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's pickup . If one works with hard time-windows (which means that + * time-windows must be met) than the pickup is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @param pickupStartsTimeWindow time-window for the beginning of the pickup activity + * @return the builder + */ + public Builder setPickupStartsTimeWindow(TimeWindow pickupStartsTimeWindow){ + this.pickupStartsTimeWindow = pickupStartsTimeWindow; return this; } - public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ - this.deliveryStartsTimeWindow = deliveryTW; + /** + * Sets the duration for the pickup activity. + * When not set, it is by default 0.0. + * + * @param pickupDuration Duration of the pickup activity (in seconds). + * @return the Builder + */ + public Builder setPickupDuration(double pickupDuration){ + this.pickupDuration = pickupDuration; return this; } - public Builder setPickupServiceTime(double pickupServiceTime){ - this.pickupDuration = pickupServiceTime; + /** + * Sets a time-window for the beginning of the delivery + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's delivery . If one works with hard time-windows (which means that + * time-windows must be met) than the delivery is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @param deliveryStartsTimeWindow time-window for the beginning of the delivery activity + * @return the builder + */ + public Builder setDeliveryStartsTimeWindow(TimeWindow deliveryStartsTimeWindow){ + this.deliveryStartsTimeWindow = deliveryStartsTimeWindow; return this; } - public Builder setDeliveryServiceTime(double deliveryServiceTime){ - this.deliveryDuration = deliveryServiceTime; + /** + * Sets the duration for the delivery activity. + * When not set, it is by default 0.0. + * + * @param deliveryDuration Duration of the delivery activity (in seconds). + * @return the Builder + */ + public Builder setDeliveryDuration(double deliveryDuration){ + this.deliveryDuration = deliveryDuration; return this; } public CarrierShipment build(){ return new CarrierShipment(this); } + + //*** deprecated methods *** + + + /** + * @deprecated please inline and use {@link #setPickupStartsTimeWindow(TimeWindow)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setPickupTimeWindow(TimeWindow pickupTW){ + return setPickupStartsTimeWindow(pickupTW); + } + + /** + * @deprecated please inline and use {@link #setPickupDuration(double)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setPickupServiceTime(double pickupServiceTime){ + return setPickupDuration(pickupServiceTime); + } + + /** + * @deprecated please inline and use {@link #setDeliveryStartsTimeWindow(TimeWindow)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ + return setDeliveryStartsTimeWindow(deliveryTW); + } + + /** + * @deprecated please inline and use {@link #setDeliveryDuration(double)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setDeliveryServiceTime(double deliveryServiceTime){ + return setDeliveryDuration(deliveryServiceTime); + } + + + } private final Id id;