Skip to content

Remove itineraries outside the search window in arriveBy search - #5433

Merged
t2gran merged 6 commits into
opentripplanner:dev-2.xfrom
entur:otp2_fix_prev_page_arrive_by_true
Nov 13, 2023
Merged

Remove itineraries outside the search window in arriveBy search#5433
t2gran merged 6 commits into
opentripplanner:dev-2.xfrom
entur:otp2_fix_prev_page_arrive_by_true

Conversation

@t2gran

@t2gran t2gran commented Oct 16, 2023

Copy link
Copy Markdown
Member

Summary

Paging does not work with arriveBy=true. The searchWindow latest-depature-time is not enforced, when paging. For more info, see issue.

Issue

Closes #5432

Unit tests

This PR updates the filter unit-tests, but I have not added an integration test for the itinerary.

Documentation

JavaDoc is updated, other doc is not changed.

Changelog

Bumping the serialization version id

Not needed

@t2gran t2gran added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Oct 16, 2023
@t2gran t2gran added this to the 2.5 (next release) milestone Oct 16, 2023
@t2gran
t2gran requested a review from a team as a code owner October 16, 2023 19:24
@codecov

codecov Bot commented Oct 16, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (a9b0151) 66.80% compared to head (299520c) 66.80%.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5433      +/-   ##
=============================================
- Coverage      66.80%   66.80%   -0.01%     
- Complexity     15557    15563       +6     
=============================================
  Files           1806     1806              
  Lines          69821    69839      +18     
  Branches        7357     7359       +2     
=============================================
+ Hits           46646    46653       +7     
- Misses         20718    20729      +11     
  Partials        2457     2457              
Files Coverage Δ
...m/filterchain/ItineraryListFilterChainBuilder.java 90.32% <100.00%> (+0.32%) ⬆️
...ain/deletionflagger/OutsideSearchWindowFilter.java 100.00% <100.00%> (ø)
...rithm/mapping/RouteRequestToFilterChainMapper.java 78.43% <100.00%> (ø)
...entripplanner/routing/algorithm/RoutingWorker.java 75.20% <89.47%> (-5.51%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java Outdated
Comment thread src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java Outdated

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've only noticed typos.

Co-authored-by: Leonard Ehrenfried <mail@leonard.io>
@jtorin

jtorin commented Oct 18, 2023

Copy link
Copy Markdown
Contributor

I can confirm that we are affected by this issue as well.

I can also confirm that the PR resolves the problem except for the detail that the arrival time must be increased by one minute to include the same trip/result on the first search,

I have reviewed the PR but I am unable to spot a change in the code that could induce this .

Common info

Search parameters are as follows, only arrival time is changed:
image

Behavior before patching

Search on exact boundary, 6:05

“0 Itineraries Returned”

Search on boundary + 1, 6:06

image

Select “Previous”:
image
(same repeated four times)

Then:
image
image

Behavior after patching

Search on exact boundary, 6:05

“0 Itineraries Returned”, as before.

Search on boundary + 1, 6:06

“0 Itineraries Returned”, before trips was presented.

Search on boundary + 2, 6:07

image

Selecting “Previous” generates “0 Itineraries Returned” twice, then:
image

Conclusion

Duplicate entries are not presented any longer, but arrival time must be increased by one minute to give the same result as before.

Co-authored-by: Johan Torin <jtorin@users.noreply.github.com>
@t2gran

t2gran commented Oct 27, 2023

Copy link
Copy Markdown
Member Author

I can also confirm that the PR resolves the problem except for the detail that the arrival time must be increased by one minute to include the same trip/result on the first search

This is not an attempt to fix this. It only fixes the bug in the searchWindow itinerary filter. @eibakke is working on a fix to the paging logic.

@t2gran t2gran changed the title Duplicate itineraries when paging in arriveBy search Remove itineraries outside the search window in arriveBy search Oct 28, 2023
@t2gran

t2gran commented Oct 28, 2023

Copy link
Copy Markdown
Member Author

@jtorin I have updated the title of this PR - it was confusing.

@t2gran

t2gran commented Oct 31, 2023

Copy link
Copy Markdown
Member Author

@jtorin I studied the test results again. There is not enough information to tell if the above is an error or not - I do not see that it is related to the thing I have fixed. The debug UI only show minutes, so when walking to the destination it is likely that you arrive there 06:05:01 witch would be to late if the dateTime is set to 06:05:00.

So, my question is - is the test you have above working on the current version of OTP?

There are another thing tat looks strange in the result as well. There is a very long wait time between the access walk and the transit - to me this is an indication that the search-window is incorrect calculated on the server.

@t2gran
t2gran requested a review from Bartosz-Kruba October 31, 2023 16:49
@leonardehrenfried

Copy link
Copy Markdown
Member

You need to resolve the conflicts.

@leonardehrenfried

Copy link
Copy Markdown
Member

@Bartosz-Kruba will review.

…rive_by_true

# Conflicts:
#	src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java
#	src/main/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainBuilder.java
#	src/main/java/org/opentripplanner/routing/algorithm/mapping/RouteRequestToFilterChainMapper.java
@jtorin

jtorin commented Nov 6, 2023

Copy link
Copy Markdown
Contributor

So, my question is - is the test you have above working on the current version of OTP?

Yes.

On dev:

(same commit as the latest merge)

(version: 2.5.0-SNAPSHOT, ser.ver.id: 123, commit: a9b0151, branch: a9b0151) using Java 21.0.1

Results comes first when searching from 6:06.

With PR:

(version: 2.5.0-SNAPSHOT, ser.ver.id: 123, commit: 299520c, branch: entur/otp2_fix_prev_page_arrive_by_true) using Java 21.0.1

Results comes first when searching from 6:07.


Otherwise same data and config.

@jtorin

jtorin commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

@t2gran

t2gran commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

Thank you @jtorin for the findings and the data. I suggest we merge this and look into the bug after #5436 and #5458 is merged. Our client team have reported other bugs on this as well and it is just not possible to test this properly without merging all these fixes. Currently we had to turn "arriveBy" off, because it does not work - so, the one missed trip is a minor thing compared to the other errors.

The only explanation I have for the behaviour you have reported is that in that there is something wrong with the heuristic. I find the result a bit odd because of the wait time after the access walk - this does not look right.

Another tip is to turn off the itinerary filter, then if the trip is removed by the search-window-filter it should say so - all trips are retuned and deleted trips are tagged with the filter(s) deleting it.

@jtorin

jtorin commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Another tip is to turn off the itinerary filter, then if the trip is removed by the search-window-filter it should say so - all trips are retuned and deleted trips are tagged with the filter(s) deleting it.

Yes, as expected the missing trip is returned tagged 'outside-search-window'. Increasing the search-window drastically will eventually produce other trips from the previous day. I guess the search-window is only (and obviously) increased backwards in time, not that one second forwards that is required to find the suppressed trip.

Still, it's nevertheless interesting that the trip is found and filtered, shows that perhaps the search is correct but the filtering not.

@t2gran
t2gran merged commit 71776a0 into opentripplanner:dev-2.x Nov 13, 2023
@t2gran
t2gran deleted the otp2_fix_prev_page_arrive_by_true branch November 13, 2023 17:59
t2gran pushed a commit that referenced this pull request Nov 13, 2023
@t2gran

t2gran commented Nov 20, 2023

Copy link
Copy Markdown
Member Author

@jtorin I have tested the reported case with #5458 today. I promised to come back to this.

First - The exact arrival time is 6:05:26 am (1697688326000 EPOCH) (use the browser developer tools). So if you set the arrival-time to 06:05, then the expected result should be NOT FOUND.

Duplicate entries are not presented any longer, but arrival time must be increased by one minute to give the same result as before.

"but arrival time must be increased" this is a bug in the old version of OTP, as explained above - when setting the arrival time to 06:05:00 - you should not get a result.

@t2gran

t2gran commented Nov 20, 2023

Copy link
Copy Markdown
Member Author

There is still a problem with the arriveBy search and paging. I am looking into this.

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.

Duplicate itineraries when paging in arriveBy search

4 participants