activitysim icon indicating copy to clipboard operation
activitysim copied to clipboard

DEST_CHOICE_LOGSUM_COLUMN_NAME Is Not Optional

Open danielsclint opened this issue 5 years ago • 1 comments

In the non-mandatory tour destination and joint tour destination setting YAML (for the MTC example), it indicates that the logsums for the destination choice can optionally be included in the resultant choice dataframe.

https://github.com/ActivitySim/activitysim/blob/05a25f687e0c151c5a3bcbf4428d2b58dd2cc4f7/activitysim/examples/example_mtc/configs/non_mandatory_tour_destination.yaml#L12-L13

The code seems to suggest the same in the joint_tour_destination.py. (See line 207)

https://github.com/ActivitySim/activitysim/blob/05a25f687e0c151c5a3bcbf4428d2b58dd2cc4f7/activitysim/abm/models/joint_tour_destination.py#L203-L213

However, if the option of want_logsum=False is set, the choice column name in the resultant choice dataframe remains named the ALT_DEST_COL_NAME defined in the YAML. (want_logsum is set to False by not specifying the optional DEST_CHOICE_LOGSUM_COLUMN_NAME in the YAML.)

This choice column is later hard coded as 'choice' when identifying the destination zone.

https://github.com/ActivitySim/activitysim/blob/05a25f687e0c151c5a3bcbf4428d2b58dd2cc4f7/activitysim/abm/models/joint_tour_destination.py#L383

The renaming of the field to choice can only happen if the want_logsum is True which requires the DEST_CHOICE_LOGSUM_COLUMN_NAME value to be set in the YAML file. (See line 269)

https://github.com/ActivitySim/activitysim/blob/05a25f687e0c151c5a3bcbf4428d2b58dd2cc4f7/activitysim/core/interaction_sample_simulate.py#L268-L270

danielsclint avatar Aug 27 '20 21:08 danielsclint

Yes this is a bug I will fix in develop.

need to add the following to end of run_destination_logsums() in joint_tour_destination .py

    if not want_logsums:
       # for consistency, always return a dataframe with canonical column name
       assert isinstance(choices, pd.Series)
       choices = choices.to_frame('choice')

    return choices

toliwaga avatar Sep 04 '20 13:09 toliwaga