Skip to content
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
1 change: 1 addition & 0 deletions activitysim/abm/models/trip_mode_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def trip_mode_choice(
trace_choice_name="trip_mode_choice",
estimator=estimator,
compute_settings=model_settings.compute_settings,
explicit_chunk_size=model_settings.explicit_chunk,
)

if state.settings.trace_hh_id:
Expand Down
9 changes: 7 additions & 2 deletions activitysim/abm/models/util/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def mode_choice_simulate(
trace_column_names=None,
estimator: Optional[Estimator] = None,
compute_settings: ComputeSettings | None = None,
explicit_chunk_size: float = 0,
):
"""
common method for both tour_mode_choice and trip_mode_choice
Expand All @@ -47,13 +48,15 @@ def mode_choice_simulate(
nest_spec
skims
locals_d
chunk_size
mode_column_name
logsum_column_name
trace_label
trace_choice_name
estimator
compute_settings : ComputeSettings
compute_settings : ComputeSettings, optional
explicit_chunk_size : float, default 0
If > 0, the fixed number of choosers per chunk (explicit chunking); if 0, chunk sizing
follows the run's chunk_training_mode / adaptive sizing.

Returns
-------
Expand All @@ -74,6 +77,7 @@ def mode_choice_simulate(
estimator=estimator,
trace_column_names=trace_column_names,
compute_settings=compute_settings,
explicit_chunk_size=explicit_chunk_size,
)

# for consistency, always return dataframe, whether or not logsums were requested
Expand Down Expand Up @@ -176,6 +180,7 @@ def run_tour_mode_choice_simulate(
trace_column_names=trace_column_names,
estimator=estimator,
compute_settings=model_settings.compute_settings,
explicit_chunk_size=model_settings.explicit_chunk,
)

return choices
8 changes: 8 additions & 0 deletions activitysim/core/configuration/logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ class TemplatedLogitComponentSettings(LogitComponentSettings, extra="forbid"):
segment-specific names.
"""

explicit_chunk: float = 0
"""
If > 0, use this fixed chunk size (number of chooser rows) instead of adaptive
chunking. If less than 1, use this fraction of the total number of rows. Plumbed
through mode_choice_simulate -> simple_simulate so mode-choice models can be chunked
(default 0 = unchanged chunkless/adaptive behavior).
"""


class LocationComponentSettings(BaseLogitComponentSettings):
"""
Expand Down
5 changes: 4 additions & 1 deletion activitysim/core/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,7 @@ def simple_simulate(
trace_choice_name=None,
trace_column_names=None,
compute_settings: ComputeSettings | None = None,
explicit_chunk_size: float = 0,
):
"""
Run an MNL or NL simulation for when the model spec does not involve alternative
Expand All @@ -1864,7 +1865,9 @@ def simple_simulate(
chooser_chunk,
chunk_trace_label,
chunk_sizer,
) in chunk.adaptive_chunked_choosers(state, choosers, trace_label):
) in chunk.adaptive_chunked_choosers(
state, choosers, trace_label, explicit_chunk_size=explicit_chunk_size
):
choices = _simple_simulate(
state,
chooser_chunk,
Expand Down
Loading