Recost shortcuts in bidastar: first approach#2661
Recost shortcuts in bidastar: first approach#2661genadz wants to merge 9 commits intovalhalla:masterfrom
Conversation
5e2fcce to
c2e67fe
Compare
|
@kevinkreiser there are some open questions I wanted to discuss:
|
c2e67fe to
6042a6d
Compare
6042a6d to
a09ddc9
Compare
There was a problem hiding this comment.
Is recosting shortcuts something that could benefit all A-star algorithms? If so, could this be implemented on the base-class?
There was a problem hiding this comment.
I think yes, will check
There was a problem hiding this comment.
all A-start algorithms inherit from PathAlgorithm interface. as for me, it's too common in order to add recost_shortcut_forward to this interface. instead of that, I will define this function in a separate *.h file (in src/thor folder) that can be used by everyone
|
NOTE: right now shortcut speed equals to speed from the first superseded edge; so, if other superseded edges have different speeds -> after recosting we can get ETA significantly different from the base. this PR #2662 fixes it |
|
Could you add some gurka tests for this recovering of shortcuts? |
|
@purew we already have tests for recovering shortcuts i dotn think we need more just for that. but we do need them specifically for this. the main point here is that the final path doesnt have shortcuts in it. so it would be enough to make a gurka map that has shortcuts, get a route that takes a shortcut, set the constrained speed on the non shortcut edges to a known value that is substantially different than the shortcut and then check that:
|
|
@gena with respect to:
No, you dont need to recompute the transition cost for those as the value will be the same. |
There was a problem hiding this comment.
why make this change? its a bunch of extra allocation and a whole extra loop over the path. what does this give us other than a slightly clearer while loop below?
There was a problem hiding this comment.
unless there is a clear reason to do this, i would highly suggest we revert this to using the label index and labelset directly in the while loop as was done before
There was a problem hiding this comment.
oh i see in the comment hints at it. you are saying that we have to start at the beginning to get the correct cost? i'm not sure its actually true though. i wonder what kind of penalty this adds. i think we can work around it by looking one label ahead and using that label as the "previous cost" for the recosting of the shortcut to avoid all this allocation
There was a problem hiding this comment.
let's suppose we go from the end to the beginning (as before), and we already processed some edges: edge_n, edge_n-1, ...., edge_k and then meet shortcut and recost the edge - it means that costs for all edges from n to k will be invalid anymore (because costs for edges n, n-1, ..., k include shortcut cost that we've just changed) and we must shift all of them by difference we get after recosting.
If we implement this approach directly - it will require approximately n * (number of shortcuts) additional operations (change costs) - doesn't look reasonable. But, I just realized, we can optimize it a little: let's save all cost changes to stack (~ (number of shortcuts) additional memory) and apply these changes once on the second pass - in this case overhead will be num_of_shourctus additional memory (solution implemented now requires n additional memory, so make sense to rewrite). WDYT?
There was a problem hiding this comment.
as soon as this fails should we log and return?
There was a problem hiding this comment.
- On the one hand we already log errors in
RecoverShortcutmethod, but from the other we can treat recovering error as recosting error here and log it. - It might be reasonable not to continue because we already know shortcut cost and there is no need to call
recost_forwardfunction in such case.
There was a problem hiding this comment.
the last PathId stores boths the cost so far and the transition cost at the beginning of the PathID. so i think you might have the transition cost in the wrong place. i always confuse mysefl on this but thats whta it looks like to me here
There was a problem hiding this comment.
hm, didn't get this note. could you run the details ?
a09ddc9 to
d3ca6ee
Compare
af8def2 to
10e6563
Compare
|
Hello |
ecf25a1 to
80e4375
Compare
80e4375 to
4879d72
Compare
| // Terminate if the cost threshold has been exceeded. | ||
| if (fwd_pred.sortcost() + cost_diff_ > threshold_) { | ||
| return FormPath(graphreader, options, origin, destination); | ||
| return FormPath(graphreader, options, origin, destination, forward_time_info, invariant); |
There was a problem hiding this comment.
not sure if it's fully correct to consider only forward time and ignore reverse time:
- on the one hand we adjust times here https://github.com/valhalla/valhalla/blob/master/src/thor/route_action.cc#L409 and here https://github.com/valhalla/valhalla/blob/master/src/thor/route_action.cc#L512 ;
- but on the other hand we potentially can miss time restrictions in case we have predefined arrival time.
|
Implemented new approach here #2711 . @kevinkreiser we should compare and choose the best one |
hm, interesting note about subsequent shortcuts. I added unit test and it works) |
63f6f75 to
772b157
Compare
|
@genadz should we close this since we went with the other approach? |
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?