Skip to content

Commit

Permalink
Merge branch 'master' into fix/drt/attribute-based-prebooking-names
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl authored Dec 5, 2024
2 parents ff48382 + 53933b6 commit 282b0f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,35 @@ public class DefaultDrtOptimizationConstraintsSet extends DrtOptimizationConstra

@Parameter
@Comment(
"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, "
"Defines the maximum allowed absolute detour in seconds. 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. 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 "
"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. 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. 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 "
"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. 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 minimum allowed absolute detour in seconds. By default, this bound is disabled (i.e. set to 0.)")
@PositiveOrZero
public double minimumAllowedDetour = 0;

@Override
protected void checkConsistency(Config config) {
super.checkConsistency(config);
if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) {
Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " +
"maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay.");
}
Verify.verify(maxAbsoluteDetour > minimumAllowedDetour, "The minimum allowed detour must" +
"be lower than the maximum allowed detour.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public DefaultDrtRouteConstraintsCalculator(DrtConfigGroup drtCfg, ConstraintSet
/**
* Calculates the maximum travel time defined as: drtCfg.getMaxTravelTimeAlpha()
* unsharedRideTime + drtCfg.getMaxTravelTimeBeta()
*
* Calculates the maximum ride time defined as: drtCfg.maxDetourAlpha *
* unsharedRideTime + drtCfg.maxDetourBeta
*
* Calculates the maximum ride time defined as:
* unsharedRideTime + min(
* maxAbsoluteDetour,
* max(minimumAllowedDetour, unsharedRideTime * (1-drtCfg.maxDetourAlpha) + drtCfg.maxDetourBeta)
* )
*
* @return DrtRouteConstraints constraints
*/
Expand All @@ -40,8 +43,8 @@ public DrtRouteConstraints calculateRouteConstraints(double departureTime, Link

if (constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) {
double maxTravelTime = defaultSet.maxTravelTimeAlpha * unsharedRideTime + defaultSet.maxTravelTimeBeta;
double maxRideTime = Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour,
defaultSet.maxDetourAlpha * unsharedRideTime + defaultSet.maxDetourBeta);
double maxDetour = Math.max(defaultSet.minimumAllowedDetour, unsharedRideTime * (defaultSet.maxDetourAlpha -1) + defaultSet.maxDetourBeta);
double maxRideTime = unsharedRideTime + Math.min(defaultSet.maxAbsoluteDetour, maxDetour);
double maxWaitTime = constraintsSet.maxWaitTime;

return new DrtRouteConstraints(maxTravelTime, maxRideTime, maxWaitTime);
Expand Down

0 comments on commit 282b0f1

Please sign in to comment.