Skip to content
Open
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
10 changes: 8 additions & 2 deletions activitysim/abm/models/trip_scheduling_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ 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()
Expand Down Expand Up @@ -350,7 +352,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
Expand Down
22 changes: 22 additions & 0 deletions activitysim/abm/test/test_misc/test_trip_scheduling_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -285,3 +286,24 @@ 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
Copy link
Author

Choose a reason for hiding this comment

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

I can convert this to a parametrised test in the same way as test_agg_accessibility_orig_land_use, I'm not sure if that's preferred or not

model_settings_explicit_chunk = tsc.TripSchedulingChoiceSettings(
**{
"SPEC": "placeholder.csv",
"compute_settings": {
"protect_columns": ["origin", "destination", "schedule_id"]
},
}
)
out_tours_chunked = tsc.run_trip_scheduling_choice(
state,
model_spec,
tours,
skims,
locals_dict,
trace_label="PyTest Trip Scheduling",
model_settings=model_settings_explicit_chunk,
)
assert_frame_equal(out_tours, out_tours_chunked)