Repository navigation
Description
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):
- 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)
- Web API: based on several parameters influence the Weighting
- 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 speedSuch 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:
- fix Speed for AverageSpeedDetails should depend on Weighting #1551
- fix introduce required/default encoded values #1805
- remove getAnnotation(IntsRef edgeFlags, Translation tr) => e.g. replace via off_bike encoded value
- include warning regarding fords and change block ford => default to allow ford! -> fixes Make ford check including checking depth == 0 #236
- other warnings: ferry, toll, private, forestry, agriculture (trackType or sacScale?) more instruction annotations and bug fix #1814
- move methods of TurnWeighting into Weighting. I.e. remove TurnWeighting Remove TurnWeighting #1820
- Use highway tag and actual edge speed for Instructions Use highway tag and actual edge speed for Instructions #990
- fix Improve edge filtering for LocationIndex #729: remove EdgeFilter like createEdgeExplorer(EdgeFilter) and move accessEnc into Weighting! Move access flag checks into Weighting #1835 ( FastestWeighting contains only edge.get(avgSpeed) but not edge.get(accessEnc) => it is assumed that this is done via the EdgeExplorer ). Reduce usages of FlagEncoder -> DefaultEdgeFilter Reduce usages of FlagEncoder #1625 -> use Weighting instead. Same for subnetwork removal
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
easbar commentedon Dec 13, 2019
Can we do this already ? Possibly saves some refactoring work if we remove it early :)
[-]Introduce configurable Weighting[/-][+]Introduce configurable Weighting / CustomWeighting[/+]Remove bogus constructor