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

PT headways #102

Merged
merged 18 commits into from
Dec 13, 2021
Merged

PT headways #102

merged 18 commits into from
Dec 13, 2021

Conversation

KasiaKoz
Copy link
Collaborator

@KasiaKoz KasiaKoz commented Nov 30, 2021

MATSim requires explicit trips with vehicles for all PT Services​. Sometimes we only know the headway in a time bracket for a service, this PR adds a few new convenience methods to:

  • Update existing trips using headway information [ref for a Route object] [ref for Route called within a Schedule object]
  • Create new Services using headway information [ref]
  • Compute headway information between each trip for each route and present it as a pandas.DataFrame [ref]
  • Compute headway stats summary (mean, min, max, etc) for each route and present it as a pandas.DataFrame [ref]

This will help with generating PT scenarios.

The headway specification is a dictionary in this format: (time_from, time_to): headway in minutes, e.g.​

{('01:00:00', '02:00:00'): 20, ​
 ('02:00:00', '03:00:00'): 30}​

Will come out with these trips:​

['route_ID_01:00:00', 
 'route_ID_01:20:00', 
 'route_ID_01:40:00', 
 'route_ID_02:00:00', 
 'route_ID_02:30:00', 
 'route_ID_03:00:00']

This can be more complicated with only some trips being injected among an existing set of trips to try and match a headway, but we propose this simple addition to current functionality for the time being.

Copy link
Contributor

@gac55 gac55 left a comment

Choose a reason for hiding this comment

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

Clarification question.

Does this implement a given headway across the entire day uniformly? I can imagine this having unintended consequences, for example, creating services early in the morning or late at night that we may not want. Does this make that configurable?

@@ -598,6 +610,16 @@ def routes(self):
yield self

def route_trips_with_stops_to_dataframe(self, gtfs_day='19700101'):
"""
This method exists for backwards compatibility only
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@KasiaKoz
Copy link
Collaborator Author

@gac55

Does this implement a given headway across the entire day uniformly?

The headway specification is a dictionary in this format: (time_from, time_to): headway in minutes, e.g.​

{('01:00:00', '02:00:00'): 20, ​
 ('02:00:00', '03:00:00'): 30}​

the spec requires you to specify the temporal bound, you can have various headways across the day. And then of course for a uniform headway in a day you can just specify

{('00:00:00', '23:59:59'): 20}​

I updated my PR description with this, pretty big omission on my part, soz

Copy link
Contributor

@gac55 gac55 left a comment

Choose a reason for hiding this comment

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

Excellent, understood now. 🚀

@KasiaKoz KasiaKoz merged commit 21815a5 into master Dec 13, 2021
@KasiaKoz KasiaKoz deleted the pt-headways branch December 13, 2021 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants