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

Do not skip connections in bidiastar #2802

Merged
merged 11 commits into from
Feb 3, 2021
Merged

Conversation

genadz
Copy link
Contributor

@genadz genadz commented Jan 25, 2021

Issue

This PR should fix 2 bugs:
1) for some cases bidirastar builds extra detours.

After debugging:
in bidirectional astar: we mark edge as permanent only before call expansion method. But it's not correct, because we can mark edge earlier right after we popped this edge from the queue.

Current behavior may loose some connections in the following case: let's suppose A->B->C->D is the part of the shortest route. On some iteration we popped B->C label as fwd_pred from the forward queue. Then we applied reverse search from the node C (suppose cost for D->C less than cost for B->C). Then we popped C->B label as rev_pred from the reverse queue. And, looks like now we should set the connection B->C, but we don't do it because the edge B->C hasn't marked as permanent for now. So, we skip this and continue forward expansion from the node C.

So, now imagine that we have 2 not-thru regions A and B and one connection edge between these regions. In some cases if we skip this connection path cannot be found or may be found with extra detour.

2) For some cases bidirastar returns pathes with double u-turns.

It happens due to the following: let's suppose we have a complex restriction no_u_turn: from AB via BC to CD. Then, forward search reaches BC, checks that it's a deadend (because of the restriction) and makes a u-turn CB. After that reverse search reaches CB, checks that it's a deadend (because of the restriction), makes a u-turn BC and meets CB edge from forward search. So, now we have the following path: AB -> BC -> CB -> BC -> CD - there is no rule to forbid such path so we accept it.

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

Requirements / Relations

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

@genadz genadz marked this pull request as draft January 25, 2021 16:30
@genadz
Copy link
Contributor Author

genadz commented Jan 25, 2021

When I made changes some tests failed. The reason: we have a bug related to complex restrictions. This bug should be fixed here #2796 . So, this PR is blocked right now

@genadz genadz marked this pull request as ready for review February 2, 2021 22:06
@genadz
Copy link
Contributor Author

genadz commented Feb 2, 2021

RAD tests passed. It was only one different route, I checked it manually, no worries.

@@ -758,7 +758,7 @@ bool BidirectionalAStar::SetForwardConnection(GraphReader& graphreader, const BD

// Set a threshold to extend search
if (threshold_ == std::numeric_limits<float>::max()) {
threshold_ = (pred.sortcost() + cost_diff_) + kThresholdDelta;
threshold_ = std::max(pred.sortcost() + cost_diff_, opp_pred.sortcost()) + kThresholdDelta;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as far as we settle edge right after we pop it from the queue, pred.sortcost() + cost_diff may be lower than opp_pred.sortcost(). so, we should choose bigger in order no to prune search too early

A-1--B--------C--------D---------H---------------------------------------I
| |
K---------------------------------------J
)";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

special testcase that reproduces bug in master

A---1-------B-------------C------D------------------------E
| |
K--------------------L
)";
Copy link
Contributor Author

@genadz genadz Feb 3, 2021

Choose a reason for hiding this comment

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

special testcase that reproduces bug in master

Comment on lines +580 to +583
test::customize_edges(map.config, [&not_thru_edgeids](const GraphId& edgeid, DirectedEdge& edge) {
if (std::find(not_thru_edgeids.begin(), not_thru_edgeids.end(), edgeid) != not_thru_edgeids.end())
edge.set_not_thru(true);
});
Copy link
Member

Choose a reason for hiding this comment

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

its too bad this didnt happen automatically in the graphenhancer. i suppose you had to do this as a workaround?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. I needed not_thru attributes to reproduce the bug

@kevinkreiser
Copy link
Member

@genadz im sorry i have to ask it, hows the performance difference 😄

@genadz
Copy link
Contributor Author

genadz commented Feb 3, 2021

@genadz im sorry i have to ask it, hows the performance difference

the same as master

@genadz
Copy link
Contributor Author

genadz commented Feb 3, 2021

@kevinkreiser thanks for review!

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.

None yet

2 participants