Skip to content

Take slowdown and accelerating into account #334

Closed as not planned
Closed as not planned

Description

@zach-m

Thanks for contributing this awesome library.

It is quite noticeable however, that unlike distance calculations - which are very accurate - the time calculations for routes are always underestimated.

I saw that in the function com.graphhopper.routing.Path.calcMillis() it is simply assumed that the driving on each edge occurs at a constant speed equal to the speed limit.

Even before accounting for traffic lights, stop signs, etc. this can be much improved by simply adding acceleration and deceleration phases around each turn, and by imposing some rigid bound on the vehicle speed when making the turn.

Is this planned for the near future?
If not, it would be nice to leave a hook (or allow subclassing) for substituting the default calculation of the millis with a custom one.

Thx
Zach

Activity

  1. karussell commented on Feb 18, 2015

    @karussell
    Member

    Not really, as we already reduce the maxspeed which has similar effects although of course not the same. This will be improved mainly via #230

  2. zach-m commented on Feb 18, 2015

    @zach-m
    Author

    Correct me if I'm wrong, but changing the weighting affects how the best route is assembled, but doesn't change the value returned by Path.getMillis() or GHResponse.getMillis(), doesn't it?

  3. karussell commented on Feb 18, 2015

    @karussell
    Member

    Ups, my fault!

    Indeed, currently there is no way to change this calculation in a post-processing step. The turn calculation is also currently not used to influence this time. We can think about something like that but before we fix other problems like #230

  4. karussell commented on Feb 18, 2015

    @karussell
    Member

    What you can do as a workaround for cities (as I see from your repo :)) is that you can reduce the default speeds. E.g. for car: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/CarFlagEncoder.java#L104

  5. zach-m commented on Feb 23, 2015

    @zach-m
    Author

    I took your advice for now, although I think it would be best to account for slowdown factors (turning time, stop signs and traffic lights) in the getMillis() functions. What I did is simply reducing the estimated speed on all edges, and now I'm getting more realistic results.

    // can be used with CarFlagEncoder instead; requires rebuild of the graph db
    final MotorcycleFlagEncoder slowerMotorcycleEncoder = new MotorcycleFlagEncoder("speedBits=6|speedFactor=2")
    {
        private static final double SLOWDOWN_FACTOR = 0.55;
    
        @Override
        public long handleWayTags(OSMWay way, long allowed, long relationFlags)
        {
            long encoded = super.handleWayTags(way, allowed, relationFlags);
            encoded = setSpeed(encoded, getSpeed(encoded) * SLOWDOWN_FACTOR);
            encoded = setReverseSpeed(encoded, getReverseSpeed(encoded) * SLOWDOWN_FACTOR);
            return encoded;
        }
    };
    
    final GraphHopper gh = new GraphHopper()
        .setEncodingManager(new EncodingManager(slowerMotorcycleEncoder))
        ...
    ;
    
  6. karussell commented on Mar 24, 2015

    @karussell
    Member

    Hey, would you mind to add 2 or 3 expected times (e.g. from your experience) with graphhopper maps links?

  7. changed the title [-]Time estimates for routes are unrealistic[/-] [+]Take slowdown and accelerating into account[/+] on Mar 24, 2015
  8. zach-m commented on Mar 25, 2015

    @zach-m
    Author

    not sure what you're asking here.. you can take any two points and compare GraphHopper's estimate with Google's (who would also give you an estimate in a trafiic-less scenario - which, I think, is what GraphHopper should aim for).
    So far the all-across slowdown factor of 0.55 proved very efficient for me with in-city, day-time routes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions