Repository navigation
Implementing turn costs - #238
Conversation
… vs. restriction, unit tests for most of the cases
|
Great. thanks! |
|
We need to reintroduce TRAVERSAL_MODE as there are at least 4 options with significant differences in speed and features. E.g. node_based, edge_based_1dir (supports turn restrictions, as fast as node-based), edge_based_2dir (two times slower but supports p-turns) and edge_based_2dir_uturn (~5 times slower with u-turn support). I'm still unsure whether we need u-turns in practice as they either produce ugly routes ('tricking' the turn restrictions) or when we put a penalty on them they won't occur. Also they make routing a lot slower as we have to disable the performance tweak (see above). Still they'd be useful on via points but that is a separate issue. |
…any as we need a more severe change
|
Hi Peter, I added a OneToManyDijkstraRef class that simply extends Dijkstra and it passes the DijkstraOneToManyTest with all traversal modes (not sure about performance though). The branch is here: https://github.com/brunesto/graphhopper/tree/turn_costs_1tomanyref . I am still fighting with git/github so I am not able yet to make a pull request though :( |
|
Sounds interesting. The finish condition is not entirely correct though. But yes, I thought about this same solution to make it easier for future changes and working with the QueryGraph. Still performance is crucial and has to be tested and possibly improved. |
|
I blindly implemented the missing methods for using OneToManyDijktraRef instead of OneToManyDijktra with CH and all current tests pass but it does not actually work. I encounter 2 problems (so far):
This problem can be hacked around by uncommenting tmpIter.isShortcut() on line 248 in LevelGraphStorage, which lets me move to the next problem.
|
|
Regarding 1), not sure about the exact reason, but maybe the branch issue_116 can help where we disabled the optimization and use the LevelFilter instead (currently 20% slower) Re 2) Yes, the edgeIds will be different. I've not thought about it yet. A related improvement could be done when the turn info is stored at the 'from edge' and not at the 'via node'. This way we can point to such the same turn information from an edge and all of its shortcuts (which is also an edge), no need for separate turn informations. |
|
I managed to get the CH working with turn restrictions but it is extremely slow. I have tried with the issue_116 which indeed fixes the disconnection of nodes, but it also slows down a lot. This simple test shows the speed difference: 100 routes in 1029 millis for master Please could you give me some assitance? I see 2 ways to go further, either to speed up the routing in issue_116 branch, or to confirm if the removal of the nodes is indeed a bug or is an expected behavior. Thanks |
|
The 'disconnect' is not a bug and expected behaviour. It is done to speed up things. We probably can implement turn costs with this limitation but it will be more complex so I have decided to avoid this optimization and accept the 25% slow down for now. There are some possible performance improvements possible as stated in #116 - see #240, some of them are simple like fixing the DFS bug, some not so.
Hmmh, I'll have to try this but for me I only see about 25% slower not >400% |
that is not sufficient you'll need to add the LevelEdgeFilter enabled as done in 116, as well as some other minor fixes. |
|
Hi Peter, I am still struggling to run CH with turn restrictions. I am running out of time, so I would like to ask you if you would consider merging the turn restrictions in the master branch even if it is not supported with CH? I am asking because our plan was to make a pull request for FYI here are the main steps which I have done so far: To handle TraversalMode.Edge2Dir: CH prepare does not disconnect edges anymore, instead they are flagged as non CH navigable. To handle turn restrictions: |
|
Why not use a separate branch where turn_costs is merged? Unfortunately I'll not have much time in the next weeks for this.
Is turn costs required for those features or why would it be necessary to wait? |
It is also possible to have a shortcut of shortcuts or mixed so the turn costs info should not use the skippedEdge. Instead I would make it possible to use one turn cost information for multiple edges. |
So I will prepare a branch to merge Turn restrictions into the master and then add DijkstraOneToManyRef to it.
Well it makes more sense for us to push for the turn restrictions first in the master, because |
I've now partially integrated turn restriction and turn cost. @khuebner already did most of the work - thanks a lot! You can enabled turn costs via
osmreader.acceptyWay=car|turnCosts=trueor in java vianew CarFlagEncoder(5, 5, /*maxTurnCost see below*/3).In order to do so I applied some changed which we should discuss:
prevOrNextEdgeIdinto Weighting.calcWeight. This avoids separate instanceof checks in all algorithmsif (!edgeBased && iter.getEdge() == prevOrNextEdgeId) return false;)The following things are on my to do list before we can merge this branch:
New issues: #269 and #270