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

School Escorting #574

Merged
merged 62 commits into from
Jan 28, 2023
Merged

School Escorting #574

merged 62 commits into from
Jan 28, 2023

Conversation

dhensle
Copy link
Contributor

@dhensle dhensle commented Jun 23, 2022

School drop-off and pick-up model implementation. Initial design details were presented at the March 8th meeting.

@coveralls
Copy link

coveralls commented Jun 23, 2022

Coverage Status

Coverage remained the same at 0.0% when pulling 3ea0f4b on dhensle:school_escorting into f189143 on ActivitySim:develop.

@JoeJimFlood
Copy link
Contributor

@dhensle I have finished my review. Here are my comments:

It might be good to add a check that NUM_ESCORTEES and NUM_CHAPERONES as defined in the settings file are consistent with the alternatives in school_escorting_alts.csv.

abm/models/school_escorting.py

  • determine_escorting_par[t]icipants()
  • create_school_escorting_bundles_table():
    • Line 215: Since the number of escortees is defined in the settings file, this should probably be for child_num in range(1, NUM_ESCORTEES+1) or something like that
    • Line 225: Just putting 0 here and removing Line 204 would make the code easier to read and more consistent with the field definitions before and after.

abm/models/non_mandatory_scheduling.py

  • create_pure_school_escort_tours and assign_in_place are imported but never called (the latter is imported twice)

abm/models/non_mandatory_destination.py

  • annotate is imported despite not being used

abm/models/non_mandatory_tour_frequency.py

  • Is Line 7 needed given that Line 22 exists? No other functions from school_escort_tours_trips are called

abm/models/trip_purpose.py

  • The function imported in Line 4 is not used

@dhensle
Copy link
Contributor Author

dhensle commented Dec 3, 2022

@JoeJimFlood Thank you for your great comments. I have responded to each in bold below. Can you please review the changes and ensure they are satisfactory? Thanks!

It might be good to add a check that NUM_ESCORTEES and NUM_CHAPERONES as defined in the settings file are consistent with the alternatives in school_escorting_alts.csv.
Agreed, added a new check_alts_consistency method.

abm/models/school_escorting.py

  • determine_escorting_par[t]icipants() fixed name typo
    • Line 40-41: Should model_settings.get() be used to prevent KeyErrors? yes, good catch
    • Line 47: Looks correct to me Thanks for checking. This was a comment to myself when developing. Removed comment.
    • Line 49/59: I agree with the comment that the driving age/escorting age should be configurable, especially if we want ActivitySim to be used outside of the US. If we do go in that direction should we have the mode choice spec files reflect that? added ability to specify options in the model yaml
  • create_school_escorting_bundles_table():
    • Line 215: Since the number of escortees is defined in the settings file, this should probably be for child_num in range(1, NUM_ESCORTEES+1) or something like that yup, missed that one. Good catch.
    • Line 225: Just putting 0 here and removing Line 204 would make the code easier to read and more consistent with the field definitions before and after. I believe we actually do need to initialize before this and not just use 0. We do not want to overwrite what was set in the previous iterations of the loop. Left as is.

abm/models/non_mandatory_scheduling.py

  • create_pure_school_escort_tours and assign_in_place are imported but never called (the latter is imported twice) Removed unused / re-imported references. assign_in_place is actually used on line 50, so I left that one but removed the second import.

abm/models/non_mandatory_destination.py

  • annotate is imported despite not being used I see it used on line 119?

abm/models/non_mandatory_tour_frequency.py

  • Is Line 7 needed given that Line 22 exists? No other functions from school_escort_tours_trips are called Nope, removed line 7.

abm/models/trip_purpose.py

  • The function imported in Line 4 is not used Removed. No idea where this came from.

@JoeJimFlood
Copy link
Contributor

@dhensle Everything looks good to me. Thank you so much for your work on this!

242323665,644477,386761,shopping,1,True,1,24,16,30290458,,,shopping,,12,WALK,2.6242779649960877
242323669,644477,386761,shopping,1,False,1,16,24,30290458,,,home,,15,WALK,2.1220846081768716
242323977,644478,386761,school,1,True,1,20,16,30290497,644478,outbound,school,,9,WALK_LOC,1.5478828044209911
242323981,644478,386761,school,1,False,1,16,20,30290497,644478,inbound,home,,21,WALK_LRF,3.7659908084629183
Copy link
Member

Choose a reason for hiding this comment

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

I notice here that there appears to be an inconsistency between trip mode choice of chauffeur and escortee. Trip 242323629 is chauffeur escorting a child home from school, trip 242323981 is the child being escorted. Purpose, destination, schedule all line up as intended. But the chauffeur is driving (SHARED2FREE) while the child is using transit (WALK_LRF). Reviewing the various code changes, it looks like this discrepancy is not a bug in code that has been written, but just something that has not been locked down; I don't recall if this is an intentional or unintentional omission.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Post-processing functionality has been added to force escortee tour and trip modes to match the chauffeur modes. For tour modes, there is ambiguity as the tour mode for the outbound leg can be different for the inbound leg since the pickup/dropoff can happen on different chauffeur tours. (The current implementation just uses the last available chauffeur tour mode. Maybe a mode heirarchy should be implemented? But this would have to change between modeling regions...) I am not sure it really matters considering the trip modes are made to match downstream.

@jpn-- jpn-- added this to the Phase 7 milestone Dec 13, 2022
return alts


def read_spec_file(file_name, set_index=None):
Copy link
Member

Choose a reason for hiding this comment

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

It looks like read_alts_file and read_spec_file are identical. Shall we use only one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, only one is needed. And this was actually caught in the flexible trip and tour id's review. Resolved when merging in changes from develop branch.

util_chauf2_time_to_work_or_univ_rs,Chauffer 2 Auto time to work or university - Ride Share,time_mand_to_home2 * ((chauf1 == 3) | (chauf2 == 3) | (chauf3 == 3)),coef_chauf_time_to_work_or_univ_rs
util_chauf1_walk_dist_to_work_or_univ_rs,Chauffer 1 Walk dist to work or university - Ride Share,(dist_mand1_to_home < 3) & ((chauf1 == 1) | (chauf2 == 1) | (chauf3 == 1)),coef_chauf_walk_dist_to_work_or_univ_rs
util_chauf2_walk_dist_to_work_or_univ_rs,Chauffer 2 Walk dist to work or university - Ride Share,(dist_mand2_to_home < 3) & ((chauf1 == 3) | (chauf2 == 3) | (chauf3 == 3)),coef_chauf_walk_dist_to_work_or_univ_rs
util_chauf1_walk_dist_to_work_or_univ_pe,Chauffer 1 Walk dist to work or university - Pure Escort,(dist_home1_to_mand < 3) & ((chauf1 == 2) | (chauf2 == 2) | (chauf3 == 2)),coef_chauf_walk_dist_to_work_or_univ_pe
Copy link
Member

Choose a reason for hiding this comment

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

There's an error in the escorting spec here. dist_home1_to_mand isn't a valid variable, it should be dist_home_to_mand1. And again on the following line for "2". When running in normal simulation mode the error is avoided and our test can pass this module, as the coefficient on this line happens to be set to 0 in the associated coefficients file. But this will cause errors if run in estimation mode or with sharrow enabled, neither of which is currently tested for the school escorting model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed. It looks like the outbound and conditional outbound spec files did not have this error.

@jpn-- jpn-- merged commit db4db8c into ActivitySim:develop Jan 28, 2023
@dhensle dhensle deleted the school_escorting branch February 22, 2024 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants