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

Keep at least one result for min-transfers and each transit-group in itinerary-group-filter #5919

Merged

Conversation

t2gran
Copy link
Member

@t2gran t2gran commented Jun 19, 2024

Summary

The MaxLimit filter in GroupByFilter in the ItineraryListFilterChain did only look at generalized-cost when it reduced the number of itineraries in each group. This problematic because the itinerary with the best number of transfers or good alternatives for transit-groups could be lost. The new McMaxLimit filter will look at all pareto criterias used in the Raptor search and keep at least one optimal result for each criteria, before limiting the result to N itineraries.

To enable this the OTPFeature.MultiCriteriaGroupMaxFilter must be set in otp-config.json.

Issue

There is no issue for this, but one case we have seen at Entur is:

Skjermbilde 2024-06-19 kl  14 31 43

The alternative with two legs with the same agency is filtered away, in favor of a slightly better cost alternative with two legs with different agencies. The first leg is the same, but because of the switch to another agency the customer has to bye two tickets and have no guarantee in case of delays. So we want both options to be shown.

This is related to #5436 and #3833.

Unit tests

✅ All new business logic has unit-tests with 100% coverage.

Documentation

✅ There is extensive JavaDoc documentation, and a little bit of explaination on the new OTPFeature to enable this behaivour. OTP will work as before, if the feature is not enabled in config.

Changelog

✅ This is a minor improvment

Bumping the serialization version id

🟥 Not needed

@t2gran t2gran added Improvement Entur Test This is currently being tested at Entur Config Change labels Jun 19, 2024
@t2gran t2gran requested a review from a team as a code owner June 19, 2024 13:05
@t2gran t2gran added this to the 2.6 (next release) milestone Jun 19, 2024
@t2gran t2gran changed the title Otp2 transit priority in group filter Keep at least one min-transfers and one result for each transit-group in itinerary-group-filter Jun 19, 2024
@t2gran t2gran changed the title Keep at least one min-transfers and one result for each transit-group in itinerary-group-filter Keep at least one result for min-transfers and each transit-group in itinerary-group-filter Jun 19, 2024
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 13 lines in your changes missing coverage. Please review.

Project coverage is 69.70%. Comparing base (03dae4e) to head (fd33464).

Files Patch % Lines
...m/filterchain/ItineraryListFilterChainBuilder.java 35.71% 8 Missing and 1 partial ⚠️
...rithm/mapping/RouteRequestToFilterChainMapper.java 0.00% 1 Missing and 1 partial ⚠️
...iority/TransitGroupPriorityItineraryDecorator.java 0.00% 1 Missing ⚠️
...orithm/filterchain/filters/system/mcmax/State.java 98.78% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5919      +/-   ##
=============================================
+ Coverage      69.65%   69.70%   +0.05%     
- Complexity     17156    17224      +68     
=============================================
  Files           1942     1947       +5     
  Lines          73786    73939     +153     
  Branches        7550     7573      +23     
=============================================
+ Hits           51397    51541     +144     
- Misses         19759    19765       +6     
- Partials        2630     2633       +3     

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

@t2gran
Copy link
Member Author

t2gran commented Jun 21, 2024

This PR is improving the group-by filter, reminding improvements is documented her #5923

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

I typical Thomas fashion this is using very clean coding practises and is well tested and documented. Nevertheless, I picked up on a few smaller issues.

@leonardehrenfried leonardehrenfried marked this pull request as draft June 27, 2024 13:29
t2gran added a commit to entur/OpenTripPlanner-LegacyHSLFork that referenced this pull request Jul 4, 2024
@t2gran t2gran marked this pull request as ready for review July 23, 2024 13:38
@t2gran
Copy link
Member Author

t2gran commented Jul 23, 2024

The merge does not look ok - I will try to do it one more time...

@leonardehrenfried
Copy link
Member

You apparently formatted all files in the client folder. I'm sure that wasn't intentional.

@t2gran t2gran force-pushed the otp2_transit_priority_in_group_filter branch from bb1d4a1 to fd33464 Compare July 23, 2024 13:57
@t2gran
Copy link
Member Author

t2gran commented Jul 23, 2024

I noticed, probably did it as part of comitting from IntelliJ. Did the merge again, but now using git from the command line.

@@ -10,7 +10,7 @@ public final class DefaultTransitGroupPriorityCalculator
implements RaptorTransitGroupPriorityCalculator {

@Override
public int mergeGroupIds(int currentGroupIds, int boardingGroupId) {
public int mergeInGroupId(int currentGroupIds, int boardingGroupId) {
Copy link
Member

Choose a reason for hiding this comment

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

What does it mean to "merge in a group id" rather than merging two group ids? I would assuming that "merging in" modifies an existing instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

The first argument is a set of group ids, not singular.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess both names work, but the name should match the JavaDoc:

/**
   * Merge in the transit group id with an existing set. Note! Both the set
   * and the group id type is {@code int}.
   *
   * @param currentGroupIds the set of groupIds for all legs in a path.
   * @param boardingGroupId the transit group id to add to the given set.
   * @return the new computed set of groupIds
   */

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

I have a question about the renaming of "mergeInGroupId" method.

@t2gran t2gran merged commit ed3651a into opentripplanner:dev-2.x Jul 26, 2024
5 checks passed
t2gran pushed a commit that referenced this pull request Jul 26, 2024
@t2gran t2gran deleted the otp2_transit_priority_in_group_filter branch October 9, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Config Change Entur Test This is currently being tested at Entur Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants