Repository navigation
Incorporate filter search into the finding of the closest node search. - #318
crowmagnumb wants to merge 3 commits into
Conversation
|
Hmmh, I don't understand your usecase. Can you give me an example of how you use this? E.g. You want to find the closest bus station(s) or something? Also we need tests for this feature otherwise your use case will be lost or broken when a new refactoring comes in. Furthermore I would prefer to avoid exploring within findNetworkEntries as this method is just about collecting nodes. So we need some kind of a loop over 'collect & explore & filter the edges' where the filter can also decide if the search should be stopped or not. |
|
Hmmh, you are holding more vehicles and location index returns earlier with only 'car edges' but you need e.g. 'bike edges'? |
|
Well, that is a pretty good example you just gave, and in a sense I am On Wed Feb 04 2015 at 1:09:21 PM Peter [email protected] wrote:
|
|
I'm not sure what you meant by that question about the car vs. bike edges. On Wed Feb 04 2015 at 1:20:10 PM Ken Southerland [email protected]
|
|
So what you want is the best tour for N points? And what you currently do is a heuristic solution to that problem, it is not optimial, right? |
|
It is absolutely not optimal because N can be as large as say 1000. i.e. very large. It is not possible in our lifetimes to find the optimal solution. What I find is a damn fine route that is pretty darn good. Optimal? No. |
|
And incorporating the explore in the find results in a much more efficient algorithm. If this is not the desired behavior for all cases (again, I really can't see why not, at least from the stand-point of the findClosest() routine) then I propose a separate routine for this. |
|
That heuristic should be good, yes. Still the LocationIndex is the wrong tool for what you want IMO. What you could do is to use Dijkstra with many destinations: QueryGraph qGraph = new QueryGraph(graph);
qGraph.lookup(yourLocations);
Dijkstra dijkstra = new Dijkstra(qGraph, encoder, weighting, TraversalMode.NODE_BASED) {
@Override protected boolean finished() {
// your condition e.g. a set of (virtual) nodes
}
};
// TODO currently not public
dijkstra.runAlgo();Or just calculate ALL distances between ALL locations and feed an optimization tool (for <10 you can do brute force search). Calculating all distances or times is easy and fast with our Matrix API but with plain GraphHopper and two simple for-loops that is often also acceptable fast. |
|
The problem with the LocationIndex and your usecase is that there is no order guaranteed, where Dijkstra guarantees that it visits the closer edges first. |
|
Still there might be indeed a problem if e.g. your graph contains car and bike streets, now you search for the closest bike street but the findNetworkEntries method returns only nodes exploring car streets (e.g. close to a motorway) |
|
It is not the routing problem I need solved. I have my routing problem and it's solved. What I wrote above was a great oversimplification of the problem, giving you just enough info necessary for this discussion. Telling me to use Dijkstra to solve my problem is missing the mark. But you keep getting glimpses of my problem. Your example of bike vs. car streets is exactly the same issue as I am having. If you use my version, that problem goes away. :) |
|
I've fixed this issue - see my new pull request: #488 Slightly more refactoring was necessary. It also should be faster on average now. @crowmagnumb if my new change is not working as expected in your case, please let me know! |
|
Thanks! Sorry I haven't had time to check as I've sinced changed jobs and have not been working on this for a while. If I get back to that, and some day I hope to, I will definitely check it out. Cheers. |
…pport dark mode, related to graphhopper#318
The problem is as I discussed about the filtering. It's not a question of does the expanded search find a node or not, it's does the expanded search find a node that passes my filter. Inside of findClosest the findNetworkEntries returns a set of node ids, then we loop through these nodes using the edge explorer and the supplied filter. The basic search does not find a node that passes my filter so findClosest returns a "null" QueryResult. If I try and expand the search further I still don't find my node because no matter what value of maxRegionSearch, findNetworkEntries returns the first set of nodes that it finds but I already know those don't pass my filter, so once again they don't pass my filter and I get a "null" result.
I've added the boolean to allow the filtering of the edges to be built into the search mechanism. I only added it to maintain backwards compatibility. I honestly don't see why this is not just done automatically.