Description
As part of #1776 we need to stop using the access encoded values check if a road is accessible for a given vehicle and instead purely rely on the edge weight calculated by the Weighting. Otherwise returning a finite weight in Weighting might have no effect in case the access flag of the corresponding road/direction is set to false.
This is not a trivial task especially with performance in mind.
Just to make sure: Do we really need to do this for #1776 already ? What if we had something like a flexible encoder that simply uses fwd/bwd=true for all roads, while some of the 'classic' vehicle profiles like car or bike continue to use the access flags (but cannot be used with flexible/configurable weighting). In this case using fwd/bwd=false and at the same time returning a finite weight would be considered a bug, and to offer the configurable weighting option the encoder must set all access flags to true.
Activity
karussell commentedon Dec 29, 2019
Why do you think this is complicated because of performance?
That would work, but would be ugly as we would check the access in the EdgeFilter and then again in the configurable Weighting.
Yes, we can use them as "base" and then, once a road is inaccessible for these "base vehicles", you cannot enable these roads via the Weighting. Actually I did this in the various branches when I implemented a preliminary version of it and the experience was okay.
The remaining problem is still issue #729 where we need to replace the EdgeFilter with the Weighting, otherwise it can happen that the LocationIndex returns edges that are blocked due to the configurable Weighting.
BTW: should we rename this issue to "make access flags optional"? As this is not about removing the access flags and more about moving the access flags check into the Weighting. I.e. we can still implement access restrictions via pre-calculated bits in the edge flags, but also calculate it dynamically via some EncodedValues.
easbar commentedon Dec 30, 2019
Ok, as long as you have some access flags and can check them within weighting quickly the performance should in principle stay the same. But do you not have to set (at least most of) the access flags to true to be able to have a real 'configurable' weighting ? Edges with access=false cannot be unblocked by a configurable weighting in my current understanding (or you ignore them but then there is no quick exit and hence performance will decrease).
What I think is 'not trivial' is figuring out what the problems are and finding a good solution for all things we would like to achieve (performance & flexibility mostly). For example it took me quite some time to find a solution to the access flags issue just for the CH preparation, #1837.
You mean ugly because its slower or whats ugly about it ? But yes I agree it would be nicer to strictly move all access checks inside the weighting.
Ok this makes sense now.
Its probably similar also for
DirectionResolver. I think we can do this step by step. For CH preparation I did #1837 now, for CH algorithms I think I'll do it in a similar way.Ok now its more clear to me. I renamed the issue to just that.
[-]Remove access flags[/-][+]Move access flag checks into Weighting[/+]location lookup based on Weighting additionally to access, fixes #729 …
karussell commentedon Dec 30, 2019
Yes. Hopefully this won't be much or one always has the option to pick the base vehicle (like car or bike). Likely this "base vehicle" selection is required to reduce other problems as well like the subnetwork removal.
Yeah, it is a big conceptual change and agree on the handling (do this issue here independent). I also have a fix for #729 without bigger changes: #1838
Ugly in the sense that two things are responsible where only one should be.
easbar commentedon Dec 30, 2019
Agreed. I thought it could be acceptable to state that using a flexweighting only works when the access flags are set to true or something, but sure moving the access checks into weighting entirely is cleaner.
karussell commentedon Dec 30, 2019
BTW: I think this will also fix those "speed == 0 vs. access == true" issues, like #1234
todo will be fixed later in #1835
location lookup based on Weighting additionally to access (#1838)
easbar commentedon Apr 29, 2020
For 1.0 this does not seem so important, because
CustomWeightingalways inherits the access flags from some base encoder and there is no way to change it. We can block additional edges (e.g. using priority), but opening up restricted edges is not possible anyway.karussell commentedon Dec 1, 2020
I played a bit with this and I don't think this depends on changing the FlagEncoder classes. We only need to avoid the implicit edge filters. Let me try to explain this :)
Let's assume we check against
car.accessin calcEdgeWeight as the very first step for all Weighting implementations. Then, when we remove all the implicit EdgeFiltering like in createEdgeExplorer we should be able to make this configurable for CustomWeighting without the need to change the FlagEncoder classes.We could introduce some new options like
default_access: trueto ignorecar.accessas a first step:The reverse direction will get the speed of the forward direction but it is unknown what happens to the average_speed of newly accessible roads like
pedestrian. To solve this problem we could provide a fallback mechanism:which could mean that if
carhas no estimated speed in the reverse direction then use the speed fromfootand if nofoot.accessthen skip the edge. I.e. the accessibility is "allowed car" minus "forbidden foot". This would replaceprofile: carand the FlagEncoder classes are just used as tag parsers that fillxy.accessandxy.average_speed.For more flexibility we could define an
average_speed_maplike we do formax_speedand use that ascustomfallback indefault_average_speedto allow certain road segments like pedestrian roads or private roads that would be otherwise disallowed from car.Now the reverse direction for all roads would be automatically allowed. We could introduce a separate flag for that, but with janino scripting we can express more complicated expressions:
easbar commentedon Feb 26, 2021
Interesting to see how much the syntax has changed :)
This is true, when we open up roads without access we have no speed value we can use. Maybe we could use, e.g., foot$average_speed as right-hand value, like this (or similar)?
Or maybe even use car$access in the condition, like this:
At first it seems useful to use the other average speed values if none are available for the base vehicle (because this is better than 'nothing'). But on the other hand I wonder in which case we actually want to do this? Do we ever want to fall back to foot speed when we go by car? Could we not just set the speed to something like 5km/h in this case (no matter what the real value for foot$average_speed is)?
easbar commentedon Feb 26, 2021
Btw I am currently working on this issue. Maybe we can replace
FastestWeightingby something like this at some point:easbar commentedon Feb 27, 2021
Also should we rename
DefaultEdgeFilter->AccessEdgeFilter(or justAccessFilter)? Filtering by access should no longer be the 'default'. There certainly are cases where we want to filter by access, but there also are cases where we rather filter by weight, see theFiniteWeightFilterI just added.