Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRT detour constraints (based on PR #2834) #2997

Merged
merged 15 commits into from
Jan 28, 2024

Conversation

luchengqi7
Copy link
Collaborator

This PR is based on the finished version of PR #2834, built based on the latest matsim-lib.

For more details, please refer to the previous PR.

Copy link
Member

@michalmac michalmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I added a few comments. Please consider them so it is easier to reason for the users and developers how this constraint really works.

@Override
public Optional<AcceptedDrtRequest> acceptDrtOffer(DrtRequest request, double departureTime, double arrivalTime) {
double updatedPickupTimeWindow = Math.min(departureTime
+ promisedPickupTimeWindow, request.getLatestStartTime());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a different name than promisedPickupTimeWindow. We usually think of a time window as a [a,b) period, where a and b are time stamps. Here, promisedPickupTimeWindow is a duration and represents a time buffer.

In the drt config group, we use maxAllowedPickupDelay instetad of promisedPickupTimeWindow. I think we should also use this name in this class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updatedPickupTimeWindow should be renamed. Maybe updatedLatestStartTime?

* @return maximum ride time
*/
static double getMaxRideTime(DrtConfigGroup drtCfg, double unsharedRideTime) {
return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should use unsharedRideTime + drtCfg.maxAbsoluteDetour in both getMaxTravelTime() and getMaxRideTime().

Imposing this constraint on maxTravelTime implies it is also imposed on maxRideTime, because maxTravelTime >= maxRideTime.


@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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rewrite the second sentence in this way?
"Once the initial pickup time is offered, he DRT optimizer must not exceed the promised time by the maxAllowedPickupDelay amount of time."

Comment on lines 116 to 128
@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")
@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")
@PositiveOrZero
public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two comments should mention that the detour is computed from the latest promised pickup time and not from the actual pickup time.

I think we should also mention the following somewhere (maybe in MaxDetourInsertionCostCalculator):
By taking into account the latest promised pickup time (instead of the actual pickup time), we simplify the handing of this constraint, because the actual pickup time remains unknown until the moment of picking up the passenger.

BTW. In a simulation setup without congestion, the actual pickup time is always less than or equal to the promised time. With congestion there is no such a guarantee.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @michalmac! I will update the descriptions and comments based on the comments.

@nkuehnel
Copy link
Member

Thanks @luchengqi7 !

@michalmac would it make sense to consolidate the OfferAcceptor and InsertionCostCalculator to implement the new constraint in the default implementations? The parameters are already part of the default drt config and request anyway

@michalmac
Copy link
Member

@michalmac would it make sense to consolidate the OfferAcceptor and InsertionCostCalculator to implement the new constraint in the default implementations? The parameters are already part of the default drt config and request anyway

Good point! Actually, that was the main reason for adding these params to the config (I assume).

@luchengqi7
Copy link
Collaborator Author

@michalmac would it make sense to consolidate the OfferAcceptor and InsertionCostCalculator to implement the new constraint in the default implementations? The parameters are already part of the default drt config and request anyway

Good point! Actually, that was the main reason for adding these params to the config (I assume).

Oh yeah, I will update that! 😀

@michalmac
Copy link
Member

@luchengqi7 I reenabled IT tests in taxi and rerun them on my laptop (intel CPU). The problem with CI failures is that the workflows are run on a linux machine with an intel CPU. When runnin on a mac machine with an apple cpu, you get slight differences in scores (output plans).

I think, in the long term, we need to change the way how we compare output plans to account for differences between these platforms.

@luchengqi7 luchengqi7 merged commit 56e60eb into master Jan 28, 2024
48 checks passed
@luchengqi7 luchengqi7 deleted the drt-max-detour-constraint branch January 28, 2024 15:30
@nkuehnel
Copy link
Member

thanks so much @luchengqi7 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants