From dc0fe55163bc0bb331c2fef5c213bfa9ab650810 Mon Sep 17 00:00:00 2001 From: Chengqi Lu <43133404+luchengqi7@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:43:38 +0100 Subject: [PATCH] Update some naming and description Based on Michal's suggestion. --- .../drt/passenger/MaxDetourOfferAcceptor.java | 14 ++++++------- .../contrib/drt/routing/DrtRouteCreator.java | 3 +-- .../contrib/drt/run/DrtConfigGroup.java | 21 +++++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/passenger/MaxDetourOfferAcceptor.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/passenger/MaxDetourOfferAcceptor.java index 00baac4565f..fe2dfb25834 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/passenger/MaxDetourOfferAcceptor.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/passenger/MaxDetourOfferAcceptor.java @@ -3,21 +3,21 @@ import java.util.Optional; public class MaxDetourOfferAcceptor implements DrtOfferAcceptor{ - private final double promisedPickupTimeWindow; + private final double maxAllowedPickupDelay; - public MaxDetourOfferAcceptor(double promisedPickupTimeWindow) { - this.promisedPickupTimeWindow = promisedPickupTimeWindow; + public MaxDetourOfferAcceptor(double maxAllowedPickupDelay) { + this.maxAllowedPickupDelay = maxAllowedPickupDelay; } @Override public Optional acceptDrtOffer(DrtRequest request, double departureTime, double arrivalTime) { - double updatedPickupTimeWindow = Math.min(departureTime - + promisedPickupTimeWindow, request.getLatestStartTime()); + double updatedLatestStartTime = Math.min(departureTime + + maxAllowedPickupDelay, request.getLatestStartTime()); return Optional.of(AcceptedDrtRequest .newBuilder() .request(request) .earliestStartTime(request.getEarliestStartTime()) - .latestArrivalTime(Math.min(updatedPickupTimeWindow + request.getMaxRideDuration(), request.getLatestArrivalTime())) - .latestStartTime(updatedPickupTimeWindow).build()); + .latestArrivalTime(Math.min(updatedLatestStartTime + request.getMaxRideDuration(), request.getLatestArrivalTime())) + .latestStartTime(updatedLatestStartTime).build()); } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java index 3f05ef097ea..15f9bb77530 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DrtRouteCreator.java @@ -61,8 +61,7 @@ public DrtRouteCreator(DrtConfigGroup drtCfg, Network modalNetwork, * @return maximum travel time */ static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) { - return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, - drtCfg.maxTravelTimeAlpha * unsharedRideTime + drtCfg.maxTravelTimeBeta); + return drtCfg.maxTravelTimeAlpha * unsharedRideTime + drtCfg.maxTravelTimeBeta; } /** diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java index aa76c3bde41..7fb685bd92e 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java @@ -107,30 +107,33 @@ public static DrtConfigGroup getSingleModeDrtConfig(Config config) { @Parameter @Comment( - "Defines the maximum allowed absolute detour in seconds of the maxTravelTime estimation function (optimisation constraint), i.e. " - + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " - + "maxAbsoluteDetour should not be smaller than 0. and should be higher than the offset maxTravelTimeBeta.") + "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + + "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " + + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") @PositiveOrZero public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] @Parameter @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. A linear combination similar to travel time constrain is used" - + "This is the ratio part") + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") @DecimalMin("1.0") public double maxDetourAlpha = Double.POSITIVE_INFINITY; @Parameter @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. A linear combination similar to travel time constrain is used" - + "This is the constant part") + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") @PositiveOrZero public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] @Parameter @Comment( - "Defines the maximum delay allowed from the initial scheduled pick up time. Once a estimated pick up time is determined, the DRT optimizer" - + "should try to keep this promise. By default, this limit is disabled. If enabled, a value between 120 and 240 is a good choice.") + "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" + + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " + + "By default, this limit is disabled. If enabled, a value between 120 and 240 is a good choice.") @PositiveOrZero public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s]