Skip to content

Don't allow A* loops for bicycles - #3574

Merged
gmellemstrand merged 3 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:remove-bicycle-loops
Jul 29, 2021
Merged

Don't allow A* loops for bicycles#3574
gmellemstrand merged 3 commits into
opentripplanner:dev-2.xfrom
leonardehrenfried:remove-bicycle-loops

Conversation

@leonardehrenfried

@leonardehrenfried leonardehrenfried commented Jul 28, 2021

Copy link
Copy Markdown
Member

Summary

Don't allow loops in A* computations for bikes. They can lead to timeouts when the start/destination is near with a high number of visibility edges.

Issue

closes #3564

Unit tests

none

Code style

Yes

Documentation

Yes

Changelog

Yes

@leonardehrenfried
leonardehrenfried requested a review from a team as a code owner July 28, 2021 19:42
@leonardehrenfried

Copy link
Copy Markdown
Member Author

I'm having a bit of a problem with the BikeRentalSnapshotTest. It seems that when I remove the loop for cyclists, then arriveBy and departAt searches return different results.

Screenshot from 2021-07-28 23-20-25

Screenshot from 2021-07-28 23-20-21

Both are, IMO, valid routes.

It seems that the looping code has masked a problem where the arriveBy and departAt intersection traversal code returns different results.

When I use a intersection cost model that returns a constant cost, then the difference disappears.

@leonardehrenfried

Copy link
Copy Markdown
Member Author

Actually, I managed to sidestep the failing test by moving the start location ever so slightly to the east.

@t2gran t2gran added this to the 2.1 milestone Jul 29, 2021
@t2gran t2gran added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Jul 29, 2021
@leonardehrenfried

Copy link
Copy Markdown
Member Author

As discussed in the dev meeting, I separated the arriveBy and departAt tests thereby documenting the unexpected difference.

@t2gran

t2gran commented Jul 29, 2021

Copy link
Copy Markdown
Member

I looked through the code and it looks ok, but @gmellemstrand will do the final review from Entur.

@gmellemstrand
gmellemstrand merged commit 9235251 into opentripplanner:dev-2.x Jul 29, 2021
@leonardehrenfried
leonardehrenfried deleted the remove-bicycle-loops branch July 29, 2021 11:14
@miklcct

miklcct commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

I'm having a bit of a problem with the BikeRentalSnapshotTest. It seems that when I remove the loop for cyclists, then arriveBy and departAt searches return different results.

Screenshot from 2021-07-28 23-20-25

Screenshot from 2021-07-28 23-20-21

Both are, IMO, valid routes.

It seems that the looping code has masked a problem where the arriveBy and departAt intersection traversal code returns different results.

When I use a intersection cost model that returns a constant cost, then the difference disappears.

The problem is not where the arriveBy and departAt intersection traversal code returns different results. It is A* not keeping the state of different back edge leading to different turn costs, so sometimes a non-optimal result is returned. A test case is provided in #6777 .

@abyrd

abyrd commented Sep 4, 2025

Copy link
Copy Markdown
Member

Good catch @miklcct, thanks for tracking down the source of the asymmetric routing behavior in this older commit. The decision to not allow loops on bicycles may have been a necessary compromise at the time to maintain performance. But the underlying reason why certain bicycle states were incomparable (allowing looping paths) was to ensure correct handling of turn costs. Making all bike states comparable is only half of the necessary change - the other half would be deactivating all turn restrictions for bicycles.

The state comparability logic here looks incomplete to me but maybe I'm missing something. The comments (even in current versions of the code four years later) are all about loops, and allowing loops "near the start and end" - there may be some misinterpretation of what this logic is for.

@miklcct

miklcct commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

However bicycles are subject to turn restrictions and I won't be happy if the router tells me a route to turn right where prohibited, forcing me to push my bike against turning traffic.

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

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bicycle routing out of places with many possible start vertices fails

5 participants