Skip to content

Commit

Permalink
Merge pull request #66 from SANDAG/BayDAG_estimation_vehtypefix
Browse files Browse the repository at this point in the history
Vehicle Type Optimization
  • Loading branch information
JoeJimFlood authored Mar 29, 2024
2 parents 627e286 + 74833cb commit 2c11873
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 2c11873

Please sign in to comment.