Add support to unprefer certain routes - #4238
Conversation
|
In case you're wondering why your build fails: things have changed in the dev-2.x branch and Github Actions always builds the merge of your branch and dev-2.x. If you merge dev-2.x into your branch again you should see the same failure locally, which will make it easy to fix. |
Co-authored-by: Thomas Gran <t2gran@gmail.com>
| transferConstraints | ||
| ); | ||
|
|
||
| int routeReluctanceCost = routePenalties.getOrDefault(trip.routeId(), ZERO_COST); |
There was a problem hiding this comment.
Sorry, this is a total nit-pick but I want to avoid confusion: can you remove the word "reluctance" from the local variable name.
A reluctance is a cost that is proportional to the length of a leg. A penalty is applied only once.
There was a problem hiding this comment.
Good point! Actually, at some point, the idea was to apply unfererence per transit leg length and variable naming is leftover.
There was a problem hiding this comment.
To me the reluctance would actually be more useful, but I understand that you're just restoring the behaviour that was there before.
If I every have the need to unprefer routes I will implement the reluctance.
…outeCost linear cost function
|
As discussed in the developer meeting on 2022-06-28, I updated the fixed unpreference penalty to linear function ( |
| T trip, | ||
| RaptorTransferConstraint transferConstraints | ||
| ) { | ||
| return delegate.boardingCost( |
There was a problem hiding this comment.
Right now this is not possible with the LinearFunction but I'm wondering if we should add the static cost here and then the coefficient in onTripRelativeRidingCost.
I believe that this would lead to the unpreferred routes being pruned earlier in the search and not when alighting the vehicle.
Am I seeing this correctly, @hannesj ?
There was a problem hiding this comment.
This is a good question! As @t2gran pointed out earlier in #4238 (comment), fixed penalty could be applied in boardingCost. Also as discussed earlier, reluctance might be the natural choice for cost policy in most scenarios and thus the optimization around the static cost might not be relevant.
There was a problem hiding this comment.
We probably should extend, or create a new interface, which would support querying the fixed and variable parts of the function. This way we could split the calculation in two, and support multiple types of functions.
…into unprefer-routes
Codecov Report
@@ Coverage Diff @@
## dev-2.x #4238 +/- ##
=============================================
+ Coverage 56.87% 56.98% +0.11%
- Complexity 10555 10648 +93
=============================================
Files 1402 1415 +13
Lines 57118 57421 +303
Branches 6600 6624 +24
=============================================
+ Hits 32485 32721 +236
- Misses 22632 22699 +67
Partials 2001 2001
Continue to review full report at Codecov.
|
leonardehrenfried
left a comment
There was a problem hiding this comment.
At today's meeting we decided that we will postpone the decision on how to split the LinearFunction until @t2gran is back. @joonaojapalo has openend an issue for that.
The code here looks good so I will approve.
leonardehrenfried
left a comment
There was a problem hiding this comment.
I think the documentation has a mistake in it. Can you confirm @joonaojapalo ?
…i input field as constant penalty
Co-authored-by: Thomas Gran <t2gran@gmail.com>
Summary
Add support to define penalty cost for unpreferred routes by request parameter or by config file. In
router-config.jsonconfiguration file, routes are defined as list of feed scoped ids inroutingDefaults.unpreferred.routesand associated costroutingDefaults.unpreferredRouteCostas linear function. For example:{ "routingDefaults": { "unpreferredRouteCost": "300 + 2.0 x", "unpreferred": { "routes": ["HSL:2146A", "HSL:31M1"] } } }Issue
Related issue: #4199
Unit tests
Changelog
The changelog file
is generated from the pull-request title, make sure the title describe the feature or issue fixed.
To exclude the PR from the changelog add
[changelog skip]in the title.