Skip to content

Reduce TraversalModes to edge- and node-based. #1520

Closed

Description

@easbar

See discussion in #1247.

Activity

  1. easbar commented on May 3, 2019

    @easbar
    MemberAuthor

    What about TraversalMode.EDGE_BASED_1DIR ? Does it have any valid use-case ? It does edge-based routing, but does not differentiate between the two possible directions an edge (identified by its ID) is encountered (so it only uses one 'state' for each edge (instead of two), thats the 1DIR part of the name). It can model turn restrictions and costs, but for example it cannot find a path with a p-turn. The javadocs say that it is

    Strictly not recommended as it could lead to 'route not found' for bidirectional algorithms.
    

    I think if there is a required p-turn it can also lead to route not found for standard Dijkstra ? On the other hand according to the javadocs it is

    As fast as node-based
    

    Would be interesting to know if anybody is actively using TraversalMode.EDGE_BASED_1DIR and for which purpose ?

  2. karussell commented on May 3, 2019

    @karussell
    Member

    On the other hand according to the javadocs it is

    Yes, 1DIR is really nice but only theoretically. I think in practise the only good solution for edge-based algorithm is bidirectional landmarks with 2DIR. IMO we can remove two of the four modes.

  3. easbar commented on May 25, 2019

    @easbar
    MemberAuthor

    Ok, TraversalMode.EDGE_BASED_1DIR was removed with #1606. Next one on the list will be TraversalMode.EDGE_BASED_2DIR_UTURN and then we can eventually rename EDGE_BASED_2DIR to EDGE_BASED. I think removing the u-turn mode is mostly about removing/replacing TraversalMode#hasUTurnSupport. Instead of checking something like

    if (traversalMode.hasUTurnSupport() && edgeA==edgeB)
    

    or

    if (traversalMode.hasUTurnSupport() && turnCostExtension.isUTurn(edgeA, edgeB)
    

    we should just 'calculate' the turn costs and by default return infinity if edgeA==edgeB or turnCostExtension.isUTurn(edgeA, edgeB). @karussell do you remember why this was not done like this from the beginning ? I never understood why instead these explicit u-turn checks were introduced. Maybe I am missing something here ? If one wants to enable/allow u-turns (possibly only under certain conditions, like smaller roads etc.) it would still be possible to do this in the calcTurnWeight method (and this would probably be even more flexible than explicit u-turn checks within the algorithms).

    Actually I am thinking about deprecating and/or removing TurnWeighting completely and as a replacement adding a calcTurnWeight method to Weighting (probably with a default implementation in AbstractWeighting). There are a few cases where we only want to calculate the turn costs (NOT edge costs plus turn costs), this was already mentioned in #269. Therefore I think the focus should be on a calcTurnWeight(inEdge, viaNode, outEdge) method instead of calcWeight(edgeState, reverse, prevOrNextEdgeId), but of course we can keep the latter as a convenience method that uses the other one. Similar would be a calcTurnTime method. I guess we have to start doing this refactoring a bit to fully become aware of all of its implications.

    Regarding TurnWeighting there are quite a few related issues:

  4. karussell commented on May 26, 2019

    @karussell
    Member

    I never understood why instead these explicit u-turn checks were introduced. Maybe I am missing something here ?

    I do not now. Maybe this is still an artifact from the early days somehow where turn costs were under development. Another reason could be a faster decision? Isn't the current procedure to always call calcWeight and then calcTurnWeight - i.e. the first call would be unnecessary in case of an infinite turn weight? But I think we can just swap this order and also have this optimization not only for U-turns.

    BTW: I'm still not sure if we really need calcTurnWeight. I know we already discussed this in

    #1586 (review) and #1590 (comment)

    but I'm unsure what to do now. Personally I would prefer to just have one method calcTurnTime if no difference is necessary.

    but of course we can keep the latter as a convenience method that uses the other one

    I have no preference

    Regarding TurnWeighting there are quite a few related issues:

    Would these 3 issues still exist if the calcTurnWeight/Time is within the Weighting?

  5. easbar commented on May 27, 2019

    @easbar
    MemberAuthor

    Another reason could be a faster decision?

    Ah good point. Yes it might be better to first calculate the turn costs, but not sure if this plays a big role and pretty sure we can apply such optimization on a lower level.

    I'm still not sure if we really need calcTurnWeight.

    Yes, good question. I think it would make sense to have a convention that 'turn weight' is always measured in time-units. If this is so we can use it for both weight- and time-calculation. For weightings that are not based on time (like curvature, energy, shortest weighting, or shortestfastestweighting) one would have to use some conversion factor that balances the edge-weight with the turn-weight contributions.
    Or in other words I think we do not need calcTurnWeight. Let's just use calcTurnTime and how this contributes to a given weighting is up to the author of the weighting.

    However, we should not have to add edge-weights to turn-times, this would look confusing:

    double weight = weighting.calcWeight(edgeState, reverse) + weighting.calcTurnTime(inEdge, viaNode, outEdge);

    So maybe still call it calcTurnWeight but make it clear that it returns a value measured in time-units ?

    I have no preference

    I was wondering how many times we will do something like this:

    double turnWeight = weighting.calcTurnWeight(inEdge, viaNode, outEdge);
    if (Double.isInfinite(turnWeight) {
     // early exit optimization mentioned above
    }
    double edgeWeight = weighting.calcWeight(...);
    double weight = edgeWeight + turnWeight;

    and to prevent this having something like weighting.calcWeight(edge, reverse, prevOrNext) still makes sense I guess.

    Would these 3 issues still exist if the calcTurnWeight/Time is within the Weighting?

    No I think they would be solved, except the one with the loop-case. That one we could probably deal with at a central place in calcTurnWeight/Time and further loop-related changes (also mentioned in #1611) should go with another issue.

  6. easbar commented on May 27, 2019

    @easbar
    MemberAuthor

    Oh, I think I have to correct myself here: I was only thinking about the case where we calculate edgeWeight+turnWeight. If this is encapsulated in a calcWeight method in Weighting sure we can take the turn time and add it to the total weight with whatever conversion factor we like (for example when thinking about how much turn times should contribute to curvature weighting etc.). But what about the cases where calcTurnWeight/Time is called in isolation (for example at the meeting point of a bidirectional search). In this case we would only be left with calcTurnTime and the conversion would not be specific to the weighting. So now I am back to thinking we do need calcTurnTime and calcTurnWeight.

  7. karussell commented on May 27, 2019

    @karussell
    Member

    However, we should not have to add edge-weights to turn-times, this would look confusing:
    So maybe still call it calcTurnWeight but make it clear that it returns a value measured in time-units ?

    This is a good argument :) ... still we would have to do the same for the time: calcMillis = time + calcTurnWeight? So maybe we have to live with two methods? (or calcTurnWeightInMillis ;) just joking!)

    So now I am back to thinking we do need calcTurnTime and calcTurnWeight.

    👍

    and to prevent this having something like weighting.calcWeight(edge, reverse, prevOrNext) still makes sense I guess.

    This is true 👍

  8. easbar commented on Jun 27, 2019

    @easbar
    MemberAuthor

    Update: the u-turn mode has been removed in #1640 and the TraversalModes are now reduced to NODE_BASED and EDGE_BASED.

    Leaving this open for now because of the issue about moving calcTurnWeight/Time to Weighting.

  9. easbar commented on Dec 9, 2019

    @easbar
    MemberAuthor

    Closing in favor of #1820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions