Flexible / Configurable Weighting Update

I invite you to try a planned feature for 1.0 which is now in a usable shape. It allows you to heavily customize the existing vehicle profiles without any Java knowledge. And not only per-request but also for the CH and LM preparations.

Cargo bike example:

base: bike

vehicle_height: 2.3
vehicle_width: 1.2

# let's assume cargo bikes are e-bikes and we should lower speed to prefer shorter and not faster routes automatically
max_speed:
  road_class:
    primary: 28

# if no other condition matches
max_speed_fallback: 25

priority:
  # exclude steps
  road_class:
    steps: 0

  surface:
    sand: 0.5
  # prefer better tracks
  track_type: { other: 1.1, grade1: 1.1 }
  # prefer official bike routes
  bike_network: { other: 0.5 }
  # avoid all situations where we have to get off the bike
  get_off_bike: 0.5

As you can see from the examples there are already several things implemented:

  • avoid, prefer or block roads with with a certain road_class (motorway, primary), surface, track_type, road_access (destination, …), road_environment (tunnel, bridge), toll, bike or hike network etc
  • define maximum vehicle properties like for speed, length, weight, height and width
  • lower the average speed via a speed_factor i.e. influence the time!
  • cap maximum speed (also influences the time!)
  • avoid, prefer or block areas via GeoJSON or also change speed or cap speed based on these areas.
  • avoid, prefer or block countries also works if issue 1875 is fixed (usage: add country encoded value and set border_directory)
  • change distance influence to prefer shorter but potentially slower routes

As there is no documentation except the PR itself and the tests I would appreciate your feedback about the usage and what is unclear or even your first custom profiles :slight_smile:.

Previously discussed here and here.

5 Likes

Have hacked together an interesting feature where we can avoiding certain turns like left_turns. Currently it still has some unexpected behaviour (for T-junctions) and is rather slow for longer routes, as the junction calculation stuff is done while the graph exploration, but it is really fun and interesting which routes are found:

Update: this matter is a bit more tricky as there is sometimes no reason to avoid certain left turns, e.g. for a T-junction coming from bottom, going to left - this is a complete different situation compared with a normal 4-road junction where oncoming traffic needs to be “crossed”.

2 Likes

Cool :slight_smile: I tried it on my machine and got it up and running straight away. First I copied the cargo bike example into the flex box field in the left side pane. Then I tried this bike route (without customization)

it does not take the official bike route that we can see on open cycle map:

image

So I tried with this simplified custom bike:

base: bike

priority:
  bike_network: { other: 0.5 }

and the new route was then using the bike network as expected: :+1:

However, the new route is 5.8km instead of 3.4km long, so I tried playing with the distance_term_constant:

distance_term_constant: 0.10

And after trying a few different values I got the short route again. I am sure there are better examples where there are different ‘intermediate’ routes depending on the priority/distance trade-off, but in my quick example the calculated road was merely snapping back an forth between the two alternatives (depending on the parameters).

1 Like

That’s a very interesting feature.

How can I test this?

I’m running my own instance successfully, but I’m not seeing the flex input field on the left side.

routing.ch.disabling_allowed and routing.lm.disabling_allowed is set to true in config.yml

Tested with master and latest web service jar

I’ve opened a new topic for setting up flex mode: Setup for Flexible / Configurable Weighting Update

You probably need to recreate the js: https://github.com/graphhopper/graphhopper/blob/master/docs/core/quickstart-from-source.md#javascript

E.g. I’m using the following so that changes will be updated automatically:

cd graphhopper/web
$ BROWSERIFYSWAP_ENV='development' npm run watch

btw: you can test this without the UI too via sending the content via curl or similar.

Powered by Discourse