Support for second "cost" criteria in McRaptor - #4996
Conversation
The method is not used from the DefaultRangeRaptorWorker. In stead each strategy is setting this on the state; Hence the method should be pushed down into the children of RaptorWorkerState.
The StopArrivalsState implementation mostly delegate to an implementation of BestNumberOfTransfers, so we can avoid the inheritance, and inject the concrete implementation of BestNumberOfTransfers where needed instead.
from CostCalculator
This wul enable us to inject a PatternRide with 2 cost criteria later
Move 'relaxCostAtDestination' from SearchParams to MultiCriteriaRequest.
…rovider to Raptor request
mc-raptor can not do reverse search
This is annoying, the information is converted doc inside the code.
- Add priorityGroupId to RaptorTripPattern - Remove DominanceFunction.noop() - Extract GeneralizedCostRelaxFunction from RelaxFunction function - Name ParetoSet comparators - Add relaxC1 and transitPriorityCalculator to MultiCriteriaRequest - Cleanup StopArrivalFactories
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #4996 +/- ##
=============================================
+ Coverage 64.03% 64.10% +0.07%
- Complexity 13566 13694 +128
=============================================
Files 1675 1687 +12
Lines 66222 66570 +348
Branches 7145 7175 +30
=============================================
+ Hits 42403 42675 +272
- Misses 21445 21500 +55
- Partials 2374 2395 +21
... and 59 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
| @@ -1,3 +1,3 @@ | |||
| tcId,nTransfers,duration,cost,walkDistance,startTime,endTime,agencies,modes,routes,stops,details | |||
| 1,0,41m47s,-1,0,13:18:13,14:00:00,,,,,Unknown transit 0tx 41m47s | |||
There was a problem hiding this comment.
Can you explain why this PR changes the non-C2 results?
There was a problem hiding this comment.
It is this fix(c7e2032). The minDurationRoutingStrategy now respect the alightSlack if no ConstrainedTransfers exist between to stops. This make the heuristic a bit tighter and the performance better.
The code line is:
c7e2032#diff-13e08433be2742e1e92ec82e4ece37c45dc793afb140b5ec211bf1707bca1908R74
where we before used 0, and now pass in the slack.
leonardehrenfried
left a comment
There was a problem hiding this comment.
I've picked up on a few typos.
Co-authored-by: Leonard Ehrenfried <mail@leonard.io>

Summary
This PR focus on adding a second criteria(c2) to McRaptor. We will use this later to provide a better neutral travel search. This PR does not change the existing behaviour - the "one" generalized-cost(c1) McRaptor still works as before. Separate state classes which have the additional criteria is added. So when the McRaptor algorithm is configured the appropriate state and calculators are plugged in. The performance for the existing functionality is unchanged - same memory usage and responstimes.
Generalized-cost, C1 and C2
I have introduced two new "words" to the OTP terminology:
c1andc2. This is criteria-one and criteria-two in the MCRaptor state. We store the computed generalized-cost inc1. In principle we can store any computed criteria we want to use in the travel search inc1anc2. So in the algorithm implementation thegeneralized-costis commonly used, while in the statec1is used.Is the C2 automatically included in the pareto-comparason?
NO! To use the c2 in the a compare function must be provided. This will depend on what you want to use the C2 criteria for. The implementation is done in such way that the
computation of c2 and the pareto-set compare function is pluggable. This PR provided functionality for using transit-group-priority as c2. The compare function relax the generalized-cost(c1) comparason if (c2) is different. The c2 is not added as an independent criteria, because that would lead to poor performance. Of, cause doing this do not return all optimal results. It is not possible to compute a sensible heuristics for transit-group-priority. By not having c2 as an independent criteria we avoid the heuristic problem as well.
This is part of #3665. I will add another PR on top of this with:
transit-group-prioritytransit-group-prioritybased on mode, sub-mode, agency and route.Issue
Part of #3665
Unit tests
Many new unit-tests and updated tests
Documentation
TODO
TODO C2will be fixed in a later PR). There are still some floating pieces.