activitysim icon indicating copy to clipboard operation
activitysim copied to clipboard

PNUM hard-coded and Vehicle table creation bug fix

Open dhensle opened this issue 5 months ago • 0 comments
trafficstars

Fixes for #951 and #952

This pull request addresses robustness and fallback mechanisms in the activitysim codebase by ensuring proper handling of missing columns (PNUM and auto_ownership) in key functions. The changes improve the stability and reliability of the model by adding conditional checks and alternative logic.

Enhancements to column handling:

  • joint_tour_frequency_composition.py: Added a fallback mechanism to handle cases where the PNUM column is missing. If PNUM is unavailable, the first person in each household is selected using stable ordering and grouping by household_id.

  • joint_tour_participation.py: Introduced logic to create a PNUM column dynamically for candidates if it is missing, ensuring that participant IDs can still be assigned correctly.

  • vehicles.py: Added a check for the presence of the auto_ownership column in the households DataFrame. If missing, the function retrieves the proto_households table as a fallback to ensure compatibility during disaggregate accessibility calculations.

dhensle avatar Jun 11 '25 23:06 dhensle