Skip to content

Custom models: Is "add" supported for speed or is this just undefined behaviour? #3347

Closed

Description

@Nakaner

Describe the bug
@karussell wrote in response to my pull request at graphhopper/custom-model-editor#8 (comment):

Currently add is only supported for turn_penalty and cannot easily be added as it is.

I move this discussion to the main repository because add works for speed (see below). Is the support for add as an operator for speed a bug, a feature or undefined behaviour?

Example with GraphHopper 11.0 routing through Karoline-Luise-Tunnel in Karlsruhe:

With a "racing car" (car_average_speed + 150):

curl -s 'http://127.0.0.1:8989/route' \
  -X POST \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "points":[[8.4169,49.004989], [8.391431,49.005486]],
  "profile":"car",
  "instructions":true,
  "details":["max_speed","average_speed"],
  "custom_model": {
    "distance_influence":15,
    "speed": [
      {"if":"road_environment==TUNNEL","add":"150"}
    ]
  },
  "ch.disable":true
}' | jq '.paths[0].time'
64759

Non-op custom model:

curl -s 'http://127.0.0.1:8989/route'   -X POST   -H 'Content-Type: application/json'   --data-raw '{
  "points":[[8.4169,49.004989], [8.391431,49.005486]],
  "profile":"car",
  "instructions":true,
  "details":["max_speed","average_speed"],
  "custom_model": {
    "distance_influence":15,
    "speed": [
      {"if":"road_environment==TUNNEL","multiply_by":"1.0"}
    ]
  },
  "ch.disable":true
}' | jq '.paths[0].time'
15049

average_speed reported in the details is 195 km/h in the first example.

Is this undefined behaviour? Should GraphHopper raise an exception?

To Reproduce

  1. GraphHopper master (commit ) or version 11.0 (both tested)
  2. default config-example.yml as shipped with those versions
  3. import: java -Ddw.graphhopper.datareader.file=karlsruhe-regbez.osm.pbf -Ddw.graphhopper.graph.location=graph-cache -jar web/target/graphhopper-web-12.0-SNAPSHOT.jar server config-example.yml (different path to .jar file for 11.0 of course)

Reported travel times differ by 1 to 3 seconds between GraphHopper 11.0 and master but the general behaviour is present in both.

System Information

openjdk 21.0.10, Ubuntu 24.04

Activity

  1. karussell commented on Apr 28, 2026

    @karussell
    Member

    "add" is supported for speed (and should work) but not for priority.

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