Skip to content

Do not create loop-edges - #1531

Merged
karussell merged 7 commits into
masterfrom
tmp2_1525
Jan 31, 2019
Merged

karussell merged 7 commits into
masterfrom
tmp2_1525

Conversation

@karussell

@karussell karussell commented Jan 29, 2019 •

Copy link
Copy Markdown
Member

This PR is the minimal change to fix #1525 (problems with edge-based algorithms). The fix avoids loop-edges from the import side. It is still possible to create loops via the Java API e.g. to attach properties like currently done in reader-gtfs.

With this PR no change needs to be done in DefaultEdgeFilter like it was necessary for #1247.

Do we need an explicit test that the OSM import results in no loop-edges?

Please note, the changes uncovered a bug in the landmark algorithm regarding the QueryGraph, which will be fixed in a separate issue. And so the test was slightly modified so that the original situation for #1014 was kept.

The other possible fix for #1525 is quite involved. Still, if results of the current fix make too many problems elsewhere, we'll have to go the more complex way, which requires a few more things:

  • the biggest change is to store the edge key in the SPTEntry, best would be if we can remove the edgeId to avoid increased memory usage for non-CH algorithms
  • introduction of graph.init(edgeKey)
  • make edge.detach working for loops too
  • the loop-edge needs to be returned twice on edgeIter.next() (note that the tried implementation in this PR has a bug if reverse=true from a previous edge state)
  • no changes in DefaultEdgeFilter are necessary

@karussell karussell added the bug label Jan 29, 2019
@karussell karussell added this to the 0.12 milestone Jan 29, 2019
@karussell
karussell requested a review from easbar January 29, 2019 12:28
Signed-off-by: easbar <[email protected]>

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@easbar

easbar commented Jan 30, 2019

Copy link
Copy Markdown
Member

It is still possible to create loops via the Java API e.g. to attach properties like currently done in reader-gtfs.

Maybe we can document this somewhere, e.g. in BaseGraph#edge(int, int) ? Or even print a warning (probably not because loops are needed for gtfs).

Do we need an explicit test that the OSM import results in no loop-edges?

Will do.

The other possible fix for #1525 is quite involved.

Good to keep this in mind, but probably shouldn't do this before #1447.

@easbar

easbar commented Jan 30, 2019 •

Copy link
Copy Markdown
Member

With this PR no change needs to be done in DefaultEdgeFilter like it was necessary for #1247.

I am not so sure about this. Even when we exclude loops in the OSM import there can still be loop shortcuts (for example the additional pillar node will be contracted right at the beginning, immediately creating a loop shortcut). The other thing I am a bit worried about is that I spent quite a bit of time to get CH work with loops and it might be a bad idea to remove the corresponding code and tests in case at a later time we would like to allow loops again. Is there any reason not to use the current version of DefaultEdgeFilter in master ? With this PR all tests in turncost_ch just passed on my laptop, except
GraphHopperGeocodingIT#testForwardGeocodingNominatim failed with java.net.SocketTimeoutException` (also fails here, probably another issue?).

@karussell

Copy link
Copy Markdown
Member Author

Thanks!

Maybe we can document this somewhere, e.g. in BaseGraph#edge(int, int) ?

Good idea!

Do we need an explicit test that the OSM import results in no loop-edges?
Will do.
Thanks!

The other thing I am a bit worried about is that I spent quite a bit of time to get CH work with loops and it might be a bad idea to remove the corresponding code and tests in case at a later time we would like to allow loops again

Couldn't we somehow inject the tweaked EdgeFilter for these tests? Or how many tests will fail? (As those tests are still in git they wouldn't be 'lost'.)

The only problem I have with this code in the default filter is that it feels a bit dirty (as it is not necessary now)

With this PR all tests in turncost_ch just passed on my laptop, except GraphHopperGeocodingIT#testForwardGeocodingNominatim failed with java.net.SocketTimeoutException` (also fails here, probably another issue?)

Uhm, yes. Unrelated & should be fixed.

@karussell

Copy link
Copy Markdown
Member Author

(As those tests are still in git they wouldn't be 'lost'.)

To make sure they are really preserved (and in master to make them easy to find), we could merge the turn cost branch with the tweaked DefaultEdgeFilter, then remove the tweak and also all failing tests.

@easbar

easbar commented Jan 30, 2019

Copy link
Copy Markdown
Member

Even when we exclude loops in the OSM import there can still be loop shortcuts

This is the real issue here, see be4e6cc#diff-094ce488919a6ffa3ad06adbc7df7213R409

There will always be loop shortcuts and the backward search can be blocked by them so no shortest path is found.

To make sure they are really preserved (and in master to make them easy to find), we could merge the turn cost branch with the tweaked DefaultEdgeFilter, then remove the tweak and also all failing tests.

Yes, this is a good idea would be good to have these changes in one commit, but like I said the real problem is that the routing does not work without the changes in the filter at the moment even with the fixed OSM import. One possibility would be to apply the special condition in the filter only on loop-shortcuts, but this would probably be even dirtier ;)

@easbar

easbar commented Jan 30, 2019

Copy link
Copy Markdown
Member

Btw the shortcut in this test is 'forward' because all shortcuts in edge-based CH are unidirectional (forward only) at the moment. Maybe (but just maybe, no idea atm) another solution would be to set all loop shortcuts fwd&bwd.

@karussell

Copy link
Copy Markdown
Member Author

One possibility would be to apply the special condition in the filter only on loop-shortcuts, but this would probably be even dirtier ;)

Got it :) ... so yes, we need the special tweak in the EdgeFilter.

Maybe (but just maybe, no idea atm) another solution would be to set all loop shortcuts fwd&bwd.

It will likely still break if we read properties in the wrong direction. Now I think this can be only fixed without the tweaked EdgeFilter with the more involved changes described above.

@karussell
karussell merged commit dce2543 into master Jan 31, 2019
@karussell
karussell deleted the tmp2_1525 branch January 31, 2019 16:54
@karussell

karussell commented Jan 31, 2019 •

Copy link
Copy Markdown
Member Author

@easbar Uhm, sorry, this is unsatisfying: I merged the PR via squashing to have just one commit and the commit contains "Signed-off-by: <name+email>" (as you can see via git log) but still your work does not appear via the icon.

It looks like we have to do "Co-authored-by: <name+email>" instead, which is a bit unusual:

https://help.github.com/articles/creating-a-commit-with-multiple-authors/

@easbar

easbar commented Jan 31, 2019

Copy link
Copy Markdown
Member

Ok no worries :)

@spalsher

Copy link
Copy Markdown

it not generating 'Names' file after running the script. Please help, i have tried maps from different countries but same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backward-only loops make problems with edge-based routing.

3 participants