Repository navigation
Do not consider turn cost support of other encoders when selecting traversal mode - #1705
Conversation
|
I think the thing that now bothers me the most is the asymmetry between CH and non-CH: For CH we always use node-based unless |
|
|
||
| TraversalMode tMode = encoder.supports(TurnWeighting.class) ? TraversalMode.EDGE_BASED : TraversalMode.NODE_BASED; | ||
|
|
||
| String tModeStr = hints.get("traversal_mode", tMode.toString()); |
There was a problem hiding this comment.
Can I remove this traversal_mode parameter to avoid further confusion ? Right now it almost does the same as the edge_based parameter and I did not find documentation for it anywhere ?
|
Should we add this to changes file and mention that edge_base parameter is/was equivalent? |
|
Hmmh, this PR is actually a breaking change for all users that do not yet support edge-based routing for CH but have turn_costs enabled. |
is it ? in which case ? note that for CH selection we only look at the edge_based request parameter currently (and not at the |
|
Maybe I have misunderstood something :D Assume I have one vehicle car with turn costs and I have (node-based) CH enabled. (1) Then request from A to B is per CH (node based) and (2) if I disable CH it is edge based with turn costs. Not intuitive, yes. But this was the best we could do for a long time :) Now, with this change, wouldn't the case (1) fail as the edge based algorithm is selected for CH? And it succeeds only if an additional parameter edge_based=false is specified? |
No, I do not think so, but let me add a test to make sure. This of course is an important case. |
|
Is this the case you had in mind ? c458149 I think it is fine. Why ? Because |
|
Build failed with A[PI limit reached. Reset in 14699 seconds]>anyway, I will re-trigger it again tomorrow |
|
@michaz the graphHopper.getEncodingManager().needsTurnCostsSupport() ? TraversalMode.EDGE_BASED : TraversalMode.NODE_BASED?! Also added this to changelog |
|
Yes! Thank you! In MapMatching, I would also be happy with just always using EDGE_BASED, if it can do strictly more than NODE_BASED. The less combinatorics, the better. That's why I was so sad at the idea that I could get an exception by choosing EDGE_BASED if some part further down thinks I don't need EDGE_BASED. |
unfortunately not yet: heading (discussion in #1697), alternative routes (#1524), block edges/areas + its slower and most of all uses a lot more memory (especially for planet-wide)
I can tell ...
Well if you choose edge_based but the server is not prepared for it its better to get a warning than not ? But I also agree with your kind of thinking (choose behavior not algorithm) so if you choose turn_costs you should not get a warning (just a slow algorithm...) |
|
Sometimes I think half of the configuration confusion (not the implementation limitations) is "just" because a handful of things are historically inside-out or the wrong way round. Like Alternatives: It's not only a different "algorithm", it's a different question to ask. On that layer, it has as little to do with regular shortest-path routing as map-matching. I think the implementation of Alternatives should just use node-based routing if it knows it can't do it differently. And not rely on the outer layer to find out for it that node-based can't be configured when Alternatives is configured. Maybe one day, a "Grand Redesign in the Sky" [Clean Code]. (Or maybe not, because I think most people think that almost always goes wrong.) |
|
EDIT:
|
|
Regarding combinatorics, look at this: This is already starting to explode (and the more flexible everything shall become the worse it is going to get). Right now the only way I see out of this mess is to:
So eventually we would first get a 'wish-list' from the user, then scan the available (CH) profiles and check if there is one that supports everything that was requested by the user. If there is no such profile fall back to some non-CH algorithm that supports everything. However, we still might need some low-level flags for debugging/testing etc. like ('do not fall back to dijkstra', 'enforce this algorithm' etc.) |
I do not know the details of the alternative route implementations, but yes sometimes this might be the problem. Identifying the places where this confusion arises will sure help. |
I think we should try to improve the current state rather than doing this, but for the flexible CH scenario we are still at the very beginning so its good to think about what would be 'ideal' (and then check how far this is from the current state). |
|
To get this to a point where we say "that's it!" would be a major project, including finding a terminology that we all agree on. To me, "profile" means "cost function", i.e. "how much does a path cost, including everything", i.e. "what is the thing I want to minimize over all paths". So it defines things like turn-costs, U-turn restrictions, other hard constraints, everything. Together with input points, headings etc., it's the optimization problem to solve. (Not to be confused with "optimization" as in tour planning.) That's almost the same as your |
|
And then there's an Algorithm, which is a solver for the optimization problem E.g. if the Profile has turn costs, and turn costs don't work with CHNodeBased, then CHNodeBased doesn't support that profile (not the other way round). The fastest Algorithm that supports what the Profile requires should be used. And it should be selected at startup time, not at query time, because the Algorithm knows what it needs to prepare to support the profile. Also, at startup time, it can be determined what prepared data can be shared between profiles. |
Yes, I think so. And the reason for this is that almost everything that defines a 'profile' needs to be known at preparation time (for CH). For me a CHProfile is the set of conditions that I fixed when I ran the preparation.
Yes when a request comes in it defines the/your 'profile', then we have to check if there is a ch-profile that matches it, otherwise we cannot use CH |
|
Nice. Almost there then. |
|
But can't this be simplified enormously if we just give every profile that a GraphHopper instance supports (not only every CHProfile; every profile) a name in the configuration file? Then, at start time, we prepare the best thing that we can prepare for that profile(*), remember to use it, and that's it? (* maybe the profile can override at configuration time (but not at query time) what algorithm it wants to be solved by) |
And then at the totally outermost layer, like in the web service, we pick one of these based on the query parameters. Or if we really want to over-engineer, put the rules for mapping query params to profile names in the config file. But for ourselves, we can just use the profile name directly in the query, and it's still "problem, not process". |
|
Perhaps the secret blocker here has been that we don't have hierarchical configuration files in the core yet. |
Yes, thanks! Perfect! |
|
Hmm, many questions about profile configuration here :) Closing this here, maybe we can continue in issues dedicated to the discussion about the configuration etc. ? For example I opened #1708. |
@michaz The issue I am having with this is that the profiles may contain parameters. For example the Even if we gave a name to every profile (which otherwise sounds very promising to me) the difficulty would still be mapping the requests onto these profiles. Sure, at first sight this seems easy: As @karussell suggested we could maintain the order of the profiles and if for example
I like the idea of moving this to the outermost layer, but doing the mapping (and this seems like the real problem to me) does not become easier this way (in fact I think it might be harder to do it like that because there might be less information about the profiles at this point?). Maybe we can even remove all the request parameters that (together) make up the routing profile (currently vehicle,weighting,turn_costs,u_turn_costs) and replace them with a single |
This is supposed to be a minimal fix to #1698.
Instead of deriving an 'overall' default traversal mode for all encoders every request checks whether or not the selected encoder supports turn costs and selects the traversal mode based on this (in case no edge_based parameter is sent along with the request).
Fixes #1698, but also related to #1637 and #1702.