Use millisecond precision in A* traversal#6436
Merged
tkalvas merged 5 commits intoFeb 17, 2025
Merged
Conversation
tkalvas
marked this pull request as draft
February 6, 2025 10:17
… 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. |
tkalvas
marked this pull request as ready for review
February 10, 2025 08:41
optionsome
requested changes
Feb 10, 2025
| int seconds = this.travelTime > 0 | ||
| ? this.travelTime | ||
| : (int) (preferences.street().elevator().hopTime() * this.levels); | ||
| s1.incrementTimeInMilliseconds(1000L * seconds); |
Member
There was a problem hiding this comment.
Use the seconds method here.
Member
There was a problem hiding this comment.
This is not fixed. Please use the seconds method
Member
|
I think this PR will be a bit easier to review if you use the |
leonardehrenfried
requested changes
Feb 14, 2025
leonardehrenfried
left a comment
Member
There was a problem hiding this comment.
There is one more call to fix.
optionsome
reviewed
Feb 14, 2025
| child.time_ms += (traversingBackward ? -milliseconds : milliseconds); | ||
| } | ||
|
|
||
| public void incrementTimeInSeconds(long seconds) { |
Member
There was a problem hiding this comment.
Btw does this need to be long?
optionsome
approved these changes
Feb 14, 2025
leonardehrenfried
approved these changes
Feb 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.