Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for routing across different sets of files #2599

Closed
georgevanvenrooij opened this issue Jun 28, 2016 · 10 comments
Closed

Support for routing across different sets of files #2599

georgevanvenrooij opened this issue Jun 28, 2016 · 10 comments

Comments

@georgevanvenrooij
Copy link

I have been trying to figure out if it is possible to generate separate OSRM files for geographically distinct regions (neighboring countries, for example) and then load them for use as a single set.

So for example: first generate a set for Germany and a separate one for France, but at run-time point OSRM to both sets of files and have it route correctly across the border.

The purpose of this would be to use OSRM on client machines and update only parts of the database over time, instead of requiring users to always download a full set.

Is this something the library could support without too much effort or does it require a custom layer of code partitioning the route across the regions and stitching them together again?

@daniel-j-h
Copy link
Member

It is not possible to merge .osrm* files.
There are tools out there for cutting and merging OSM extract, though.

But keep in mind you might run into issues like the following:

http://map.project-osrm.org/?z=8&center=49.694285%2C7.904663&loc=50.095917%2C6.350098&loc=49.310799%2C5.243225&hl=en&alt=0

Here a route from Germany to France takes you through Luxembourg (and the alternative takes you through Belgium). This works on the demo server, as we route on the whole planet. If you route on your Germany-France extract only, the "shortest route" will do a detour because you're forcing it to stay in the Germany-France extract (and now it's not be the actual shortest route anymore).

Here is a way to dynamically update edge weights:
https://github.com/Project-OSRM/osrm-backend/wiki/Traffic

There is currently no way to dynamically update the graph as in bringing in new changesets, though.

@MoKob
Copy link

MoKob commented Jun 28, 2016

While it might be possible to adjust the extracting process in a way that serves your purpose (which itself might not be easy at all), the preprocessing phase (osrm-contract) has to run on the full set by default.

You could consider leaving the border vertices of region out of you contraction, so for region_1 - (set of connections) - region_2, you would only contract vertices that are in region_1 or region_2 but not the border vertices.

Doing so, you could still route on subsets of the graph and even correctly between regions. You will suffer a slowdown of the query, though and the contraction order might result in worse results, since it is restricted in its operation.
Country-borders might also not be the optimal choice for separation which could result in difficult to handle sizes...
All in all, without serious adjustments such a separation is not possible.

@georgevanvenrooij
Copy link
Author

Thanks for the insights. I mentioned the Germany-France example only as an example. The actual case I'm investigating is using a regular grid of tiles where I would like the option of regenerating one or more tiles for updated data, or expanding an existing set with new tiles and having the routing engine work across the union of tiles.

Looking at the algorithm behind OSRM and some of the file structures, it looks like it could be theoretically possible to generate a full set but distribute parts of it that then match up again when multiple parts are combined, because of its hierarchical nature.

@MoKob
Copy link

MoKob commented Jun 28, 2016

@georgevanvenrooij well, technically it is possible. The tiling approach will require immense amounts of memory if you end up with a lot of connections between the borders. The algorithm behind OSRM will essentially create square matrices in between these connections.

The approach has been done in the literature and we aim to implement something similar in the future. A naive approach will not work, though.

@daniel-j-h
Copy link
Member

Just out of interest, do you want to use OSRM in a game engine? :) Because it starts to sound like it.

@georgevanvenrooij
Copy link
Author

@daniel-j-h that is indeed the case, we're developing a custom engine for a game and OSRM is a candidate library that we are considering to use for routing queries along a road network.

@MoKob
Copy link

MoKob commented Jun 28, 2016

@georgevanvenrooij in case of a game engine, the number of borders might be small enough for your ideas to work. The speed-up over basic algorithms in these cases will be far smaller than on a large continental road network.
Whether it works depends on the structure of the network and the size of your network and how structured it is. If many paths have similar length, or if there is a clear hierarchy.

@georgevanvenrooij
Copy link
Author

georgevanvenrooij commented Jun 28, 2016

@MoKob in our case the road network is actually based on real-world road networks, so the complexity and density of the roads is very similar.

One of the reasons for investigating OSRM is its speed, since we want to be able to determine routes for thousands of agents in a reasonable amount of time. Because of the setting chosen for the game (WW2 strategy), we can get away with less-than-optimal routes, simplified lua profiles and we don't require the entire world but still some big parts of it. It would be nice if distributing the database in parts would be possible, instead of requiring users the download the full database every time there is some kind of update.

Being a game, we can probably get away with cutting up query routes at tile borders ourselves, submitting the tiled pieces to separate library instances and then connecting the results at the borders, even if this generates sub-optimal results. That seems to be the easiest way forward if distributing one large database becomes an issue, although I have a feeling something more elegant should be possible by exploiting the hierarchical aspect of the algorithm, but I'm no expert on this matter.

Is the literature you mentioned available online somewhere? I'd love to read more about it.

@MoKob
Copy link

MoKob commented Jun 28, 2016

@georgevanvenrooij there is quite the bit of research available (often also publicly). A good starting point is this TR, a survey paper by some of my former colleagues.

In general I would recommend reading on customizable contraction hierarchies and multi-level Dijkstra. Especially multi-level Dijkstra could be interesting for your goals. It would require a larger investment of engineering on you end, since I know of no open source project using any of these techniques.

There is also some work on performing updates for MLD on a GPU very fast. The list of publications is endless.

@MoKob
Copy link

MoKob commented Jun 29, 2016

Closing here. Nothing actionable. Feel free to re-open if you should have follow-up questions.

@MoKob MoKob closed this as completed Jun 29, 2016
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

No branches or pull requests

3 participants