fix(estimation): correct the participant_num assignment logic for estimation mode in joint tour participation #1008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes two related issues in the joint-tour code paths:
joint_tour_participation.py(8f13299)Problem: In estimation mode, the code could re-assign participant_num rather than using the original survey participant_num, which could change the identity of the tour leader (ActivitySim treats participant_num == 1 as the tour leader). This broke association of the joint tour with the correct person.
Fix: When running in estimation mode, we now merge participant_num from the survey's joint_tour_participants table by participant_id so the original participant numbering (and the tour leader) is preserved.
joint_tour_frequency.py(2e7629e)Problem: The code assumed a PNUM column existed; where PNUM was missing, code could fail or behave unpredictably.
Fix: If PNUM is missing, the code now selects the first person in the household to act as the PNUM (keeps behavior deterministic and prevents failures).
cc: @dhensle