-
Notifications
You must be signed in to change notification settings - Fork 684
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
Allow expansion into a region when not_thru_pruning_ is false on 2nd pass #2978
Conversation
…we trasition to is marked not_thru, set not_thru to false for the edgelabel.
src/thor/bidirectional_astar.cc
Outdated
// to false here only if allow_restricted_thru is true and we are not restricted. | ||
// This bool is only set to true on the 2nd pass in route_action. See the gurka | ||
// test allow_restricted_thru | ||
bool thru = (pred.not_thru_pruning() || !meta.edge->not_thru()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: I think a var name of not_thru_pruning
would be more appropriate since it reflects the not_thru
pruning state of the current edge label (i.e whether we're culling-out not_thru edges or not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this not_thru_pruning and not confuse the issue with the restriction name.
@@ -37,6 +37,11 @@ void TimeDepReverse::Clear() { | |||
} | |||
edgelabels_rev_.clear(); | |||
adjacencylist_rev_.clear(); | |||
|
|||
// Set the ferry flag to false | |||
has_ferry_ = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this isn't related to the not_thru issue? the has_ferry
flag was simply missing from this implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandeepsandhu correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @danpat note the missing has_ferry
src/thor/bidirectional_astar.cc
Outdated
// based on the restriction, but it is also marked as not_thru. We set the not_thru | ||
// to false here only if allow_restricted_thru is true. This bool is only set to true | ||
// on the 2nd pass in route_action. See the gurka test allow_restricted_thru | ||
bool thru = (allow_restricted_thru() ? false : (pred.not_thru_pruning() || !meta.edge->not_thru())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the condition being checked different than the forward direction? Here we're switching off pruning without checking if the predecessor edge has restriction or not (i.e using pred.restrictions()
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandeepsandhu unfortunately we can't. I will explain when I fill in the details above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply have a not_thru_pruning option that is true on the first pass and false on the 2nd pass. No need (in my opinion) to check for restrictions - just disable all not_thru pruning on the 2nd pass. This was mostly added as a performance optimization for cycling and pedestrian (where hierarchies are not useful).
} | ||
}, | ||
std::exception); | ||
auto result = gurka::do_action(valhalla::Options::route, map, {"A", "F"}, "auto", {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, why is not failing to find a route anymore with your change? This is a simple not_thru
case and the previous open edge does not have any restriction on it. I thought this case would still throw a no-route exception since there's no other restriction involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mandeepsandhu in the reverse search not_thru is not considered anymore on the 2nd pass
…on the second pass
src/thor/bidirectional_astar.cc
Outdated
@@ -324,11 +326,17 @@ inline bool BidirectionalAStar::ExpandForwardInner(GraphReader& graphreader, | |||
float sortcost = | |||
newcost.cost + astarheuristic_forward_.Get(t2->get_node_ll(meta.edge->endnode()), dist); | |||
|
|||
// There is an edge case where we may encounter only_restrictions with edges being | |||
// marked as not_thru. Basically the only way to get in this area is via this edge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confusing description. The edge that is restricted is not marked as not_thru. I guess the "only_restriction" means the path can only go onto the not_thru edge, but Valhalla doesn't really have the notion of "only" - it just has edges that are restricted / not allowed.
src/thor/multimodal.cc
Outdated
@@ -92,6 +92,8 @@ void MultiModalPathAlgorithm::Clear() { | |||
|
|||
// Set the ferry flag to false | |||
has_ferry_ = false; | |||
// Set not thru pruning to true | |||
not_thru_pruning_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't multi-modal routes always forward search (not bidirectional) - and we don't use not_thru pruning except in bidirectional A*?
src/thor/timedep_forward.cc
Outdated
@@ -43,6 +43,8 @@ void TimeDepForward::Clear() { | |||
|
|||
// Set the ferry flag to false | |||
has_ferry_ = false; | |||
// Set not thru pruning to true | |||
not_thru_pruning_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as multi-modal
/** | ||
* Set the not_thru_pruning_ | ||
* @param pruning set the not_thru_pruning_ to pruning value. | ||
* only set on the second pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is set to true on first pass for bidirectional, so this comment line is incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider moving the comments on not_thru pruning from bidirectional_astar.cc into here.
valhalla/thor/pathalgorithm.h
Outdated
@@ -106,6 +124,8 @@ class PathAlgorithm { | |||
|
|||
bool has_ferry_; // Indicates whether the path has a ferry | |||
|
|||
bool not_thru_pruning_; // Indicates whether to allow access into a restricted no thru region. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take out the word restricted, change to "into a not-thru region"
src/thor/bidirectional_astar.cc
Outdated
@@ -549,11 +557,17 @@ inline bool BidirectionalAStar::ExpandReverseInner(GraphReader& graphreader, | |||
float sortcost = | |||
newcost.cost + astarheuristic_reverse_.Get(t2->get_node_ll(meta.edge->endnode()), dist); | |||
|
|||
// There is an edge case where we may encounter only_restrictions with edges being |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider moving this lengthy comment into the PathAlgorithm method that sets not_thru pruning.
src/thor/astar_bss.cc
Outdated
@@ -57,6 +57,8 @@ void AStarBSSAlgorithm::Clear() { | |||
|
|||
// Set the ferry flag to false | |||
has_ferry_ = false; | |||
// Set not thru pruning to true | |||
not_thru_pruning_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought only bidirectional A* uses not_thru_pruning?
Issue
This PR resolves an edge case where we may encounter only_restrictions with edges being marked as not_thru. Basically the only way to get in this area is via this edge based on the restriction, but it is also marked as not_thru. To resolve this issue, we set the not_thru to false for all edges only if the global
not_thru_pruning_
is false.not_thru_pruning_
is only set to false on the 2nd pass in route_action. See the gurka testnot_thru_pruning_
as it is based on the following real world example:This way/edge is marked as a not_thru edge.
But the only way to get into this area is this way/edge due to the only restriction.
So basically in the forward or reverse expansion in bidirectional A* we stop expanding due to the edge being marked as not_thru.
I tried removing logic to not mark this edge as not_thru in Mjolnir; however, the following edge is also marked as not_thru so we would just uturn on the original edge and still not traverse into this area.
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?