Skip to content
Closed
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
32 changes: 32 additions & 0 deletions activitysim/abm/models/trip_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ class TripDestinationSettings(LocationComponentSettings, extra="forbid"):
fail_some_trips_for_testing: bool = False
"""This setting is used by testing code to force failed trip_destination."""

ALTS_ATTRIBUTES_SAMPLING: list[str] = []
"""List of attributes to include in the alternatives table when sampling.

These columns should exist in the land_use (for regular sampling) or land_use_taz
(for presampling) table. They will be added to the alternatives table, and available
for use in expressions in the model sampling spec.

.. versionadded:: 1.3
"""

@root_validator(pre=True)
def deprecated_destination_prefix(cls, values):
replacements = {
Expand Down Expand Up @@ -242,6 +252,17 @@ def destination_sample(
skims = skim_hotel.sample_skims(presample=False)
alt_dest_col_name = model_settings.ALT_DEST_COL_NAME

alternative_attributes = model_settings.ALTS_ATTRIBUTES_SAMPLING
if alternative_attributes:
land_use = state.get_dataframe("land_use")
alternatives = pd.merge(
alternatives,
land_use[alternative_attributes],
left_index=True,
right_index=True,
how="left",
)

choices = _destination_sample(
state,
primary_purpose,
Expand Down Expand Up @@ -561,6 +582,17 @@ def destination_presample(
network_los.map_maz_to_taz(alternatives.index)
).sum()

alternative_attributes = model_settings.ALTS_ATTRIBUTES_SAMPLING
if alternative_attributes:
land_use_taz = state.get_dataframe("land_use_taz")
alternatives = pd.merge(
alternatives,
land_use_taz[alternative_attributes],
left_index=True,
right_index=True,
how="left",
)

# # i did this but after changing alt_dest_col_name to 'trip_dest' it
# # shouldn't be needed anymore
# alternatives.index.name = ALT_DEST_TAZ
Expand Down