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

protect_columns for all simulations (choosers, alts, simple simulate, interaction simulate, etc) #871

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions activitysim/abm/models/parking_location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@ def choose_parking_location(
locals_dict["PARKING"] = skims["op_skims"].dest_key

spec = get_spec_for_segment(state, model_settings, segment_name)
trips = drop_unused_columns(trips, spec, locals_dict, custom_chooser=None)
trips = drop_unused_columns(
trips,
spec,
locals_dict,
custom_chooser=None,
additional_columns=model_settings.compute_settings.protect_columns,
)
alternatives = drop_unused_columns(
alternatives, spec, locals_dict, custom_chooser=None
alternatives,
spec,
locals_dict,
custom_chooser=None,
additional_columns=model_settings.compute_settings.protect_columns,
)

destination_sample = logit.interaction_dataset(
Expand Down
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)
1 change: 1 addition & 0 deletions activitysim/core/configuration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def subcomponent_settings(self, subcomponent: str) -> ComputeSettings:
use_numexpr=self.use_numexpr,
use_numba=self.use_numba,
drop_unused_columns=self.drop_unused_columns,
protect_columns=self.protect_columns,
)


Expand Down
3 changes: 2 additions & 1 deletion activitysim/core/interaction_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def _interaction_sample(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=compute_settings.protect_columns,
)

alternatives = util.drop_unused_columns(
Expand All @@ -265,7 +266,7 @@ def _interaction_sample(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=["tdd", "origin_destination"],
additional_columns=["tdd"] + compute_settings.protect_columns,
)

if sharrow_enabled:
Expand Down
3 changes: 2 additions & 1 deletion activitysim/core/interaction_sample_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _interaction_sample_simulate(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=compute_settings.protect_columns,
)

alternatives = util.drop_unused_columns(
Expand All @@ -166,7 +167,7 @@ def _interaction_sample_simulate(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=["tdd", "origin_destination"],
additional_columns=["tdd"] + compute_settings.protect_columns,
)

interaction_df = alternatives.join(choosers, how="left", rsuffix="_chooser")
Expand Down
1 change: 1 addition & 0 deletions activitysim/core/interaction_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ def _interaction_simulate(
locals_d,
custom_chooser=None,
sharrow_enabled=sharrow_enabled,
additional_columns=compute_settings.protect_columns,
)

if (
Expand Down
1 change: 1 addition & 0 deletions activitysim/core/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@ def _simple_simulate_logsums(
locals_d,
custom_chooser=None,
sharrow_enabled=state.settings.sharrow,
additional_columns=compute_settings.protect_columns,
)

if nest_spec is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ SEGMENTS:

LOGSUM_SETTINGS: tour_mode_choice
LOGSUM_PREPROCESSOR: preprocessor

compute_settings:
protect_columns:
- origin_destination
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will break the sandag model that's not in the test system... are we keeping track of these breaking changes anywhere? I think there have been a few of these since we started the Phase 8 work and I don't want them to get lost...

Loading