Skip to content

Commit

Permalink
Update some naming and description
Browse files Browse the repository at this point in the history
Based on Michal's suggestion.
  • Loading branch information
luchengqi7 committed Jan 26, 2024
1 parent d69429b commit dc0fe55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AcceptedDrtRequest> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit dc0fe55

Please sign in to comment.