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

Draft: max detour constraint drt #2834

Closed
wants to merge 12 commits into from

Conversation

nkuehnel
Copy link
Member

No description provided.

@nkuehnel nkuehnel requested a review from luchengqi7 October 11, 2023 10:04
@nkuehnel nkuehnel added the code sprint Possible issue(s) for the MATSim code sprint label Oct 11, 2023
to include max ride duration. The max ride duration is calculated in a similar manner as the max travel time. A new set of parameters (maxDetourAlpha, maxDetourBeta) are introduced in the drtCfg to calculate the max ride duration.
}

final int pickupIdx = insertion.pickup.index;
Map<Id<Request>, Double> pickUps = new HashMap<>(ongoingRequests);
Copy link
Member

Choose a reason for hiding this comment

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

What is the point of copying this map?

Copy link
Member

Choose a reason for hiding this comment

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

I think I understand the idea. However, I think copying the map and then adding even more stuff to it is a bit too heavy.


public class MaxDetourInsertionCostCalculator implements InsertionCostCalculator, PassengerPickedUpEventHandler, PassengerDroppedOffEventHandler {

private final Map<Id<Request>, Double> ongoingRequests = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

This map can be read and written at the same time (events handling is executed in parallel to optimisation)

@luchengqi7
Copy link
Collaborator

Hi Nico, it seems that our hack does not work with the current insertion logic. The arrival time of the WayPoint is not implemented.

I have discussed with Michal (@michalmac), and now we think it may be better to have some more fundamental implementation, rather than changing the current basic structure of the insertion.

We can have a discussion after you return from your vacation.

@luchengqi7
Copy link
Collaborator

Hi Nico,

How are you? Hope everything is running smoothly :)

May I know if there is any update from your side on this topic? Shall we go ahead to change the structure of the insertion logic, or perhaps we can think of an alternative quick fix?

Best regards,
Chengqi Lu

@sebhoerl
Copy link
Contributor

sebhoerl commented Dec 1, 2023

Just as comment, it might also be worth it thinking about adding this as a constraint here :)
#2947

@luchengqi7
Copy link
Collaborator

Just as comment, it might also be worth it thinking about adding this as a constraint here :) #2947

That's a great point! Thanks a lot, Sebastian!

@michalmac
Copy link
Member

michalmac commented Dec 1, 2023

Just as comment, it might also be worth it thinking about adding this as a constraint here :) #2947

That's a great point! Thanks a lot, Sebastian!

My suggestion would be to use the max detour time in pre-computation of slack times, i.e. before generating insertions. Otherwise, if we only post-process insertions, we may experience an "unexplainable" increase in computation time when changing from max travel time to max detour time.

@nkuehnel
Copy link
Member Author

nkuehnel commented Dec 6, 2023

Hey @luchengqi7 ! sorry for my late reply, it was a bit busy.

Maybe we can have a chat next week? I'll write a mail

@luchengqi7
Copy link
Collaborator

Hey @luchengqi7 ! sorry for my late reply, it was a bit busy.

Maybe we can have a chat next week? I'll write a mail

Sure, that sounds good! Thanks a lot! 👍

@michalmac
Copy link
Member

I just pushed a commit that reverts the changes in AbstractRoute (this was not intended) and instead introduces them in DrtRoute.

@nkuehnel @luchengqi7 I wanted to bring this up for your next week sync: DrtConfigGroup.maxAbsoluteDetour is used for the total travel time (wait+ride). I guess we need something else for the max detour wrt ride time? Right now this logic is not correct (see the first argument in both min() methods):

	static double getMaxTravelTime(DrtConfigGroup drtCfg, double unsharedRideTime) {
		return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, drtCfg.maxTravelTimeAlpha * unsharedRideTime + drtCfg.maxTravelTimeBeta);
	}

	static double getMaxRideTime(DrtConfigGroup drtCfg, double unsharedRideTime) {
		return Math.min(unsharedRideTime + drtCfg.maxAbsoluteDetour, drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta);
	}

We now make use the initial planned pick up time (+ a small buffer) + max ride duration to determine the latest arrival time. This will also be a fixed value, therefore, it will not impact the matching logic. The latest arrival time based on the original alpha beta value is also included here (with Math.min operation).

The main change here is that we can no longer insert a lot of stops before the scheduled pick ups, as we limit the latest pick up time based on the initial scheduled pick up time. This should also be meaningful in the reality.
@luchengqi7
Copy link
Collaborator

Hi @nkuehnel, today I have discussed with Michal, and he is happy about this new idea. Since there are some other changes and conflicts in this branch, shall I open a new PR in the current matsim-lib (upstream)?

luchengqi7 added a commit that referenced this pull request Dec 15, 2023
luchengqi7 added a commit that referenced this pull request Jan 28, 2024
* Add DRT detour constraints

Based on the PR #2834

* Consolidate two classes

PromisedPickupTimeWindowDrtOfferAcceptor -> MaxDetourOfferAcceptor

MaxDetourInsertionCostCalculator -> DefaultInsertionCostCalculator

* Update SharingFactorTest.java

* Update expected outputs

* Unimportant commit

To make sure the test will be based on the new expected values

* temporarily disable check

* Update some naming and description

Based on Michal's suggestion.

* Minor refactoring

* Revert "temporarily disable check"

This reverts commit d69429b.

* taxi: update expected output plans in tests

---------

Co-authored-by: Michal Maciejewski <[email protected]>, Nico Kühnel (nkuehnel)
@luchengqi7
Copy link
Collaborator

The proposed changes in this PR have been merged to the master branch by PR #2997.

@luchengqi7 luchengqi7 closed this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code sprint Possible issue(s) for the MATSim code sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement more fine-grained control over DRT detour and waiting time constraints
4 participants