Skip to content

Add cost of egress leg to the cost of the last transit leg if transit leg arrives at destination#4547

Merged
MikaelJarfors merged 10 commits into
opentripplanner:dev-2.xfrom
Skanetrafiken:egress-cost-on-final-transit-leg
Nov 8, 2022
Merged

Add cost of egress leg to the cost of the last transit leg if transit leg arrives at destination#4547
MikaelJarfors merged 10 commits into
opentripplanner:dev-2.xfrom
Skanetrafiken:egress-cost-on-final-transit-leg

Conversation

@MikaelJarfors
Copy link
Copy Markdown
Contributor

@MikaelJarfors MikaelJarfors commented Oct 26, 2022

Closes #4546

@leonardehrenfried
Copy link
Copy Markdown
Member

leonardehrenfried commented Oct 26, 2022

I think you want to add more documentation why a leg with duration 0 has a non-zero cost but other than that I think this is reasonable. However, @t2gran and @hannesj are the experts in this field.

@hannesj
Copy link
Copy Markdown
Contributor

hannesj commented Oct 26, 2022

Could you fix the formatting issue by running mvn compile. It is also possible to set up IntelliJ to do it automatically on save, as described in the docs

EDIT: Seems that the docs are outdated, you can use the internal prettier plugin to format the code nowdays

@MikaelJarfors MikaelJarfors force-pushed the egress-cost-on-final-transit-leg branch from 28fd74f to 6fe4a36 Compare October 26, 2022 14:43
@MikaelJarfors
Copy link
Copy Markdown
Contributor Author

@hannesj The coding style should be fixed now - was just some whitespace.

Have you had a look at the idea behind this?

@t2gran t2gran added this to the 2.2 milestone Nov 1, 2022
@t2gran t2gran marked this pull request as ready for review November 1, 2022 09:51
@t2gran t2gran requested a review from a team as a code owner November 1, 2022 09:51
@t2gran t2gran added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Nov 1, 2022
@leonardehrenfried
Copy link
Copy Markdown
Member

We discussed this in the dev meeting last week. The general idea behind this is good but @MikaelJarfors will create a better encapsulation so it's clearer what is happening and why.

@t2gran t2gran modified the milestones: 2.2, 2.3 Nov 1, 2022
@Bartosz-Kruba Bartosz-Kruba added the Skanetrafiken On skanetrafikens roadmap label Nov 3, 2022
@MikaelJarfors
Copy link
Copy Markdown
Contributor Author

@hannesj and @leonardehrenfried I have encapsulated the zero duration logic and added a test for this specific functionality!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Base: 59.98% // Head: 60.46% // Increases project coverage by +0.48% 🎉

Coverage data is based on head (6573b0d) compared to base (e437493).
Patch coverage: 93.75% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #4547      +/-   ##
=============================================
+ Coverage      59.98%   60.46%   +0.48%     
- Complexity     11990    12116     +126     
=============================================
  Files           1562     1574      +12     
  Lines          62358    63279     +921     
  Branches        6986     7004      +18     
=============================================
+ Hits           37405    38263     +858     
- Misses         22794    22837      +43     
- Partials        2159     2179      +20     
Impacted Files Coverage Δ
...algorithm/mapping/RaptorPathToItineraryMapper.java 73.01% <92.30%> (+2.52%) ⬆️
.../algorithm/raptoradapter/router/TransitRouter.java 75.89% <100.00%> (ø)
...thm/raptoradapter/transit/DefaultAccessEgress.java 63.15% <100.00%> (+2.04%) ⬆️
...va/org/opentripplanner/framework/io/FileUtils.java 45.00% <0.00%> (-16.54%) ⬇️
...in/java/org/opentripplanner/model/UpdateError.java 80.64% <0.00%> (-15.01%) ⬇️
...lapi/datafetchers/LegacyGraphQLTicketTypeImpl.java 35.29% <0.00%> (-14.71%) ⬇️
...lanner/transit/raptor/service/DebugHeuristics.java 0.00% <0.00%> (-8.70%) ⬇️
...transit/raptor/api/transit/RaptorAccessEgress.java 91.66% <0.00%> (-8.34%) ⬇️
...er/transit/raptor/service/HeuristicSearchTask.java 66.66% <0.00%> (-6.07%) ⬇️
...opentripplanner/ext/fares/model/FareAttribute.java 57.89% <0.00%> (-5.75%) ⬇️
... and 158 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

}

@Override
public boolean stopReachedOnBoard() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method has another meaning, which we shouldn't override. It is used to signal that an access or egress departs onboard a vehicle (currently only flex), and those generally have a duration greater than zero. See Javadoc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok - that is fine - I will make a new method for this functionality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To be honest with you Hannes - I read the java docs and thought it suited this perfectly. I will revise the Javadoc to make it closer to its actual use.

Copy link
Copy Markdown
Contributor

@hannesj hannesj Nov 4, 2022

Choose a reason for hiding this comment

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

Yes, in the egress case it isn't described correctly. It should say that if it is an access, it is true if the access arrives onboard a vehicle to the stop, and in case of egress if the egress leaves the stop onboard a vehicle. In this case there is no egress at all, since the destination is the stop in question.

// leg given that it is the last leg.
int lastLegCost = 0;
PathLeg<T> nextLeg = pathLeg.nextLeg();
if (nextLeg.isEgressLeg() && nextLeg.asEgressLeg().egress().stopReachedOnBoard()) {
Copy link
Copy Markdown
Member

@leonardehrenfried leonardehrenfried Nov 4, 2022

Choose a reason for hiding this comment

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

Rather than checking if the last leg was reached on board, would it not make sense to somehow check that the alight penalty has been shifted from the transit leg to the egress one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This check is needed in order to choose whether to shift the cost from one leg to the other - so it is difficult to do this the other way around.

Have I interpreted you correctly?

Copy link
Copy Markdown
Member

@leonardehrenfried leonardehrenfried Nov 7, 2022

Choose a reason for hiding this comment

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

My question is: do we only want to shift the cost back only if the egress leg is empty/zero duration?

Could there not be an egress leg with a short walking duration, say at a cost of 100, that still has a -3000 penalty, so we end up with a leg with a cost of -2900?

@leonardehrenfried leonardehrenfried changed the title Add cost of egress leg to the cost of the last transit leg if transit… Add cost of egress leg to the cost of the last transit leg if transit leg arrives at destination Nov 8, 2022
@MikaelJarfors MikaelJarfors merged commit e011673 into opentripplanner:dev-2.x Nov 8, 2022
t2gran pushed a commit that referenced this pull request Nov 8, 2022
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. Skanetrafiken On skanetrafikens roadmap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OtherThanSameLegsMaxGeneralizedCostFilter filters out all legs if egress leg has a negative cost

6 participants