Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change sharing criterion to avoid artificial detours #3302

Merged
merged 6 commits into from
Sep 6, 2021
Merged

Conversation

genadz
Copy link
Contributor

@genadz genadz commented Sep 2, 2021

Changes:

  • use continuous function to calculate sharing coefficient (instead of piecewise constant function);
  • change definition of "sharing": it was modified from "part of edges that a candidate shares" to "part of edges that already chosen path shares with alternative";
  • extend alternatives search.

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Update the docs with any new request parameters or changes to behavior described
  • Update the changelog
  • If you made changes to the lua files, update the taginfo too.

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

  Before 'sharing' was defined as a part of shared edges of
  an alternative candidate. Now it's a part of shared edges
  of already chosen route. It prevents from getting alternatives
  with artificial detours.
 Changed alternative_cost_extend coefficient from 1.1 to 1.2
@genadz
Copy link
Contributor Author

genadz commented Sep 2, 2021

Quantity

ETA < 10m

master branch
1st alternative 1454 1463
2nd alternative 918 930

10m < ETA < 30m

master branch
1st alternative 511 508
2nd alternative 356 352

30m < ETA < 1h

master branch
1st alternative 707 754 (+7%)
2nd alternative 545 602 (+10%)

1h < ETA < 5h

master branch
1st alternative 3537 4045 (+14%)
2nd alternative 2360 3201 (+36%)

Quality

Let me share several examples:

with alternatives only in master

before after
master_1 branch_1
master_2 branch_2
master_3 branch_3

As expected, some alternatives that have unreasonable detours were filtered out.

with alternatives only in branch

before after
master_4 branch_4
master_1 branch_1

These changes caused by increased kAlternativeCostExtend parameter.

different alternatives were proposed

before after
master_1 branch_1
master_3 branch_3
master_2 branch_2

Performance

master

5%	10%	50%	90%	95%	99%	100%	
0.0088	0.0126	0.0991	0.3900	0.8046	1.7444	6.8323	
mean: 0.1885

branch

5%	10%	50%	90%	95%	99%	100%	
0.0088	0.0127	0.1081	0.4341	0.8226	1.8168	7.8100	
mean: 0.2057

Average performance drop is about 10%. Taking into account quality/quantity improvements I think it's a good deal.

return 0.65;
}
if (distance < 10000.f)
return 0.6f;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed min at_most_shared coefficient from 0.5 to 0.6

if (distance < 100000.f) {
// Uniformly increase 'at_most_shared' value from 0.6 to 0.75 for routes
// from 10km to 100km
return 0.6f + (kAtMostShared - 0.6f) * (distance - 10000.f) / (100000.f - 10000.f);
Copy link
Contributor Author

@genadz genadz Sep 2, 2021

Choose a reason for hiding this comment

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

replaced piecewise constant function with a continuous one

if ((shared_length / total_length) > at_most_shared) {
// throw this alternate away if any of the chosen paths shares more than at_most_shared with it
assert(paths[i].back().path_distance > 0);
if ((shared_length / paths[i].back().path_distance) > at_most_shared) {
Copy link
Contributor Author

@genadz genadz Sep 2, 2021

Choose a reason for hiding this comment

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

this is important change. What was before:
"sharing value is a part of shared edges of an alternative candidate with some already chosen route"
now is
"sharing value is a part of shared edges of some already chosen route with an alternative candidate".

It should prevent from getting artificial alternatives with unreasonable detours.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's consider a particular example:

A------------------------------------B---------C----------------------------------------D
                                     |         |
                                     |         |
                                     |         |
                                     |         |
                                     E---------F

here ABCD is an optimal route and ABEFCD is an alternative candidate.
Let's assume that len(AB + CD) / len(ABCD) = 0.85 and len(AB + CD) / len(ABEFCD) = 0.75. Current master will allow ABEFCD to be an alternative despite the fact that BEFC detour is obviously unreasonable. This branch will reject this alternative due to the fact that sharing = 0.85 > 0.75 = at_most_shared value.

Copy link
Member

Choose a reason for hiding this comment

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

this was what was originally intended actually... good catch! i should also note though that in another pr we are looking into problems with teh path_distance not being set on the last edge label, which is where the pathinfo gets it. it is my h unch that this is in the case that we find a path using only the forward search tree but i havent proven it yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, thanks for the comment, I will check it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevinkreiser replaced division with multiplication to avoid possible problems

@@ -28,7 +28,7 @@ constexpr float kThresholdDelta = 420.0f;
// an upper bound value cost for alternative routes we're looking for. Due to the fact that
// we can't estimate route cost that goes through some particular edge very precisely, we
// can find alternatives with costs greater than the threshold.
constexpr float kAlternativeCostExtend = 1.1f;
constexpr float kAlternativeCostExtend = 1.2f;
Copy link
Contributor Author

@genadz genadz Sep 2, 2021

Choose a reason for hiding this comment

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

It doesn't drop performance too much, see "Performance" section in the comment above #3302 (comment)

@genadz genadz requested a review from kevinkreiser September 2, 2021 16:22
kevinkreiser
kevinkreiser previously approved these changes Sep 3, 2021
@merkispavel
Copy link
Contributor

I guess this is a sign that valhalla's Gods like your changes
image

Copy link
Contributor

@merkispavel merkispavel left a comment

Choose a reason for hiding this comment

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

reapprove, looks good

@genadz genadz merged commit d425e99 into master Sep 6, 2021
@genadz genadz deleted the kgv_sharing branch September 6, 2021 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants