[GraphHopper] How to consider traffic jam when route on road net
Philipp Hamm
Philipp.Hamm at Optitool.DE
Fri Jan 10 09:31:39 UTC 2014
Sorry, it should be ‘which must NOT overestimate the real costs’
Von: Philipp Hamm [mailto:Philipp.Hamm at Optitool.DE]
Gesendet: Freitag, 10. Januar 2014 10:27
An: GraphHopper Java routing engine
Betreff: Re: [GraphHopper] How to consider traffic jam when route on road net
> @Override
> public double getMinWeight(double distance) {
> return distance;
> }
this will probably cause big troubles using astar or astarbi algorithm, as it is used by the heuristic (which must overestimate the real cost).
so it should be distance/maxspeed for all fastest weightings.
regards,
philipp
Von: Alexander Cherepanov [mailto:lanmaster at hotmail.ru]
Gesendet: Freitag, 10. Januar 2014 07:38
An: Peter K
Cc: GraphHopper Java routing engine
Betreff: Re: [GraphHopper] How to consider traffic jam when route on road net
Hello, Peter!
Thank you very much!
I was try and it is ok.
Let me show for others people some code for example:
// somewhere in main() method (for example)
CmdArgs args1 = CmdArgs.readFromConfig("Cfg/Graphhopper.cfg", "graphhopper.config");
GraphHopper gh = new GraphHopperJam().forServer().init(args1);
gh.setEncodingManager(new EncodingManager("CAR"));
gh.importOrLoad();
GHRequest request = new GHRequest(56.833703,60.687447,56.777473,60.623331);
// there is our own weighting method selection
request.setWeighting("fastestjam"); // look here
GHResponse response = gh.route(request);
double res = response.getDistance();
// GraphHopperJam.java
public class GraphHopperJam extends GraphHopper {
protected Weighting createWeighting( String weighting, FlagEncoder encoder )
{
// ignore case
weighting = weighting.toLowerCase();
if ("shortest".equals(weighting))
return new ShortestWeighting();
if ("fastestjam".equals(weighting)) // look here, it is added for selectable our weighting class
return new FastestJamWeighting(); // our weighting class
return new FastestWeighting(encoder);
}
}
// FastestJamWeighting.java
public class FastestJamWeighting implements Weighting {
@Override
public double getMinWeight(double distance) {
return distance;
}
@Override
public double calcWeight(EdgeIteratorState edgeIter) {
return edgeIter.getDistance(); // It will be changed for our weight algorithm
}
@Override
public double revertWeight(EdgeIteratorState iter, double weight) {
return weight;
}
@Override
public String toString() {
return "FASTESTJAM|";
}
}
Чтв 09 Янв 2014 16:23:52 +0600, Peter K <peathal at yahoo.de<mailto:peathal at yahoo.de>> написал:
Hey,
if you don't use maven you'll have to add the dependencies explicitely. If you use maven it will download the dependencies you need and include it automatically into your project. IntelliJ and NetBeans are good in handling maven projects.
> but it would be very nice if we can use Graphhopper as library and extends
> or implements some classes/methods for our purposes (instead overwrite the Weighting)
with 'overwrite' I meant extending and 'overloading' the method. No need to change the sources for this.
Regards,
Peter.
Hello again!
Also it is hard to reuse source code...
I get 0.2 version, unpack folder "\graphhopper-0.2\core\src\main\java\com\graphhopper\" to my IntelliJ IDEA's project folder \project\src\com\graphhopper\
and I get import error in "InstructionList.java":
import gnu.trove.list.TDoubleList;
Where to get that code?
Why don't you include that sources to your project?
Пнд 06 Янв 2014 18:22:46 +0600, Peter K <peathal at yahoo.de><http://mail.qip.ru/compose/?adb_to=peathal@yahoo.de> написал:
Hi,
indeed: if you are updating the edges in real time you won't be able to use CH or you will have to prepare the graph again which is not real-time but okayish for country-sized data like Germany (<10min) and good for even big cities (<2min). Updating the already contracted graph is possible but complex and tedious.
If you maintain some mapping between OSM IDs (or GPS data) and the GraphHopper edge IDs this "update" process is easily implemented (and should be very fast) if you overwrite the Weighting (no changes necessary to the FlagEncoder I think) and return your own:
@Override
public double calcWeight( EdgeIteratorState edge ) {
return getWeightForID(edge.getEdge());
}
> Even when you know the Edge Id, you have to iterate over all Edges.
As Nicolas pointed out there is the getEdgeProps method, but I think extending "Weighting" should be sufficient.
> how to set this bitmask because I couldn't find any documentation on to flags itself.
Yes, again as Nicolas said (thanks btw :) !) there is no documentation but you can see the CarFlagEncoder class and its unit tests. Mainly the first two bits specifies the access (forward?, backward?) and then the speed as integer (but with low resolution - only 5km/h). You should increase the resolution if you have very precise real time data.
Regards,
Peter.
Hello,
It could work but I think that this will get the routing algorithm even slower.
Add this to the drop of contraction your performances would get really poor I’m afraid.
Nicolas GILLET
Market-IP –Creating Mobile Intelligence
Phone : +32 81 33 11 11
Fax : +32 81 33 11 10
www.market-ip.com<http://www.market-ip.com/> – www.telefleet.com<http://www.telefleet.com/> – www.geoplanning.net<http://www.geoplanning.net/> – www.drivexpert.net<http://www.drivexpert.net/>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
De : lanmaster at hotmail.ru [mailto:lanmaster at hotmail.ru]
Envoyé : lundi 6 janvier 2014 12:17
À : Nicolas Gillet
Cc : GraphHopper Java routing engine; Jrgen Zornig
Objet : Re: Re: [GraphHopper] How to consider traffic jam when route on road network<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Hello, Nicolas,
Why do I need to change any edge's weight?
My thought is about make no change in the graph data, but parallel calculate my own weights and use that in algorithm-place, where gets original Graph's weights.
May be my things was incorrect, please explain me.
Пнд 06 Янв 2014 16:05:06 +0500, Nicolas Gillet <nicolas.gillet at market-ip.com> написал:<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Hello guys,<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
That implementation won’t be efficient I think.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
First thing you must know about using real time weighting is that you won’t be able to use contractions hierarchies unless you re-contract the whole graph any time you change any edge’s weight.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Without contraction you’ll have a serious downgrade of performances.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
If you still want to perform real time weighting, the best option is to update the edge’s weight with your live traffic info, so updating the flags.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
> 1.) Which flags are included and which position they are set?
This depends on the flag encoders you use, check the CarFlagEncoder class.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
> 2.) Is there a convinient way to get a single EdgeIteratorState Object directly by poviding its ID?<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
If you know it’s GraphHopper’s ID, you can do graph.getEdgeProps(edgeId, Integer.MIN_VALUE) but you’ll have to maintain a way to link OSM ID’s with GH’s ids.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Regards,<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Nicolas GILLET<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Market-IP –Creating Mobile Intelligence<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Phone : +32 81 33 11 11 <http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Fax : +32 81 33 11 10<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
www.market-ip.com – www.telefleet.com – www.geoplanning.net – www.drivexpert.net <http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
De : lanmaster at hotmail.ru [mailto:lanmaster at hotmail.ru]
Envoyé : lundi 6 janvier 2014 11:47
À : Jrgen Zornig
Cc : GraphHopper Java routing engine
Objet : Re: [GraphHopper] How to consider traffic jam when route on road network?<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Hello, Jrgen!
I think about this implementation:
1. We have in-memory arraylist, that contains infos about traffic jam
2. We have function that can calculate weight of way by two coordinate pairs (from node / to node)
3. We have modification on Graphhopper's route calculate algorithm, that can request weight from our weight function (2) and summarize it with original Graphhopper's weight.
Can that implementation be useful, how do you think?
Пнд 06 Янв 2014 15:16:52 +0500, Jrgen Zornig <juergen.zornig at gmail.com> написал:<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
I am also trying to figure out how real time graph modifications and short and temporary events should be handled for the routing.
I assume you use to OSM graph? That makes things more complicated I think,because I have not found a function to retrieve a single Edge without iterating over and over the whole graph. Even when you know the Edge Id, you have to iterate over all Edges.
In our scenario, we use a different (our own) graph, and while loading it, I build up a HashMap for all EdgeIteratorState Objects I have generated during loading. So I can easily find a corresponding Edge for a given TrafficJam, either by directly referencing it over our EdgeIds or by finding out the Id via the LocationIndex (NodeIds and the referenced EdgeIds).
When having the corresponding EdgeIteratorState Object it should be simple to deactivate the Edge by calling setFlags(), but I also have no clue yet, how to set this bitmask because I couldn't find any documentation on to flags itself.
So I want to add to this question:
1.) Which flags are included and which position they are set?
2.) Is there a convinient way to get a single EdgeIteratorState Object directly by poviding its ID?
I am in need of these functions to handle real time traffic data on the graph.
P.S. Perhaps we can figure it out by ourselves, so Peter doesn't have to answer every single question ;)
Regards,
Juergen
Am 06.01.2014 09:54, schrieb lanmaster at hotmail.ru:<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Graphhopper is a project for finding routes over a road network. It also provides functionality for weighting this routing like fastest or shortest path e.g. via the FastestWeighting class. Now, the question is: how can we extend Graphhopper to use the speed data we get from our traffic provider in realtime?<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
As I can see:<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
1. We must create a function that gets traffic jam data from our database.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
2. We must force use that modified function (Encoder?) somewhere in Graphhopper route() function. Do I think right?<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
Please show me how we can do this by example.<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
_______________________________________________<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
GraphHopper mailing list<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
GraphHopper at openstreetmap.org<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
https://lists.openstreetmap.org/listinfo/graphhopper<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
_______________________________________________<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
GraphHopper mailing list<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
GraphHopper at openstreetmap.org<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
https://lists.openstreetmap.org/listinfo/graphhopper<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
--<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
--<http://www.linkedin.com/groups/MarketIP-4289716?gid=4289716&trk=hb_side_g>
-------------- n�chster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20140110/1e41a64d/attachment.html>
More information about the GraphHopper
mailing list