Otp2 cost transfer - #3629
Merged
Merged
Otp2 cost transfer#3629
Conversation
- Support for reduced cost in Raptor for constrained transfers - New Path builder, used in Raptor mappers(FWD & RWS), Optimize transfers and in TestPathBuilder.
Unit tests are added on OptimizedPathTail and OptimizedPath.
Clean up how transfer constraint is added to path toStrings. Make utility methods for adding cost w/unit.
There is an error in the logic in OptimizedPathTail line 195 and the OptimizedPath line 90, when adding the priority cost. In both places a cost was added for path legs witch did not represent a transfer. Since the transfer constraint is on the transit-leg BEFORE the optional transfer, this logic is a bit complicated. This commit fixes this, and refactor the priority cost calculation, so the cost is always positive. Previously the transfer priority cost was calculated in the TransferPriority enum, but part of the information is in the TransferConstraint, so it make sense to move some of the logic up to he TransferConstraint.
This commit add the ability to log the stop id and name as part of the Raptor returned path. This is continent when logging and debugging in Raptor.
hannesj
reviewed
Oct 6, 2021
Co-authored-by: Hannes Junnila <hannes.junnila@gmail.com>
t2gran
force-pushed
the
otp2_cost_transfer
branch
from
October 7, 2021 14:43
f77e1c2 to
66e0b66
Compare
# Conflicts: # src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java
hannesj
previously approved these changes
Oct 8, 2021
We need to check if the previous stop-arrival is an access-stop arrival in StopArrivalsState#previousTransit(int boardStopIndex), not just return the previous arrival.
This parameter do not need to be a multi-criteria request.
Inject the search direction (FORWARD/REVERSE) into the debug logger using life-cycle events instead of relaying on looking at "increasing" arrival-times. There are cases where arrival times in two following arrivals are tha same, and with constrained transfers we might allow negative times.
The trip-times-search is used in many places to find boar- and alight-times for a given RaptorTripSchedule. There are several version supporting forward and reverse Raptor search results, but the current version handle the NO_WAIT_WORKER and the 0 minutes transfers badly. To improve this a new search witch find the colosest trip with respect to an approximate time is added, and the existing methods refactored. New unit tests are added. We will use the new version later.
The Raptor routing engine only support one access/egress leg for each stop. The McRaptor do support this, but not the Standard Raptor or BestTime Raptor. The BestTime will not fail, but pick an arbitrary access/egress while the Standard will fail. The reason way this has not failed in normal operation is that the BestTime is used in the Heuristics. But, for transfers with constraints we need to use the Standard Raptor state instead.
If transfer constraints are not used with heuristics we might not be able to find a path from some locations. This commit enables using constrained transfers with the Standard Raptor State and uses it for the heuristic search when constrained transfers is enabled.
flaktack
previously approved these changes
Oct 12, 2021
flaktack
left a comment
Contributor
There was a problem hiding this comment.
We've tested this with staySeated transfers and it worked as expected.
hannesj
previously approved these changes
Oct 12, 2021
In NeTEx an interchange have an id, in GTFS a transfer do not. We include it here to enable debugging, logging and system integration. Note! OTP do not use the id, and it is just passed through OTP. There is no service in OTP to look up a transfer by the id.
Raptor allow facilitated transfers between two stops to happen even if there is no time to do the transfer walking. So, the optimized transfer service also need to respect this.
t2gran
force-pushed
the
otp2_cost_transfer
branch
from
October 13, 2021 11:57
1d41c2f to
6aef0a9
Compare
hannesj
previously approved these changes
Oct 20, 2021
abyrd
previously approved these changes
Oct 21, 2021
abyrd
left a comment
Member
There was a problem hiding this comment.
I have done a high-level review, and this generally looks good. I have not tested on input data with guaranteed transfers (so it's good to have testing commentary from @flaktack). It's also reassuring to see thorough use of testing and assertions. I just made one suggestion on the changelog.
Member
Author
|
I will force this trough, since we have two approvals (dismissed by the last merged.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR clean up the Optimize transfer, path building and add cost calculation for guaranteed and stay-seated transfers during the Raptor routing. It is the base for adding some of the reminding features for constrained transfer support.
A CONSTRAINED transfer is a transfer with extra constraints. These are imported from GTFS transfers.txt and NeTEx Interchanges. Example of constraints are
stay-seated(blocks in GTFS),guaranteed, transfer priority, max-wait-time. This PR only changes the Raptor and post Raptor code, it does not do anything with the import.This PR also changes OTP to use constrained transfers in the heuristics, previously it was only used in the forward multi-criteria search. To make it work several improvements was needed:
RaptorRoutingRequestTransitDatado. The only reason this have not failed is that the Best-time Raptor state is used in the heuristics. The constrained transfers require the standard state to be used to look up previous transit arrivals (previous trip). This fails hard with an exception, saying that multiple-access paths are not supported. I have added support for this by filtering the access and egress paths if the Raptor profile is not multi-criteria. The multi-criteria is unchanged and work with this.Issue
closes #3478
Unit tests
I have not done any performance testing on this, but with few constrained transfers the performance change should be minimal. Also, the
OTPFeature#TransferConstraintscan be turned off - in witch case the performance should be the same as before.Documentation
All relevant documentation should be up to date, there is very little doc on this in the documentation.
Changelog
✅