Skip to content

Introduce configurable Weighting / CustomWeighting #1776

Closed

Description

@karussell

This is issue will supersede the 5 year old issue #193 and will at least lead to specific issues to push this topic forward.

The basic idea is to have a highly configurable Weighting (cost function) or later even scriptable Weighting, i.e. tell Dijkstra to include or exclude certain edges and do that without the need for Java.

The "scripted" Weighting is likely to happen later as the configurable Weighting (config-Weighting) is simpler regarding security and overall complexity. Performance seems to be similar.

There are already a few experimental branches (here, here, here, here).

You'll notice that I tried to avoid the usage of "FlagEncoder" in the following, because it is possible without it. I.e. we only need a custom Weighting that uses the available edge data (EncodedValues). The PT travel mode is already implemented without a FlagEncoder.

There are three pipelines where we could introduce the config-Weighting (or scripting):

  1. OSM import: read raw and sometimes ugly OSM data and create a "clean data" graph with nodes and edges and its EncodedValues (create a travel-mode-independent topology with clean attributes in proper units)
  2. Web API: based on several parameters influence the Weighting
  3. CH (or LM) preparation: create shortcuts based on a Weighting

It would be nice to have a script that operates directly on OSM tags like other routers do. But I think we should avoid this because:

  • the average user of the web API should not be confronted with the complexity of OSM, e.g. there are many options to define one-way roads and much more stuff
  • we should also be able support other data like Gtfs, TomTom etc where an OSM-dependency is problematic

So the first "clean graph creation" step is still in Java and out of scope of this issue here. To make pipeline 2 or 3 more "configurable" we will create more EncodedValues in pipeline 1.

Now that we "only" need to support the web API pipeline and preparation pipeline it appears that we can use the identical config-Weighting for both cases, except that the config-Weighting for the web API pipeline is retrieved via a POST request (e.g. see #1689) and for the preparation we read a file that also defines the name of the Weighting, which we can then use in the query.

This means you can play around in flexible mode until you are satisfied with the ETAs and routes and then "freeze" the Weighting and make it faster (via CH or LM).

One preliminary short example of such a config could look like:

base: car # later we could replace this with e.g. "topologies: [road, ferry], access: car"
max_speed: 110
average_speed:
  road_class: { motorway: 80 } # travel only on the defined road_classes, everything else is 0, i.e. not accessible in both directions
speed_factor:
  road_environment: { bridge: 0.9 } # slow down on bridges
priority:
  road_environment: { tunnel: 0.9 } # avoid tunnels without changing the speed

Such a configuration could fulfill most of the requirements
that I found when thinking about this for awhile.

TODO: add public transit use cases.

One conceptual challenge is that we need to store different access and turn cost values for travel modes at the OSM-import pipeline before the actual Weighting can be defined. So when parsing OSM access tags we already need the concept of a "car" to e.g. allow the car in only one direction, or we need to know the concept of "truck" for different speed limits signs etc.

This could make sense, because a bike-Weighting at a later stage must not strictly follow the typical "bike" access restrictions, instead we could assume walking speed and ignore the one-way restriction. We would create additional TagParsers that fill EncodedValues like "car.access" or "hgv.average_speed" before we actually use them in the config-Weighting.

Before this can be implemented we need:

There are the following separate tasks or subtasks:

  • make the config-Weighting ("scripting") working
  • better separation of core vs. OSM-dependent functionality
  • avoid the fat dependency for jackson and yaml in core, i.e. core only uses the FlexConfig.java
  • we need a way to migrate away from FlagEncoder to reduce complexity, still we need some EncodedValue collectors like PtEncodedValues?
  • create a clean topology-only graph. Store properties like turn costs, access and relations in some generic way. Partly done in move relation and turn relation parsing out of FlagEncoder #1775.
  • subnetwork removal issue: remove subnetworks for all EncodedValues with a suffic ".access"
  • EdgeFilter in LocationIndex should get dependent on the Weighting not FlagEncoder Improve edge filtering for LocationIndex #729
  • remove DataFlagEncoder and GenericWeighting -> done Remove DataFlagEncoder #1826

Activity

  1. easbar commented on Dec 13, 2019

    @easbar
    Member

    remove DataFlagEncoder and GenericWeighting

    Can we do this already ? Possibly saves some refactoring work if we remove it early :)

  2. changed the title [-]Introduce configurable Weighting[/-] [+]Introduce configurable Weighting / CustomWeighting[/+] on Feb 6, 2020
  3. added this to the 1.0 milestone on May 1, 2020
  4. added a commit that references this issue on May 17, 2020
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions