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

Bug fix TransitionCostReverse call: pass right internal_turn argument #3271

Merged
merged 7 commits into from
Aug 16, 2021

Conversation

merkispavel
Copy link
Contributor

@merkispavel merkispavel commented Aug 16, 2021

Issue

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?

genadz
genadz previously approved these changes Aug 16, 2021
@@ -311,7 +307,7 @@ inline bool UnidirectionalAStar<expansion_direction, FORWARD>::ExpandInner(
(pred.not_thru_pruning() || !meta.edge->not_thru()),
(pred.closure_pruning() || !(costing_->IsClosed(meta.edge, tile))),
static_cast<bool>(flow_sources & kDefaultFlowMask),
costing_->TurnType(meta.edge->localedgeidx(), nodeinfo, meta.edge),
costing_->TurnType(pred.opp_local_idx(), nodeinfo, meta.edge),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It isn't related to the main purpose of the PR but I found it while writing a unit test

: costing_->TransitionCostReverse(meta.edge->localedgeidx(), nodeinfo, opp_edge,
opp_pred_edge,
static_cast<bool>(flow_sources & kDefaultFlowMask),
pred.internal_turn());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The key is this line

(penalize_internal_uturns && internal_turn == InternalTurn::kLeftTurn && has_left))

We need to check whether the previous maneuver is internal turn and the current one is a turn. And the "previousness" is the same for both forward and reverse searches

Copy link
Member

Choose a reason for hiding this comment

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

haha i looked at this change in the previous pr several times and i wasnt a fan of the temporary internal_turn variable, im glad to see it go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm feeling the same 😄

forward.trip().routes(0).legs(0).node().Get(node_count - 1).cost().elapsed_cost();
auto reverse_cost =
reverse.trip().routes(0).legs(0).node().Get(node_count - 1).cost().elapsed_cost();
// if assert is triggered - check if uturn on internal edges is detected correctly
Copy link
Contributor

Choose a reason for hiding this comment

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

which assert do you mean ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean the "expect_near" check below

Copy link
Contributor

Choose a reason for hiding this comment

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

ok)

Copy link
Member

Choose a reason for hiding this comment

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

i dont suppose these changes fix the TODO below? still not?

Copy link
Contributor Author

@merkispavel merkispavel Aug 16, 2021

Choose a reason for hiding this comment

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

right 😞
I should mention that this delta is pretty small(~ 1e-4..1e-5) so it's not so critical(but annoying). EXPECT_NEAR with a small threshold(e.g 0.1) is the best workaround until it's fixed

Copy link
Member

Choose a reason for hiding this comment

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

ah interesting. i feel like before it was a larger epsilon. perhaps your fixes are fixing it but since we are recosting in the forward direction, and its single precision float, the chagne in order of operations is enough to have such a small deviation? do you mind enabling them and adding the delta with the comment explaining that they are super close and some of our hypotheses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, no problem. Done

@merkispavel
Copy link
Contributor Author

Unwanted divebombs from #3260 are gone 🎉
image
image
image

@kevinkreiser
Copy link
Member

@merkispavel you cant argue with those images

genadz
genadz previously approved these changes Aug 16, 2021
@merkispavel merkispavel merged commit 061f1d3 into master Aug 16, 2021
@nilsnolde nilsnolde deleted the fix-internal-turn-parameter branch February 24, 2024 15:07
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