ActivitySim / activitysim

An Open Platform for Activity-Based Travel Modeling
https://activitysim.github.io
BSD 3-Clause "New" or "Revised" License
195 stars 99 forks source link

`num_escortees` Crashed Trip Mode Choice #814

Closed i-am-sijia closed 8 months ago

i-am-sijia commented 9 months ago

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:

  1. 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.
  2. The num_escortees is 1 and it made the DRIVEALONE mode unavailable. This variable is generated in the school escorting model.

To Reproduce Steps to reproduce the behavior:

  1. Use main branch @ff3e96b.
  2. Run full size prototype mtc extended model with 100% household.

Expected behavior Trip mode choice should not crash

i-am-sijia commented 9 months ago

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 -

image

Changing the expression to df.escort_participants.fillna('').apply(lambda x: len(x.split('_')) if len(x)>0 else 0) should fix this bug.

i-am-sijia commented 9 months ago

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.