Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle Type Optimization #66

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions activitysim/abm/models/vehicle_type_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ def iterate_vehicle_type_choice(
model_settings, alts_cats_dict, vehicle_type_data
)

# alts preprocessor
alts_preprocessor_settings = model_settings.alts_preprocessor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be model_settings.get("alts_preprocessor", None)

if alts_preprocessor_settings:
expressions.assign_columns(
state,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No state variable in this code base. This argument should be removed.

df=alts_wide,
model_settings=alts_preprocessor_settings,
locals_dict=locals_dict,
trace_label=trace_label,
)

# - preparing choosers for iterating
vehicles_merged = vehicles_merged.to_frame()
vehicles_merged["already_owned_veh"] = ""
Expand Down Expand Up @@ -380,6 +391,12 @@ def iterate_vehicle_type_choice(
len(choosers),
)

# filter columns of alts and choosers
if len(model_settings.get("COLS_TO_INCLUDE_IN_CHOOSER_TABLE")) > 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to set default for get function to be array. i.e. model_settings.get("COLS_TO_INCLUDE_IN_CHOOSER_TABLE", []). Here and below.

choosers = choosers[model_settings.get("COLS_TO_INCLUDE_IN_CHOOSER_TABLE")]
if len(model_settings.get("COLS_TO_INCLUDE_IN_ALTS_TABLE")) > 0:
alts_wide = alts_wide[model_settings.get("COLS_TO_INCLUDE_IN_ALTS_TABLE")]

# if there were so many alts that they had to be created programmatically,
# by combining categorical variables, then the utility expressions should make
# use of interaction terms to accommodate alt-specific coefficients and constants
Expand Down
Loading