Skip to content

Add missing setup call - #2968

Merged
easbar merged 1 commit into
graphhopper:masterfrom
otbutz:otm_timeout
Apr 15, 2024
Merged

easbar merged 1 commit into
graphhopper:masterfrom
otbutz:otm_timeout

Conversation

@otbutz

@otbutz otbutz commented Apr 11, 2024

Copy link
Copy Markdown
Contributor

While DijkstraOneToMany evaluates the timeout, it's missing the setup.

@easbar

easbar commented Apr 11, 2024

Copy link
Copy Markdown
Member

I wonder if the timeout should be applied to each call of calcPath or rather like the weight limit for all such calls (because calcPath is supposed to be called multiple times here). Then again there is no init or similar method where it could be setup currently.

@otbutz

otbutz commented Apr 12, 2024

Copy link
Copy Markdown
Contributor Author

Currently we're sort of doing both? The visited nodes are reset on each call:

IMHO we should reset all limits per run. Enforcing them over multiple passes should be up to the caller.

@easbar

easbar commented Apr 12, 2024

Copy link
Copy Markdown
Member

I agree that the time limit should rather be used per call, because there might be unrelated things running in between the calcPath call that likely should be excluded from the time measurement. For the visited nodes and the maximum weight I think the global limits make sense, because the current weight and visited nodes can only increase from call to call anyway. Or do you have an actual use case for per-call limited weights and nodes?

@otbutz

otbutz commented Apr 12, 2024

Copy link
Copy Markdown
Contributor Author

I'm currently using DijkstraOneToMany to compute a distance matrix. While CH-based routing would be an order of magnitude faster, it's unfortunately not an option for my use case, which involves more dynamic custom models.

Global limits would have to scale with the number of destinations for which the algorithm instance is to be reused. The problem is that some destinations might simply not be reachable, and I don't want GraphHopper touching the whole graph to come to that conclusion. In the event that a limit is reached while calculating the path for a destination, I would still want to continue with the remaining destinations, which is not possible with a global limit in place.

@easbar

easbar commented Apr 12, 2024

Copy link
Copy Markdown
Member

In the event that a limit is reached while calculating the path for a destination, I would still want to continue with the remaining destinations, which is not possible with a global limit in place.

You mean if you are trying to calculate a path to node A which is only found at, say, weight=1000, and it isn't found because the limit is 100 for example you aren't able to find node B at weight 50? That shouldn't be of course. I think the way it should work is:

  1. start the search to some node, which grows the Dijkstra tree until it is found or the weight limit is reached
  2. search for another node. If it was discovered already return it, otherwise keep growing the tree (up to the weight limit if necessary)

This algorithm is basically left over from a previous CH preparation algorithm, so it is quite possible that it doesn't fit more general usages.

@otbutz

otbutz commented Apr 12, 2024

Copy link
Copy Markdown
Contributor Author

search for another node. If it was discovered already return it, otherwise keep growing the tree (up to the weight limit if necessary)

As long as paths for already discovered nodes are still returned even when the algorithm has reached one of its limits, it would be fine.

@easbar

easbar commented Apr 13, 2024

Copy link
Copy Markdown
Member

Ok, but you are saying this is currently not the case? Anyway as far as I am concerned we can merge this PR.

@otbutz

otbutz commented Apr 15, 2024

Copy link
Copy Markdown
Contributor Author

I think the current state is fine.

@easbar
easbar merged commit efce482 into graphhopper:master Apr 15, 2024
@karussell karussell added this to the 9.0 milestone Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants