Skip to content

Fix for #116: Make normal algorithms work on graph prepared for CH - #338

Closed
karussell wants to merge 23 commits into
masterfrom
issue_116_3
Closed

karussell wants to merge 23 commits into
masterfrom
issue_116_3

Conversation

@karussell

Copy link
Copy Markdown
Member

This pull requests fixes #116 and does the following

  • it allows executing normal algorithms on a prepared graph (using a shortcut filter, see BaseGraph and Graph.getBaseGraph), although doing so is slower than on unprepared as it needs to filter away the shortcuts. Separate list of traversal references for CH and normal edges #339 will fix this
  • the LevelEdgeFilter which was necessary before is now called more often (also for normal edges going downward levels) resulting in a slower routing and preparation for CH. This is roughly 18% and will also be fixed with Separate list of traversal references for CH and normal edges #339
  • multiple vehicles are allowed, but only one is prepared via CH (the graphHopper.setDefaultVehicle or algorithm.defaultVehicle or the lexicographically first vehicle in the graph.flagEncoders list)
  • as normal traversal is allowed on a prepared graph we can now calculate proper instructions, e.g. the roundabout instructions will work for CH too
  • the location index creation is done before preparation which removes the need to create an in-memory index before preparation to feed custom data

@karussell karussell added this to the 0.4 milestone Feb 25, 2015
@karussell karussell changed the title Fix 116 Make normal algorithms work on graph prepared for CH Fix for #116: Make normal algorithms work on graph prepared for CH Feb 25, 2015
@devemux86

Copy link
Copy Markdown
Contributor

Peter graph preparation seems more limited now.

By studying the PR I see in config-example.properties:
"Enable turn restrictions for car (Currently prepare.chWeighting=fastest is required, see below)"
What if we want to prepare non CH graphs with car TR and multiple vehicles?

Also the algorithm.defaultVehicle=car is needed only with CH, right?

@karussell

Copy link
Copy Markdown
Member Author

Graph preparation is not limited. But thanks, that is a mistake :) ! Turn restrictions is only possible for prepare.chWeighting=no

What if we want to prepare non CH graphs with car TR and multiple vehicles?

'preparation' is only done for CH.

@devemux86

Copy link
Copy Markdown
Contributor

Ok! I chose wrong word, by "prepare" I was meaning "build" graphs.

@karussell

Copy link
Copy Markdown
Member Author

Yes, thanks!

@karussell

Copy link
Copy Markdown
Member Author

@devemux86 would you check if you also get a dramatical slow down on your devices. I've an old device and seeing now a lot slower than before. Not sure if we should release with that now :(

@karussell

Copy link
Copy Markdown
Member Author

Or if I should fix #339 before .. hmmh

@karussell karussell closed this Feb 26, 2015
@devemux86

Copy link
Copy Markdown
Contributor

@karussell you mean with CH off ?
Sure just let me integrate the updated code.

@karussell

Copy link
Copy Markdown
Member Author

CH off should be unchanged. CH on will be very slow, still not sure why not only 20% ...

@devemux86

Copy link
Copy Markdown
Contributor

Ok I'll try CH with 1 vehicle.
With more than 1 vehicles the build fails with "Currently only one vehicle is supported if you enable CH".

@karussell

Copy link
Copy Markdown
Member Author

With more than 1 vehicles the build fails with "Currently only one vehicle is supported if you enable CH"

this should build and import with more vehicles, but only one vehicle (default vehicle) should be picked for CH

@devemux86

Copy link
Copy Markdown
Contributor

Yes I have studied the new code changes and the docs.
If I put algorithm.defaultVehicle=car in config properties then the build fails, e.g. for car,foot,bike2
If I omit it the build proceeds.

@karussell

Copy link
Copy Markdown
Member Author

oh, okay. will have a look

@devemux86

Copy link
Copy Markdown
Contributor

Ok your example (foot,car) and default car works.

For the record my settings that fail are:

graph.flagEncoders=car|turnCosts=true,foot,bike2
graph.bytesForFlags=8
graph.dataaccess=RAM_STORE
algorithm.defaultVehicle=car

and Elevation enabled for bike2

@devemux86

Copy link
Copy Markdown
Contributor

@devemux86 would you check if you also get a dramatical slow down on your devices. I've an old device and seeing now a lot slower than before. Not sure if we should release with that now :(

I have made some tests with CH, specifically on older devices and unfortunately you are right.
There are times that I cannot even distinguish when I have CH on or off :(

(Lately I prefer playing with CH off, as I find Bidirectional A* fast and of course able to use multiple vehicles, TR and elevation)

@karussell

Copy link
Copy Markdown
Member Author

@jansoe what do you mean?
@devemux86 okay, then we will delay and I'll have to fix the other issue :( ... hopefully it is nothing else somewhere hidden

as I find Bidirectional A* fast

how fast is it for, say a 300km route on a recent device? (I have only a 4 year old samsung ;))

BTW: elevation can be used with CH

@karussell

Copy link
Copy Markdown
Member Author

@devemux86 would you try to compare with a sorted graph? (or do you already have it enabled?) graph.doSort=true or hopper.setSortGraph

@devemux86

Copy link
Copy Markdown
Contributor

No I didn't used a sorted graph. I'll make more tests.

@devemux86

Copy link
Copy Markdown
Contributor

I tried that and with extremely large routes >500km and even on powerful mobiles (also on Atlas at pc) and I think (unless I'm doing something wrong!) that CH on / off states appear to me with similar performance (without certainly an observable difference).

@jansoe

jansoe commented Feb 26, 2015

Copy link
Copy Markdown
Contributor

sorry was in a rush, I just wanted to point to that exception I currently get, but don't yet fully understand.
https://github.com/graphhopper/graphhopper/blob/issue_116_3/core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java#L97
Will take a closer look tommorow.

@karussell

Copy link
Copy Markdown
Member Author

Ah, okay. Yes that is the same problem Emux has, will take a look.

@devemux86 thanks for the feedback! What is your best way to profile android apps on the device - simply include StopWatch or are there more efficient ways?

@devemux86

Copy link
Copy Markdown
Contributor

Eclipse has device monitors via ADT and AS has also some new monitors.
But for calculations speed I find often more convenient to just use counters like the one you mentioned.

@karussell

Copy link
Copy Markdown
Member Author

Okay, the problem is a simple one: levelFilter is null in PrepareContractionHierarchies.createAlgo IF the graph was already prepared and e.g. loaded from disc. If it was prepared and the routes are executes all was fine. So it occured on the Desktop too, will fix. Thanks @jansoe for pointing me to this!

@karussell

Copy link
Copy Markdown
Member Author

This speed anomaly is now documented and fixed in #349

@karussell

Copy link
Copy Markdown
Member Author

The other bug @devemux86 mentioned is now reported here #350 (will be fixed soon)

@karussell

Copy link
Copy Markdown
Member Author

Please let me know if this is working as expected (and only 20% or less slower), then we'll postpone #339 and release

@renauddl

renauddl commented Mar 2, 2015

Copy link
Copy Markdown

Hi Peter,

just curious to know:
Do you still remove higher to lower during the contraction when this
feature is activated?

@karussell

Copy link
Copy Markdown
Member Author

We disconnect higher to lower shortcuts and filter away higher to lower edges.

@karussell
karussell deleted the issue_116_3 branch March 3, 2015 15:10
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.

Make normal algorithms work on graph prepared for CH

4 participants