-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use millisecond precision in A* traversal #6436
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
Use millisecond precision in A* traversal #6436
Conversation
… backwards are always the same length, to the millisecond, and also when rounded to seconds
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6436 +/- ##
=============================================
+ Coverage 69.84% 70.35% +0.51%
- Complexity 18124 18176 +52
=============================================
Files 2069 2062 -7
Lines 77268 76935 -333
Branches 7855 7764 -91
=============================================
+ Hits 53965 54128 +163
+ Misses 20546 20051 -495
+ Partials 2757 2756 -1 ☔ View full report in Codecov by Sentry. |
application/src/ext/java/org/opentripplanner/ext/flex/edgetype/FlexTripEdge.java
Outdated
Show resolved
Hide resolved
...cation/src/main/java/org/opentripplanner/service/vehiclerental/street/VehicleRentalEdge.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/edge/StreetEdge.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/edge/PathwayEdge.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/search/state/State.java
Show resolved
Hide resolved
application/src/main/java/org/opentripplanner/street/model/edge/ElevatorBoardEdge.java
Outdated
Show resolved
Hide resolved
| int seconds = this.travelTime > 0 | ||
| ? this.travelTime | ||
| : (int) (preferences.street().elevator().hopTime() * this.levels); | ||
| s1.incrementTimeInMilliseconds(1000L * seconds); |
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.
Use the seconds method here.
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 not fixed. Please use the seconds method
|
I think this PR will be a bit easier to review if you use the |
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.
There is one more call to fix.
| child.time_ms += (traversingBackward ? -milliseconds : milliseconds); | ||
| } | ||
|
|
||
| public void incrementTimeInSeconds(long seconds) { |
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.
Btw does this need to be long?
Summary
The existing State handling code in searches updates the time (integer, seconds) by calculating the time used by each step, rounding it up to the nearest integer, and then updating the total. In well-mapped indoor areas, the steps are small, and there are many of them. In our example problem spot, there are 42 edges in 284 metres. This ends up making the total 35 seconds too long. Our transfers try to be well designed, and we have a 7 minute window for that transfer. It takes 287 seconds to walk that distance, and a 90 second transferSlack. We cannot afford inaccuracies of the order of half a minute.
This PR changes the unit of calculation to milliseconds in the actual traversal, and still uses whole numbers. The granularity of time elsewhere in OTP still mostly stays as one second, to avoid a massive change.
The symmetry of backward and forward changes is preserved. When the same trip is searched backward and forward, the duration is exactly the same both in milliseconds and when rounded to seconds. When a forward search is made, the rounded end time is taken as a start time of a reverse search, the rounded end time of the reverse search is the same as the start time of the forward search, given that that had a millisecond part of zero.
Unit tests
In a large number of tests trip durations have become slightly shorter. This accounts for the large amount of changes to tests.
Changelog
This will be a significant change, because the durations have been incorrect for a long time, and people will notice.
Bumping the serialization version id
Unnecessary.