Skip to content

destination support for car that doesn't modify the speed - #1752

Merged
karussell merged 3 commits into
masterfrom
car_destination
Oct 29, 2019
Merged

karussell merged 3 commits into
masterfrom
car_destination

Conversation

@karussell

Copy link
Copy Markdown
Member

fixes #733

Basically it moves the priorityEncoder to the CarFlagEncoder and fills it with bad priority if e.g. vehicle or motor_vehicle tag is destination

@karussell karussell added this to the 1.0 milestone Oct 17, 2019
public class CarFlagEncoder extends AbstractFlagEncoder {
protected final Map<String, Integer> trackTypeSpeedMap = new HashMap<>();
protected final Set<String> badSurfaceSpeedMap = new HashSet<>();
protected final Set<String> avoidAccessAtAllCosts = new HashSet<>();

@easbar easbar Oct 26, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called avoidAccessAtAllCosts ? If we avoid access to roads with destination tag at all costs why do we not just add them to restrictedValues ? Well of course thats not what we want, because a start/target point can be located at a road with destination tag ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant as "avoid access" but if necessary like for start and end locations the access should be allowed.

I would not want to use restrictedValues as e.g. there is no, restricted or private as value that should be excluded.

because a start/target point can be located at a road with destination tag ?

Yes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but I still do not understand why it is called avoidAccessAtAllCosts because we do not want to 'avoid access at all costs'. We want to 'apply penalty so normally we do not pass these roads unless its required to arrive at the destination (or start)'.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I do not understand the difference why avoiding a road isn't the same as adding a penalty to it. If a road is only accessible for people living there then I want to avoid the access of that road under all circumstances for the general path finding.

@easbar easbar Oct 28, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm for me 'avoiding something at all costs' sounds like I will not do it under any circumstances and 'applying a penalty' is more like I rather do not do it unless its really needed and I accept some penalty for doing it :)

If a road is only accessible for people living there then I want to avoid the access of that road under all circumstances for the general path finding.

Yes and no :) I want to avoid that road under all circumstances when I am only passing through, but I still use it if I need to use it to arrive at the destination. And even for passing through I do not avoid it under all circumstances, because the penalty is not infinite, i.e. if the required detour is too large I still use it.

But maybe this is just me..

}

