Skip to content

Commit

Permalink
enabling compute settings for trip scheduling choice
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed May 13, 2024
1 parent 28fdbb6 commit 9ad1d0d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions activitysim/abm/models/trip_scheduling_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
get_time_windows,
)
from activitysim.core import chunk, expressions, simulate, tracing, workflow
from activitysim.core.configuration.base import PreprocessorSettings, PydanticReadable
from activitysim.core.configuration.base import (
ComputeSettings,
PreprocessorSettings,
PydanticReadable,
)
from activitysim.core.interaction_sample_simulate import _interaction_sample_simulate
from activitysim.core.skim_dataset import SkimDataset
from activitysim.core.skim_dictionary import SkimDict
Expand Down Expand Up @@ -223,6 +227,7 @@ def run_trip_scheduling_choice(
skims,
locals_dict: Mapping,
trace_label: str,
model_settings: TripSchedulingChoiceSettings,
):
NUM_TOUR_LEGS = 3
trace_label = tracing.extend_trace_label(trace_label, "interaction_sample_simulate")
Expand Down Expand Up @@ -296,6 +301,7 @@ def run_trip_scheduling_choice(
trace_choice_name="trip_schedule_stage_1",
estimator=None,
chunk_sizer=chunk_sizer,
compute_settings=model_settings.compute_settings,
)

assert len(choices.index) == len(choosers.index)
Expand Down Expand Up @@ -338,6 +344,9 @@ class TripSchedulingChoiceSettings(PydanticReadable, extra="forbid"):
SPECIFICATION: str
"""file name of specification file"""

compute_settings: ComputeSettings = ComputeSettings()
"""Compute settings for this component."""


@workflow.step
def trip_scheduling_choice(
Expand Down Expand Up @@ -419,7 +428,13 @@ def trip_scheduling_choice(
)

tours_df = run_trip_scheduling_choice(
state, spec, tours_df, skims, locals_dict, trace_label
state,
spec,
tours_df,
skims,
locals_dict,
trace_label,
model_settings,
)

state.add_table("tours", tours_df)
2 changes: 1 addition & 1 deletion activitysim/core/interaction_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def _interaction_sample(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=compute_settings.protect_columns,
additional_columns=["tdd"] + compute_settings.protect_columns,
)

if sharrow_enabled:
Expand Down
2 changes: 1 addition & 1 deletion activitysim/core/interaction_sample_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _interaction_sample_simulate(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=compute_settings.protect_columns,
additional_columns=["tdd"] + compute_settings.protect_columns,
)

interaction_df = alternatives.join(choosers, how="left", rsuffix="_chooser")
Expand Down

0 comments on commit 9ad1d0d

Please sign in to comment.