activitysim
activitysim copied to clipboard
`num_escortees` Crashed Trip Mode Choice
Describe the bug The benchmarking run with full size MTC extended model crashed in trip mode choice in both Sharrow and non-Sharrow model, crashed in the same household, same trips.
Traced this household, it is crashed when trying to choose the trip modes for a school tour with 2 trips, the first trip is home-school and the second trip is school-home. The tour mode is DRIVEALONEFREE. Attaching relevant trip mode choice trace files.
trip_mode_choice_annotate_trips_preprocessor-fd6943.csv expression_values-fd6943.csv expression_value_DRIVEALONEFREE-fd6943.csv choosers-fd6943.csv raw_utilities-fd6943.csv
Two things seem odd:
- This 17-year old children has a highschool location that is 146 miles away from home. (home zone 1402, school zone 690). This is possibly some bug in the location choice, will open separate issues. This created -77 utils although it did not made the DRIVEALONE mode unavailable.
- The
num_escorteesis 1 and it made the DRIVEALONE mode unavailable. This variable is generated in the school escorting model.
To Reproduce Steps to reproduce the behavior:
- Use main branch @ff3e96b.
- Run full size prototype mtc extended model with 100% household.
Expected behavior Trip mode choice should not crash
The bug is in the trip_mode_choice_annotate_trips_preprocessors.csv.
There is this expression df.escort_participants.fillna('').apply(lambda x: len(x.split('_'))) that creates num_escortees.
It is wrong and never results in 0 when the escort_participants is missing or is an empty string. Because -
Changing the expression to df.escort_participants.fillna('').apply(lambda x: len(x.split('_')) if len(x)>0 else 0) should fix this bug.
The fix was made to the https://github.com/ActivitySim/activitysim-prototype-mtc/commit/9ca05ca81a240cc74bfd764b1d859b55dbf597e0. The model was able to run through successfully. @jpn-- I did not change the version in this repo, given that we possibly want to discontinue hosting prototype_mtc in this repo.