You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Through the use of negative turn penalties, it's possible to return steps, legs or even entire routes that have negative durations.
Background:
Given the node map
"""
a b c d
"""
And the nodes
| node | id |
| a | 1 |
| b | 2 |
| c | 3 |
| d | 4 |
And the ways
| nodes | highway |
| ab | primary |
| bc | primary |
| bc | primary |
| cd | primary |
And the profile "testbot"
Scenario: negative route
Given the turn penalty file
"""
2,3,4,-70,0
"""
And the contract extra arguments "--turn-penalty-file {penalties_file}"
And the customize extra arguments "--turn-penalty-file {penalties_file}"
When I route I should get
| from | to | route | time |
| a | d | ab,bc,cd,cd | -10 |
I think this should be tightened up. I can't think of a use-case where a negative duration in the result would be desired.
Current implementation
Some observations about the current implementation:
There is one situation where negative durations are checked and clamped - the first edge in a route. See this comment for an example.
Proposed Fix
My suggestion is to implement the same negative penalty clamping for duration as is done for weight when performing traffic updates. This will prevent steps, legs and routes from having negative duration. It will also provide consistency with the duration clamping that already occurs on the first route edge.
Through the use of negative turn penalties, it's possible to return steps, legs or even entire routes that have negative durations.
I think this should be tightened up. I can't think of a use-case where a negative duration in the result would be desired.
Current implementation
Some observations about the current implementation:
It's not possible to set negative edge weights or edge durations via the traffic update mechanism, as negative values are treated as invalid.
Negative turn penalty weights are also clamped to ensure the total turn weight is non-negative. The same is not applied for negative durations.
At runtime, there is a check during route assembly for negative weights, but not durations.
There is one situation where negative durations are checked and clamped - the first edge in a route. See this comment for an example.
Proposed Fix
My suggestion is to implement the same negative penalty clamping for
duration
as is done forweight
when performing traffic updates. This will prevent steps, legs and routes from having negative duration. It will also provide consistency with the duration clamping that already occurs on the first route edge.Related
Negative turn penalty discussion - #3683
The text was updated successfully, but these errors were encountered: