Custom Model Produces Short Trip Durations

Hello,

I’m using GraphHopper in my project to generate routes, approximate mileage and trip durations. While the mileage calculations seem accurate, the trip durations are consistently too short, which is a problem for my use case.

I’ve compared the results to the GraphHopper online web app, and the durations there are much more realistic. The web app doesn’t use traffic data (which isn’t supported in my country), so I suspect the issue lies within my custom model or configuration.

Here’s my profile:

private Profile getCarProfile() {
    final var profile = new Profile(CAR_PROFILE);
    final var customModel = new CustomModel();
    customModel.setDistanceInfluence(10.0);
    customModel.addToPriority(Statement.If("!car_access", Statement.Op.MULTIPLY, "0"));
    customModel.addToSpeed(Statement.If("true", Statement.Op.LIMIT, "car_average_speed"));
    profile.setTurnCostsConfig(TurnCostsConfig.car());
    profile.setCustomModel(customModel);
    return profile;
}

And the route function:

GHResponse getResponse(List<MapCoordinatesDto> waypoints) {
    final var points = waypoints.stream()
           .map((i) -> new GHPoint(i.latitude(), i.longitude()))
           .toList();

    final var request = new GHRequest(points);

    request.setProfile(CAR_PROFILE);
    request.putHint("instructions", false);
    request.putHint("calcPoints", false);

    return graphHopper.route(request);
}

Question:

  1. Is there a configuration issue in my custom model that could lead to shorter trip durations?
  2. How can I adjust the model or profile to ensure realistic duration calculations?

Any insights or suggestions would be greatly appreciated!

Your custom model configuration is fine, but the car_average_speed in the open source project still won’t result in the same speeds as for the hosted service. You could decrease the overall speed by adding another speed statement (see the custom model documentation for details), or more specifically for the types of roads where you expect a longer trip duration. Do you have any examples for this? Also decreasing the speed in urban areas typically improves the duration estimates. You can do this by using the urban_density encoded value that you need to enable in your config file.