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 all 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
16 changes: 16 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,16 @@ def iterate_vehicle_type_choice(
model_settings, alts_cats_dict, vehicle_type_data
)

# alts preprocessor
alts_preprocessor_settings = model_settings.get("alts_preprocessor", None)
if alts_preprocessor_settings:
expressions.assign_columns(
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 +390,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:
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