activitysim
activitysim copied to clipboard
PNUM hard-coded and Vehicle table creation bug fix
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 thePNUMcolumn is missing. IfPNUMis unavailable, the first person in each household is selected using stable ordering and grouping byhousehold_id. -
joint_tour_participation.py: Introduced logic to create aPNUMcolumn 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 theauto_ownershipcolumn in thehouseholdsDataFrame. If missing, the function retrieves theproto_householdstable as a fallback to ensure compatibility during disaggregate accessibility calculations.