From 38c71bf270a31e6b36e48882da2d6e656e5d50de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Jul 2026 13:20:13 +0000 Subject: [PATCH 1/2] Initial plan From 2dda67e67f228affa4da46beecd89dc1ae8535e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Jul 2026 13:25:00 +0000 Subject: [PATCH 2/2] Fix black formatting in trip_scheduling_choice files --- .../abm/models/trip_scheduling_choice.py | 13 ++++++++-- .../test_misc/test_trip_scheduling_choice.py | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/activitysim/abm/models/trip_scheduling_choice.py b/activitysim/abm/models/trip_scheduling_choice.py index 81d908ef1b..fb54ced692 100644 --- a/activitysim/abm/models/trip_scheduling_choice.py +++ b/activitysim/abm/models/trip_scheduling_choice.py @@ -276,7 +276,12 @@ def run_trip_scheduling_choice( choosers, chunk_trace_label, chunk_sizer, - ) in chunk.adaptive_chunked_choosers(state, indirect_tours, trace_label): + ) in chunk.adaptive_chunked_choosers( + state, + indirect_tours, + trace_label, + explicit_chunk_size=model_settings.explicit_chunk, + ): # Sort the choosers and get the schedule alternatives choosers = choosers.sort_index() schedules = generate_schedule_alternatives(choosers).sort_index() @@ -350,7 +355,11 @@ class TripSchedulingChoiceSettings(LogitComponentSettings, extra="forbid"): Settings for the `trip_scheduling_choice` component. """ - pass + explicit_chunk: float = 0 + """ + If > 0, use this chunk size instead of adaptive chunking. + If less than 1, use this fraction of the total number of rows. + """ @workflow.step diff --git a/activitysim/abm/test/test_misc/test_trip_scheduling_choice.py b/activitysim/abm/test/test_misc/test_trip_scheduling_choice.py index 6823a5b123..9159044c40 100644 --- a/activitysim/abm/test/test_misc/test_trip_scheduling_choice.py +++ b/activitysim/abm/test/test_misc/test_trip_scheduling_choice.py @@ -4,6 +4,7 @@ import os from pathlib import Path +from pandas.testing import assert_frame_equal from activitysim.abm.models import trip_scheduling_choice as tsc from activitysim.abm.tables.skims import skim_dict @@ -285,3 +286,26 @@ def test_run_trip_scheduling_choice(model_spec, tours, skims, locals_dict): # check that tours with no inbound stops have zero inbound duration assert out_tours[tsc.IB_DURATION].mask(in_tours[tsc.HAS_IB_STOPS], 0).sum() == 0 + + # confirm explicit chunking is supported and doesn't affect results + state.settings.chunk_training_mode = "explicit" + + model_settings_explicit_chunk = tsc.TripSchedulingChoiceSettings( + **{ + "SPEC": "placeholder.csv", + "explicit_chunk": 2, + "compute_settings": { + "protect_columns": ["origin", "destination", "schedule_id"] + }, + } + ) + out_tours_chunked = tsc.run_trip_scheduling_choice( + state, + model_spec, + in_tours.copy(deep=True), + skims, + locals_dict, + trace_label="PyTest Trip Scheduling", + model_settings=model_settings_explicit_chunk, + ) + assert_frame_equal(out_tours, out_tours_chunked)