Skip to content

Commit

Permalink
correct veh type alts for choices
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensle committed Feb 6, 2024
1 parent 15b7f31 commit 2a99bed
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions activitysim/abm/models/vehicle_type_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def construct_model_alternatives(model_settings, alts_cats_dict, vehicle_type_da
alts_wide.set_index(["body_type", "age", "fuel_type"]).index
)
].reset_index()
alts_long.index = alts_wide.index
alts_wide.drop(columns="_merge", inplace=True)

# converting age to integer to allow interactions in utilities
Expand Down Expand Up @@ -427,14 +428,12 @@ def iterate_vehicle_type_choice(
choices.rename(columns={"choice": "vehicle_type"}, inplace=True)

if alts_cats_dict:
alts = (
alts_long[alts_long.columns]
.apply(lambda row: "_".join(row.values.astype(str)), axis=1)
.values
)
alts = alts_long[alts_long.columns].apply(
lambda row: "_".join(row.values.astype(str)), axis=1
).to_dict()
else:
alts = model_spec.columns
choices["vehicle_type"] = choices["vehicle_type"].map(dict(enumerate(alts)))
alts = enumerate(dict(model_spec.columns))
choices["vehicle_type"] = choices["vehicle_type"].map(alts)

# STEP II: append probabilistic vehicle type attributes
if probs_spec_file is not None:
Expand Down

0 comments on commit 2a99bed

Please sign in to comment.