-
Notifications
You must be signed in to change notification settings - Fork 107
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
Implements the framework for distance based fare calculation #30
Open
skinkie
wants to merge
4
commits into
OneBusAway:master
Choose a base branch
from
plannerstack:distance_based_fare
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
What is this field? It's not included in the original proposal. The "units_traveled" value mentioned in the spec doc is just a place-holder variable that refers to a computed value from the actual trip itinerary (distance traveled in km, zones, etc)
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.
Is your suggestion that shape_dist_traveled is used for this? Given that these things never line up with operator values, my interpretation was that you would give a origin_id and destination_id and mention the number of units_traveled. In such way it would be possible to unambigiously port a A/B matrix into GTFS.
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.
Well, the distance calculation depends on the distance_mode enum:
1 - per-km - distance values will be computed by computing the length of the shape between the two stops. shape_dist_taveled values will be ignored (since they are unit-less) but instead the distance between lat-lon points belonging to the shape will be computed directly. This is necessarily a bit approximate, but should hopefully give the rider a reasonably close value.
2 - per-zone - compute the number of zones traversed by an intinerary
3 - per-stop - compute the number of stops traversed by an itinerary
I'm not sure it makes sense to include a "units_traveled" for each pair of origin_id and destination_id values. If you are going to be including the entire stop-to-stop fare matrix in the GTFS, why would you need distance-based pricing at that point? You could just specify the price as a fare_attribute directly.
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 'approximate' will not work for many agencies. Firstly because some do not even publish shapes, secondly because the shape distance is not used in fare calculation, thirdly rounding errors.
The main reason why we can't publish the price is because of a "startup cost" encoded in "price". The distance-based price is a surplus to that.
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.
Can you describe when "startup cost" is used? If I take a trip from A=>B, with a transfer, followed by B=>C, do I pay the startup cost for the entire trip or just the first leg?
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.
Considering that you are using the same fare system, only the first leg given that your transfer is, within the transfer_duration period.
In the current allows to describe linear relations with respect to distance traveled, but not degenerative relations. The latter (Dutch Railways) we did implement with a cross-product operation on all stops.
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.
In that case, I'd propose the following:
Introduce an additional "distance_mode" enum value:
4 - user-defined distance unit is used, as defined in fare_distances.txt
And introduce a separate fare_distances.txt file with fields:
from_zone_id, to_zone_id, distance_traveled
which would be used to define the A/B matrix of distances.
The main issue here is that I think of fare_rules.txt as defining rules for matching legs and itineraries, while distance_traveled is more of a property of a leg to be matched.