@Override
public boolean supports(Class<?> feature) {

@easbar easbar Oct 26, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we are using PriorityWeighting instead of FastestWeighting in GraphHopper#createWeighting, right ? But does that not change all the weights that are calculated, because PriorityWeighting uses weight/(0.5+priority) to calculate the weight and priority is not 0.5 by default, not even for PriorityCode.UNCHANGED ? Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse for A* (just to handle the rare case of destination tags).

Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But does that not change all the weights that are calculated

What do you mean here? The weight should not be used or stored somewhere.

Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse

Hmmh, yes. Do you think changing it to e.g. weight*14/(7+priority) would help?

Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?

Ah, yes. This needs a change.

@easbar easbar Oct 28, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean here? The weight should not be used or stored somewhere.

Yes, I guess you are right the weight has no 'real' meaning, but then again I think we use it for many tests to check for correctness (but really we do not, because we hardly use PriorityWeighting in tests, but I do not think this is a good thing). For the present feature all we want is penalizing roads with access=destination tags such that they are only used when the start/destination lies in such an area, but we do not pass these areas. I don't think this justifies changing all weights. I think there should be a 'neutral' priority for all the roads we do not want to change the weight of. PriorityCode.UNCHANGED sounds like its neutral but its not. Or actually I wonder why this is even about priorities and we are not simply using a penalty factor (see below).

Do you think changing it to e.g. weight*14/(7+priority)

Ok lets say our weight estimation without priority is minWeight and with priority a route weight can increase by a factor of x, then we do not have to adjust the weight estimation at all. I think thats what you mean here (because for the 'fastest' priority=7 your formula leaves the (min)weight unchanged) ? To be honest I do not know why we should use the formula from PriorityWeighting here at all. All we want is to increase the weight of access=destination roads. So why are we not just talking about this factor ? As long as it is >=1 we do not need to adjust the weight estimation and depending on its size we get an idea how much of a detour we want to tolerate to enforce not driving through access=destination roads.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another problem I see with PriorityWeighting is that it extends FastestWeighting, but do we not want to account for access=destination when we use the ShortFastestWeighting for example ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's assume we have a configurable Weighting like proposed in #193 then we could easily introduce this "destination factor" and also account for "shortest"-related weightings.

I wanted to introduce this fix before the mechanism for such a configurable Weighting is established because the situation is a bit ugly right now due to the changed speed for those values (still without it it would be worse IMO) and the configurable Weighting might still take a bit more time.

But we can also wait with this if you think this would be cleaner and obviously it would avoid changing the weight definition twice.

To be honest I do not know why we should use the formula from PriorityWeighting here at all ... So why are we not just talking about this factor ?

This would require yet another Weighting before introducing "configurable Weighting". Another option would be to introduce a roadAccessFactor in FastestWeighting if the RoadAccess EncodedValue is stored (but this would be also a bit unclean IMO).

@easbar easbar Oct 28, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sure if this is only like a first step towards the final solution with configurable Weighting this is probably fine.

This would require yet another Weighting before introducing "configurable Weighting".

I would find all this easier to understand if there was something like DestinationSupportingFastestWeighting that just applies a penalty factor in case of access=destination instead of using PriorityWeighting with the weight/(0.5+priority) formula that does not make so much sense to me for this use case.

Another option would be to introduce a roadAccessFactor in FastestWeighting if the RoadAccess EncodedValue is stored (but this would be also a bit unclean IMO).

Why would this be unclean, is this not exactly what we want ? We want fastest weighting to support the access=destination tag (thats why you made GraphHopper#createWeighting return PriorityWeighting in case of "fastest"). Previously it did this by adjusting the speed and now it should do this by applying the penalty factor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sure if this is only like a first step towards the final solution with configurable Weighting this is probably fine.

Hmmh, it is not really a first step. More a last step of the old procedure :) before we introduce the new thing.

Why would this be unclean, is this not exactly what we want ?

Yes, if it goes into a separate Weighting class it wouldn't be unclean.

Will now think about this feature more and if we really should do this hassle before changing it again with the configurable Weighting.

@karussell karussell left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

public class CarFlagEncoder extends AbstractFlagEncoder {
protected final Map<String, Integer> trackTypeSpeedMap = new HashMap<>();
protected final Set<String> badSurfaceSpeedMap = new HashSet<>();
protected final Set<String> avoidAccessAtAllCosts = new HashSet<>();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant as "avoid access" but if necessary like for start and end locations the access should be allowed.

I would not want to use restrictedValues as e.g. there is no, restricted or private as value that should be excluded.

because a start/target point can be located at a road with destination tag ?

Yes

}

@Override
public boolean supports(Class<?> feature) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But does that not change all the weights that are calculated

What do you mean here? The weight should not be used or stored somewhere.

Also this changes the min weight to minWeight/7.5 which means the weight estimation is a lot worse

Hmmh, yes. Do you think changing it to e.g. weight*14/(7+priority) would help?

Currently the javadocs for PriorityWeighting say its specifically for motor bikes ? Thats not the case anymore ?

Ah, yes. This needs a change.

@karussell

Copy link
Copy Markdown
Member Author

Ok, moved it to FastestWeighting and so also ShortFastestWeighting can handle it. Also the factor is configurable and we do not use more bits as we reuse the road_access EncodedValue like it would be the case in the future for a configurable Weighting. I think this makes more sense :) ?

There is also an integration test showing that it works: GraphHopperIT.testNorthBayreuthDestination

@karussell
karussell requested a review from easbar October 28, 2019 13:49

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

maxSpeed = encoder.getMaxSpeed() / SPEED_CONV;

if (encoder.hasEncodedValue(RoadAccess.KEY)) {
// ensure that we do not need to change getMinWeight, i.e. road_access_delay is actual a penalty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

road_access_delay ? You probably mean roadAccessPenalty in the comment. And the import thing is its >=1 (which you enforce already).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment on the roadAccessPenalty about what it is supposed to do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

road_access_delay

ups, this was the name before ;) .. will correct it

Maybe add a comment on the roadAccessPenalty about what it is supposed to do

Will do

@Azbesciak

Copy link
Copy Markdown
Contributor

IMO moving such a thing, like not allowing access because it is a destination, to weighting, is not a good approach. For example it is not considered in ShortestWeighting now. Shortest does not mean that "go straight, violate all constraints".
If you want it to be in weighting (which I think is a good approach, but speed IMO also matters and could be configured [unloading truck for example at customer large private area, don't know], or speed for couriers in inhabited area) it should be made via composition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for restriction value 'destination' for car

3 participants