Skip to content

Unique paths for pr - #579

Closed
boldtrn wants to merge 15 commits into
graphhopper:masterfrom
boldtrn:unique_paths_for_pr
Closed

boldtrn wants to merge 15 commits into
graphhopper:masterfrom
boldtrn:unique_paths_for_pr

Conversation

@boldtrn

@boldtrn boldtrn commented Nov 26, 2015

Copy link
Copy Markdown
Member

This PR contains the possibility to request unique paths.

This is possible by adding unique_paths=true to the request. Currently this only works with Dijkstra and the DijkstraBi.

Changed Min Bendiness to 1 again

Changed .sh

Changed Formatting

Fixed Formatting

Changed Curvature Parameters

Fixed the Tests

Fixed the Tests
@boldtrn
boldtrn force-pushed the unique_paths_for_pr branch 2 times, most recently from 7cc51cd to 26ada28 Compare November 26, 2015 13:43
@karussell

Copy link
Copy Markdown
Member

What are the advantages over a custom weighting?

@boldtrn

boldtrn commented Nov 27, 2015

Copy link
Copy Markdown
Member Author

The idea was to make it independant from the weighting. So that fastest, shortest, curvature, what ever works with unique paths. But I think adding it to the weighting seems natural.

How about extending the weighting interface so that additional weighting strategies can be defined (basically a strategy pattern). This would allow us to define additional strategies (or boosters/modifiers) for a given weighting.

A possible use case are the unique paths. Other usecases are possible as well. E.g. Consider current traffic situation.

@karussell

Copy link
Copy Markdown
Member

How about extending the weighting interface so that additional weighting strategies can
be defined (basically a strategy pattern). This would allow us to define additional
strategies (or boosters/modifiers) for a given weighting.

Yes, this is a good idea - I would avoid fiddling with the algorithms as it they are complex enough and we hopefully get more of them and tune them further.

We also need this more configurable Weighting stuff when we improve the flexibility (hopefully soonish), where we can post a profile via JSON etc. When I initially thought about it I think we provide a map (json struction) and grab certain properties for fast calculation in calcWeight but as this is not implemented I cannot say if it works reasonable (easy to use and fast). The problem with calcWeight is that it is potentially invoked millions of times per route (hundres&thousands of times only for CH) calculation and it needs to be very fast.

@boldtrn boldtrn mentioned this pull request Nov 29, 2015
@boldtrn

boldtrn commented Nov 30, 2015

Copy link
Copy Markdown
Member Author

@karussell I just added the Interface for the weighting strategy. What do you think? Are you happy with that architecture?

@boldtrn boldtrn mentioned this pull request Nov 30, 2015
@karussell

Copy link
Copy Markdown
Member

@karussell I just added the Interface for the weighting strategy. What do you think? Are you happy with that architecture?

Hmmh :) ... then the rest of the changes like in GraphHopper.java won't be necessary, right?

We really have to be careful here regarding performance and need a mechanism which adds no overhead. E.g. using the 'new' ;) for-loop pattern is slower than via indices. What do you think about the superWeighting mechanism instead (used for TurnWeighting)? One would have to measure the fastest and potentially refactor the TurnWeighting.

Still I think this has to be decoupled from this issue in the first place, maybe finally we can implement a simple AvoidEdgeIdWeightingStrategy or something, here?

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.

btw: lazy initialization here is not good as although calcPath is single threaded in core GH, this can change and others can have multi-threaded algos. A weighting should be seen as read-only.

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.

Yes I thought about it and thought that a null check is faster then querying size.

@karussell

Copy link
Copy Markdown
Member

One would have to measure the fastest

BTW: there is a simple procedure to measure if there is a difference:
./graphhopper.sh measurement your.pbf [count]
Where the count parameter can be omitted (implicit 1) or be e.g. 2 and then the current and the last commit are used to run the measurement or more commits of course are possible. This is a simple mechanism to compare performance for multiple commits.

@boldtrn

boldtrn commented Nov 30, 2015

Copy link
Copy Markdown
Member Author

Hmmh :) ... then the rest of the changes like in GraphHopper.java won't be necessary, right?

The changes in GraphHopper.java are still necessary. The issue is, calcWeight does not know if the edge was used or not. So you have to update, once a Path was created. (https://github.com/graphhopper/graphhopper/pull/579/files#diff-59d362881b641ff1b933a3785503c20eR1125)

When avoiding already explored edges, no path will be found (I tried that first).

What do you think about the superWeighting mechanism instead (used for TurnWeighting)

I thought about chaining weighting objects (this is basically the same as in TurnWeighting?). I chose this approach because I think it is more flexible and less magic is involved. But performance wise it is probably faster, especially if no modification is set.

@boldtrn

boldtrn commented Nov 30, 2015

Copy link
Copy Markdown
Member Author

@karussell I just thought about this issue. Probably something like the TurnWeighting makes more sense in this case, because we do not change anything if we only use a regular Weighting. I will change this PR accordingly.

@boldtrn
boldtrn force-pushed the unique_paths_for_pr branch 3 times, most recently from c672152 to 2dc9063 Compare November 30, 2015 14:40
@boldtrn

boldtrn commented Nov 30, 2015

Copy link
Copy Markdown
Member Author

@karussell My changes are pushed. I hope you like it.

Unfortunately I pulled from the graphhopper master and github shows all changes made including the ones from master.

@karussell

Copy link
Copy Markdown
Member

Unfortunately I pulled from the graphhopper master and github shows all changes made including the ones from master.

Hmmh, that is strange and hard to review, also merging this will lead to a confusing history - can you clone the latest master again and copy just the 3 files you changed?

As you have the abstract weighting class: I would either refactor the TurnWeighting to use the abstract class also there or remove the abstract class completely as all 'abstract' classes with just one implementation are a bit overhead :)
I do not like 'premature optimization' for code too, although I have to admit that GH is not 100% free of this ;)

@boldtrn
boldtrn force-pushed the unique_paths_for_pr branch from 2dc9063 to 4d9085c Compare November 30, 2015 15:05
Peter and others added 4 commits November 30, 2015 16:11
Added Unique Path Calculation, using a WeightWrapping Mechanismn

Added Weighting Strategy

Updated UniquePath calculation

Removed Already Visited Edges

Remove Old Class

Added Tests

Removed history
@boldtrn
boldtrn force-pushed the unique_paths_for_pr branch from 3d48905 to b6eccee Compare November 30, 2015 15:12
@boldtrn

boldtrn commented Nov 30, 2015

Copy link
Copy Markdown
Member Author

Ok, I will close this PR.

@boldtrn boldtrn closed this Nov 30, 2015
@boldtrn
boldtrn deleted the unique_paths_for_pr branch February 16, 2016 13:12
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

Successfully merging this pull request may close these issues.

4 participants