|
| 1 | +package org.matsim.contrib.drt.optimizer; |
| 2 | + |
| 3 | +import com.google.common.base.Verify; |
| 4 | +import jakarta.validation.constraints.DecimalMin; |
| 5 | +import jakarta.validation.constraints.NotBlank; |
| 6 | +import jakarta.validation.constraints.PositiveOrZero; |
| 7 | +import org.matsim.core.config.Config; |
| 8 | +import org.matsim.core.config.ReflectiveConfigGroup; |
| 9 | + |
| 10 | +public class DrtOptimizationConstraintsSet extends ReflectiveConfigGroup { |
| 11 | + |
| 12 | + public static final String SET_NAME = "drtOptimizationConstraintsSet"; |
| 13 | + public static final String DEFAULT_PARAMS_NAME = "default"; |
| 14 | + |
| 15 | + public DrtOptimizationConstraintsSet() { |
| 16 | + super(SET_NAME); |
| 17 | + } |
| 18 | + |
| 19 | + @Parameter |
| 20 | + @Comment("name of optimization params") |
| 21 | + @NotBlank |
| 22 | + public String name = DEFAULT_PARAMS_NAME; |
| 23 | + |
| 24 | + @Parameter |
| 25 | + @Comment("Max wait time for the bus to come (optimisation constraint).") |
| 26 | + @PositiveOrZero |
| 27 | + public double maxWaitTime = Double.NaN;// seconds |
| 28 | + |
| 29 | + @Parameter |
| 30 | + @Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. " |
| 31 | + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " |
| 32 | + + "Alpha should not be smaller than 1.") |
| 33 | + @DecimalMin("1.0") |
| 34 | + public double maxTravelTimeAlpha = Double.NaN;// [-] |
| 35 | + |
| 36 | + @Parameter |
| 37 | + @Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. " |
| 38 | + + "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). " |
| 39 | + + "Beta should not be smaller than 0.") |
| 40 | + @PositiveOrZero |
| 41 | + public double maxTravelTimeBeta = Double.NaN;// [s] |
| 42 | + |
| 43 | + @Parameter |
| 44 | + @Comment( |
| 45 | + "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + |
| 46 | + "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " |
| 47 | + + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") |
| 48 | + @PositiveOrZero |
| 49 | + public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] |
| 50 | + |
| 51 | + @Parameter |
| 52 | + @Comment( |
| 53 | + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " |
| 54 | + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " |
| 55 | + + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") |
| 56 | + @DecimalMin("1.0") |
| 57 | + public double maxDetourAlpha = Double.POSITIVE_INFINITY; |
| 58 | + |
| 59 | + @Parameter |
| 60 | + @Comment( |
| 61 | + "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " |
| 62 | + + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " |
| 63 | + + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") |
| 64 | + @PositiveOrZero |
| 65 | + public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] |
| 66 | + |
| 67 | + @Parameter |
| 68 | + @Comment( |
| 69 | + "Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised" |
| 70 | + + "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. " |
| 71 | + + "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.") |
| 72 | + @PositiveOrZero |
| 73 | + public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s] |
| 74 | + |
| 75 | + @Parameter |
| 76 | + @Comment("If true, the max travel and wait times of a submitted request" |
| 77 | + + " are considered hard constraints (the request gets rejected if one of the constraints is violated)." |
| 78 | + + " If false, the max travel and wait times are considered soft constraints (insertion of a request that" |
| 79 | + + " violates one of the constraints is allowed, but its cost is increased by additional penalty to make" |
| 80 | + + " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised" |
| 81 | + + " InsertionCostCalculator.PenaltyCalculator") |
| 82 | + public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params) |
| 83 | + |
| 84 | + @Parameter |
| 85 | + @Comment( |
| 86 | + "Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt." |
| 87 | + + " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).") |
| 88 | + @PositiveOrZero // used only for stopbased DRT scheme |
| 89 | + public double maxWalkDistance = Double.MAX_VALUE;// [m]; |
| 90 | + |
| 91 | + |
| 92 | + @Parameter |
| 93 | + @Comment( |
| 94 | + "Time before reaching a planned dropoff from which it is not allowed to insert new detours for new requests. I.e.," + |
| 95 | + " if set to 180, then a vehicle will not divert to pickup or dropoff a new passenger once a boarded passenger is only " + |
| 96 | + "3 minutes away from her destination, even though her time window would allow it." + |
| 97 | + " Delayed detours just before arrival are usually perceived very negatively.") |
| 98 | + @PositiveOrZero |
| 99 | + public double lateDiversionthreshold = 0; // [s]; |
| 100 | + |
| 101 | + |
| 102 | + @Override |
| 103 | + protected void checkConsistency(Config config) { |
| 104 | + super.checkConsistency(config); |
| 105 | + if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { |
| 106 | + Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + |
| 107 | + "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments