Skip to content

Alternative routes with node-based CH - #1722

Merged
michaz merged 14 commits into
masterfrom
mz-alternative-ch-2
Jan 4, 2020
Merged

michaz merged 14 commits into
masterfrom
mz-alternative-ch-2

Conversation

@michaz

@michaz michaz commented Sep 10, 2019 •

Copy link
Copy Markdown
Member

So this is my attempt. Goal was to start with few moving parts, and finish with fewer. :-)

Note that this doesn't even use the existing AlternativeRoutes. This is really all the code there is.

Actually, the most hairy code in this class is stuff for walking backwards and forwards on Path because we don't have that as a utility.

The algorithm seems to be pretty "self-regulating" -- thanks to CH, candidates are already filtered down. So we don't have to check so many candidates. The share-factor is a very good filter criterion, so we don't even seem to really need a maximum number of paths here.

Screen Shot 2019-09-10 at 17 46 26

@easbar

easbar commented Sep 11, 2019

Copy link
Copy Markdown
Member

Cool! I def. agree that the Path class needs some thought. Especially because it is half algorithm (path extraction) and half a data/result type. I'll open an issue for this (started typing it earlier, but not finished yet).

The method used here is one that (in literature) predates the one used in #1524 ? What are the advantages/disadvantages of the two methods ?

@easbar

easbar commented Sep 13, 2019

Copy link
Copy Markdown
Member

For the path issues I opened #1727

@karussell

karussell commented Dec 24, 2019 •

Copy link
Copy Markdown
Member

I was going to merge master but the newly introduced tests fail:

[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.021 s <<< FAILURE! - in com.graphhopper.routing.AlternativeRouteCHTest

[ERROR] testCalcAlternatives2(com.graphhopper.routing.AlternativeRouteCHTest)  Time elapsed: 0.011 s  <<< FAILURE!
java.lang.AssertionError: expected:<3> but was:<1>
	at com.graphhopper.routing.AlternativeRouteCHTest.testCalcAlternatives2(AlternativeRouteCHTest.java:128)

[ERROR] testCalcAlternatives(com.graphhopper.routing.AlternativeRouteCHTest)  Time elapsed: 0.005 s  <<< FAILURE!
java.lang.AssertionError: expected:<2> but was:<1>
	at com.graphhopper.routing.AlternativeRouteCHTest.testCalcAlternatives(AlternativeRouteCHTest.java:98)

Is this a work in progress?

It would be cool to have it merged and later cherry pick a few features like the "motorway loop fix" from #1524.

@michaz

michaz commented Dec 29, 2019

Copy link
Copy Markdown
Member Author

Is this a work in progress?

Ah. Yes. I don't even know what I was trying to do there. I don't have a proper test case yet. Coming up.

@karussell karussell added this to the 1.0 milestone Dec 29, 2019
@michaz

michaz commented Jan 3, 2020

Copy link
Copy Markdown
Member Author

I would cautiously call this finished. Merge?

@michaz
michaz merged commit a947fe4 into master Jan 4, 2020
@michaz
michaz deleted the mz-alternative-ch-2 branch January 4, 2020 08:30
karussell added a commit that referenced this pull request Jan 4, 2020
return true;

// This gives us a path s -> v -> t, but since we are using contraction hierarchies,
// s -> v and v -> t need not be shortest paths. In fact, they can sometimes be pretty strange.

@karussell karussell Jan 6, 2020 •

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.

IMO it is not something special for CH that s -> v -> t is not a shortest path. Can we instead write something like

The path s -> v -> t is not the shortest way. Only s -> v and v -> t are.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, s -> v and v -> t are not shortest paths at that point, and that's the problem.

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.

Can you explain why this is the case? I do not understand why e.g. s -> v is not shortest although it was fetched from the bestWeightMapFrom.

@michaz michaz Jan 6, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because bestWeightMapFrom is the open set, not the shortest path tree. v is not necessarily closed yet, from either direction. You're right in that's also the case without CH, but with CH, those paths can get arbitrarily ugly because concatenations of shortcuts can be really circuitous routes.

@easbar easbar Jan 6, 2020 •

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.

Not only that. The CH fwd/bwd searches even settle nodes that are not reached via a shortest path. This is because the searches are restricted to only relax edges leading to higher (or equal) level nodes. This is also the reason why we can prune the searches with stall on demand. See e.g. ch. 3.5.2 here: https://algo2.iti.kit.edu/documents/routeplanning/geisberger_dipl.pdf.

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.

v is not necessarily closed yet, from either direction
...
The CH fwd/bwd searches even settle nodes that are not reached via a shortest path.

Ah, ok - thanks! I need to relearn some basics of GH and CH it seems :)

See e.g. ch. 3.5.2 here: https://algo2.iti.kit.edu/documents/routeplanning/geisberger_dipl.pdf.

Thx! BTW: for firefox this link works :)

https://algo2.iti.kit.edu/documents/routeplanning/geisberger_dipl.pdf#subsubsection.3.5.2

@michaz michaz Jan 6, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

BTW: for firefox this link works :)

>:-(

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.

>:-(

if this is a sad Emoji I have good news: it works for chrome too ;)

@karussell karussell Jan 6, 2020 •

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.

Currently the query speed is 50 times slower than the ordinary routingCH.mean metric, but there is room for improvement, e.g. this branch: https://github.com/graphhopper/graphhopper/compare/try_alt_ch_faster

For this branch and on our big map the speed up is even 6x and the routingCH_alt.alternative_rateis above 2. So it is basically just faster without "quality reduction" (I have no idea how to measure the real quality here, so I hope the count is a good indicator for the moment to analyze speed :) )

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants