Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
5c506f1
np array instead of for loop
janzill Mar 19, 2026
710b3b0
memory reduction
janzill Mar 19, 2026
60a744a
no duplicate arrays
janzill Mar 19, 2026
f97185e
bug fix: order of chooser_idx in interaction_simulate
janzill Mar 19, 2026
9d69dab
add tests, docstrings for logit
tomstephen Mar 16, 2026
a9db131
Add basic with/without EET test for interaction simulate
tomstephen Mar 17, 2026
a7f2e8f
Fix, complete tests for interaction sample, simulate
tomstephen Mar 18, 2026
df574ee
Linting
tomstephen Mar 18, 2026
cf92aad
Normalise number of choosers, alternatives and minimum tolerance for …
tomstephen Mar 18, 2026
73f45fe
reshape, do not flatten for potential performance
janzill Mar 19, 2026
6440d3f
undo stray comment
janzill Mar 19, 2026
1df7d0d
unify mc and eet reporting during choice making
janzill Mar 19, 2026
5e9847d
series not array
janzill Mar 19, 2026
1213b56
reinstate test, up number of draws for comparison
janzill Mar 19, 2026
fa54204
numpy not loop
janzill Mar 19, 2026
1b2b6dc
interaction_sample test to catch index order bug
janzill Mar 19, 2026
4e0c7e8
make test clearer
janzill Mar 20, 2026
1aa85ba
reset rng offset on iterate_location_choice (shadow pricing)
janzill Mar 22, 2026
bd4211f
Add tests for logit NL, ordering, and all models using EET
tomstephen Mar 23, 2026
76cacb2
Add basic docs for EET
tomstephen Mar 23, 2026
f628505
Add tests checking that choices made using eet and from probabilities…
TylerP132 Mar 23, 2026
362eef0
Linting, minor changes to test_simulate.py
tomstephen Mar 23, 2026
d0a6429
roll back changes to core tests to minimize noise
janzill Mar 26, 2026
65fd171
Implement Jan's suggestion of how to calculate household ids for test…
TylerP132 Mar 30, 2026
f55b2cd
Add test for compute_nested_utilities. Computes nested utilities on a…
TylerP132 Mar 31, 2026
4debaad
Linting
tomstephen Mar 31, 2026
743c56f
Move nest_spec to a fixture in simulate.py tests
TylerP132 Mar 31, 2026
b62001e
Merge with Tom's linting changes
TylerP132 Mar 31, 2026
b021cee
Finish removing nest_spec definition in simulate.py tests
TylerP132 Mar 31, 2026
52f75fa
Merge pull request #5 from outerl/tom/nested-logit-tests-and-docs
janzill Mar 31, 2026
ae71433
lint
janzill Mar 31, 2026
6ef25e1
clean up
janzill Mar 31, 2026
d491e45
Merge branch 'jzill/runtime_improvement' into jzill/reset_rng_on_shad…
janzill Mar 31, 2026
cc8fda0
reset rng only for eet for now. discuss in engineering meeting
janzill Mar 31, 2026
c1806fc
Close out remaining TODO-EETs
tomstephen Mar 31, 2026
3270474
Shuffle check to logit.py
tomstephen Mar 31, 2026
dd54711
Linting
tomstephen Mar 31, 2026
a73f6ea
Fix test
tomstephen Mar 31, 2026
b455e2a
Roll back validate_utils
tomstephen Mar 31, 2026
a490999
eet doco start
janzill Mar 31, 2026
661c6b3
doco part two
janzill Mar 31, 2026
a0bc5ba
Merge branch 'jzill/runtime_improvement' of github.com:outerl/activit…
janzill Mar 31, 2026
40b0b06
add scale comment
janzill Mar 31, 2026
21daa5c
Revert linting changes
tomstephen Apr 1, 2026
0da80bf
.
tomstephen Apr 1, 2026
1d139e0
Fix failing tests
tomstephen Apr 2, 2026
605366f
doc fix
janzill Apr 2, 2026
8c74d2a
docs
janzill Apr 2, 2026
f542e58
doco clean up
janzill Apr 2, 2026
2d1dbcb
doco re memory
janzill Apr 2, 2026
837ae41
doco clean up
janzill Apr 2, 2026
d674268
memory usage doco
janzill Apr 2, 2026
7959c94
clean up doco
janzill Apr 2, 2026
a7e8529
undo changes in unrelated code to reduce noise
janzill Apr 2, 2026
c5bd23f
Merge pull request #3 from outerl/jzill/runtime_improvement
janzill Apr 2, 2026
be3a270
testing for semcog model, update to shadow pricing reset
janzill Apr 2, 2026
7209985
lint
janzill Apr 2, 2026
22a4f62
disable test unitl further investigation
janzill Apr 2, 2026
220c5cf
mp rng reset, disabling one new test for no
janzill Apr 3, 2026
d50ad3c
semcog test with different seed for eet mp to work around non-determi…
janzill Apr 3, 2026
d5a8fd4
no need to restrict to specific choosers for reset, each process has …
janzill Apr 3, 2026
033f08a
Add eet multiple zone test for zone=2
TylerP132 Apr 7, 2026
f5b6301
Change formatting from using ruff to black
TylerP132 Apr 7, 2026
5b24d44
add back accidentally removed import
janzill Apr 7, 2026
9661d01
re-add 3-zone tests
janzill Apr 7, 2026
7c96cbc
base seed same as non-eet, update regress eet data
janzill Apr 7, 2026
c786919
progressive 2 zone test
janzill Apr 7, 2026
08b2b03
Merge pull request #6 from outerl/explicit_error_terms-multiple_zone_…
janzill Apr 8, 2026
0d2356e
Copy changes from m-richards:matt/poisson_eet_2026_04
tomstephen Apr 9, 2026
89dbe5c
Tidy, complete implementation of alts_context, add tests, rebuild reg…
tomstephen Apr 9, 2026
47ed600
Commenting/fix alts context constructions, update semcog test
tomstephen Apr 9, 2026
2d181b2
Deterministic randoms when adding/removing tours for trip scheduling …
tomstephen Apr 10, 2026
cfe6166
PR noise
tomstephen Apr 10, 2026
7a22612
Roll back final_trips.csv for production_semcog
tomstephen Apr 10, 2026
bc56a87
PR noise, make sure alts_context built on un-modified alternatives in…
tomstephen Apr 10, 2026
531b562
linting
tomstephen Apr 10, 2026
19750a0
updates outdated comment
janzill Apr 10, 2026
834fc90
re-add arc test, remove parking choice column from regress trips
janzill Apr 10, 2026
6d29f18
re-instate arc tests
janzill Apr 11, 2026
12a3d8a
Revert "Deterministic randoms when adding/removing tours for trip sch…
janzill Apr 11, 2026
3bd3251
no alts_context for trip_scheduling
janzill Apr 11, 2026
8d7ae41
updates arc regress files
janzill Apr 11, 2026
f2d7bfa
removes outdated comment
janzill Apr 11, 2026
d7c1345
trip scheduling comment for EET
janzill Apr 11, 2026
e9fb130
disable arc sharrow test until regress trips are updated
janzill Apr 11, 2026
10db123
doco update
janzill Apr 11, 2026
fcef6b3
Merge pull request #7 from outerl/deterministic-alt-sample-randoms
janzill Apr 11, 2026
1e9f26c
Matt's Poisson sampling changes from PR 1065
janzill Apr 11, 2026
3bde470
bug fix
janzill Apr 12, 2026
346f0e8
add second return arg for zero probs as well
janzill Apr 12, 2026
32a2662
eet for nested logit
janzill May 6, 2026
e0dbad8
towards a unified choice interface
janzill May 6, 2026
e944d1e
test and doco updates
janzill May 6, 2026
968da57
jtp fix
janzill May 6, 2026
04b2a28
fused location sampling
janzill May 6, 2026
8f0ae70
c order to map the first n_alt rands to all alternatives for the firs…
janzill May 6, 2026
510c6ab
fused mnl ev1 argmax with alt_info
janzill May 6, 2026
3ae81fa
stable sampling
janzill May 6, 2026
cb0c5d4
some doco updates
janzill May 6, 2026
bd762c8
doc clean up
janzill May 6, 2026
acaa22a
Merge remote-tracking branch 'origin/jzill/eet_poisson_sampling_from_…
janzill May 6, 2026
248defd
poisson sample tests and runtime improvements
janzill May 10, 2026
cfdd7da
tests for random sampling as fallback, some doc strings and removal o…
janzill May 11, 2026
ee3c429
avoid unneccessary dataframe construction, better doco
janzill May 11, 2026
68faa94
update interaction sample tests for poisson
janzill May 11, 2026
73d83e6
integration of sampling methods with clear separation from eet as sim…
janzill May 11, 2026
e8fb1d7
poisson sampling optimization
janzill May 11, 2026
ccd5098
poisson sampling with stable rands across scenarios where attractions…
janzill May 11, 2026
fecb26d
do not throw on poisson fallback sampling with sample_size > alternat…
janzill May 11, 2026
0cb9289
debug logging
janzill May 11, 2026
3c4a3b1
clean up
janzill May 12, 2026
e4e415a
sampling doco
janzill May 12, 2026
b7b1d90
clean up
janzill May 12, 2026
bf24aa5
doco update
janzill May 12, 2026
067448c
linting
janzill May 12, 2026
1f731ca
razzmatazz. I mean maz for taz.
janzill May 12, 2026
7731971
test fixes and stable sorting for tour/trip loc choice
janzill May 12, 2026
480c8ad
no stable alts for MC
janzill May 12, 2026
c8470ec
lint
janzill May 12, 2026
a77cbec
stable two-zone maz_from_taz for Poisson
janzill May 13, 2026
e91e566
more doco
janzill May 13, 2026
a6ff459
no op if no alts_context
janzill May 13, 2026
7aaeb1b
do not throw on interaction_sample_simulate w/o alts_context
janzill May 13, 2026
e9a2813
eet special casing
janzill May 13, 2026
6d0a24e
tour_od with maz_taz stable, clean up
janzill May 13, 2026
5b0c79e
arc eet golden trips
janzill May 13, 2026
429f954
Merge branch 'jzill/eet_runtime_inc_nl_and_poisson' of github.com:out…
janzill May 13, 2026
5c961b7
switch base seed to avoid trip_scheduling (probabilistic) to come up …
janzill May 13, 2026
a325f45
forgot the corresponding golden trips
janzill May 13, 2026
4fcd239
test multiple_zone golden
janzill May 14, 2026
8933d6c
removes requirement of interaction_sample_simulate to have alts_context
janzill May 14, 2026
270d450
fix test by using eet as intended, remove stable_indexing in tour_des…
janzill May 14, 2026
01b38c7
clean up
janzill May 14, 2026
4b78e20
conditional stable sample indexes
janzill May 14, 2026
ae278cc
stable alts only for eet with poisson sampling for two-zone
janzill May 14, 2026
de74dfc
trip maz-for-taz stable alts for eet with poisson sampling
janzill May 14, 2026
77b80b3
clean up
janzill May 14, 2026
bdfe757
stable two-zone alts for tour_od
janzill May 14, 2026
67fd055
tour_od stable alt cond
janzill May 14, 2026
249acfa
resolve_smapling_method
janzill May 14, 2026
3ebe20c
decouple sample and simulation methods
janzill May 18, 2026
dc52907
separate RNG for shadow pricing to enable loc choiec rng reset for si…
janzill May 18, 2026
d58d0c5
lint
janzill May 18, 2026
7f68160
logging and comments
janzill May 18, 2026
e6b75ea
debug logging for sample method, add warning for disagg acc and poisson
janzill May 20, 2026
4803032
doco
janzill May 20, 2026
d11f2be
info, nto warning
janzill May 20, 2026
7b7170b
compute settings, not model settings
janzill May 20, 2026
b844372
compute settings, not model settings
janzill May 20, 2026
196704a
variable name
janzill May 20, 2026
1567d5f
Merge pull request #8 from outerl/jzill/eet_runtime_inc_nl_and_poisson
janzill May 21, 2026
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 .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
matrix:
region:
- prototype_mtc
- prototype_arc
- placeholder_psrc
- prototype_marin
- prototype_mtc_extended
Expand Down
18 changes: 17 additions & 1 deletion activitysim/abm/models/disaggregate_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
from activitysim.abm.tables import shadow_pricing
from activitysim.core import estimation, los, tracing, util, workflow
from activitysim.core.configuration.base import (
ComputeSettings,
PreprocessorSettings,
PydanticReadable,
ComputeSettings,
)
from activitysim.core.configuration.logit import TourLocationComponentSettings
from activitysim.core.expressions import assign_columns
from activitysim.core.interaction_sample import _resolve_sample_method

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -760,6 +761,21 @@ def get_disaggregate_logsums(
state, "disaggregate_accessibility.yaml"
)

if (
_resolve_sample_method(
state, getattr(disagg_model_settings, "compute_settings", None)
)
== "poisson"
):
logger.warning(
"Using Poisson sampling method for disaggregate accessibility calculations. Currently the results will"
+ " differ from those obtained with monte-carlo or eet sampling by a constant shift of"
+ f" log({disagg_model_settings.DESTINATION_SAMPLE_SIZE}) if you are using the common correction factor"
+ " `log(pick_count / prob)` in location choice specs. The results of the Poisson method are unbiased,"
+ " i.e., they agree with the results obtained with a full destination sample, unlike those for"
+ " monte-carlo or eet sampling."
)

for model_name in [
"workplace_location",
"school_location",
Expand Down
34 changes: 17 additions & 17 deletions activitysim/abm/models/joint_tour_participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
)
from activitysim.core.configuration.base import ComputeSettings, PreprocessorSettings
from activitysim.core.configuration.logit import LogitComponentSettings
from activitysim.core.util import assign_in_place, reindex
from activitysim.core.exceptions import InvalidTravelError
from activitysim.core.util import assign_in_place, reindex

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,6 +131,7 @@ def participants_chooser(
choosers: pd.DataFrame,
spec: pd.DataFrame,
trace_label: str,
nest_spec: Optional[dict, LogitNestSpec] = None,
) -> tuple[pd.Series, pd.Series]:
"""
custom alternative to logit.make_choices for simulate.simple_simulate
Expand Down Expand Up @@ -250,14 +251,21 @@ def participants_chooser(
f"{num_tours_remaining} tours could not be satisfied after {iter} iterations"
)

choice_function = (
logit.make_choices_utility_based
if state.settings.use_explicit_error_terms
else logit.make_choices
)
choices, rands = choice_function(
state, probs_or_utils, trace_label=trace_label, trace_choosers=choosers
)
if state.settings.use_explicit_error_terms:
choices, rands = logit.make_choices_utility_based(
state,
probs_or_utils,
trace_label=trace_label,
trace_choosers=choosers,
nest_spec=nest_spec,
)
else:
choices, rands = logit.make_choices(
state,
probs_or_utils,
trace_label=trace_label,
trace_choosers=choosers,
)
participate = choices == PARTICIPATE_CHOICE

# satisfaction indexed by tour_id
Expand Down Expand Up @@ -429,14 +437,6 @@ def joint_tour_participation(
if i not in model_settings.compute_settings.protect_columns:
model_settings.compute_settings.protect_columns.append(i)

# TODO EET: this is related to the difference in nested logit and logit choice as per comment in
# make_choices_utility_based. As soon as alt_order_array is removed from arguments to
# make_choices_explicit_error_term_nl this guard can be removed
if state.settings.use_explicit_error_terms:
assert (
nest_spec is None
), "Nested logit model custom chooser for EET requires name_mapping, currently not implemented in jtp"

custom_chooser = participants_chooser

choices = simulate.simple_simulate_by_chunk_id(
Expand Down
100 changes: 97 additions & 3 deletions activitysim/abm/models/location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
TourLocationComponentSettings,
TourModeComponentSettings,
)
from activitysim.core.interaction_sample import interaction_sample
from activitysim.core.exceptions import DuplicateWorkflowTableError
from activitysim.core.interaction_sample import (
_resolve_sample_method,
interaction_sample,
)
from activitysim.core.interaction_sample_simulate import interaction_sample_simulate
from activitysim.core.logit import AltsContext
from activitysim.core.util import reindex
from activitysim.core.exceptions import DuplicateWorkflowTableError

"""
The school/workplace location model predicts the zones in which various people will
Expand Down Expand Up @@ -116,6 +120,8 @@ def _location_sample(
chunk_tag,
trace_label,
zone_layer=None,
stable_alt_positions=None,
n_total_alts=None,
):
"""
select a sample of alternative locations.
Expand Down Expand Up @@ -211,6 +217,8 @@ def _location_sample(
chunk_tag=chunk_tag,
trace_label=trace_label,
zone_layer=zone_layer,
stable_alt_positions=stable_alt_positions,
n_total_alts=n_total_alts,
explicit_chunk_size=model_settings.explicit_chunk,
compute_settings=model_settings.compute_settings.subcomponent_settings(
"sample"
Expand All @@ -226,6 +234,7 @@ def location_sample(
persons_merged,
network_los,
dest_size_terms,
full_dest_size_terms,
estimator,
model_settings: TourLocationComponentSettings,
chunk_size,
Expand All @@ -245,6 +254,16 @@ def location_sample(

alt_dest_col_name = model_settings.ALT_DEST_COL_NAME

if state.settings.use_explicit_error_terms:
stable_alt_positions = full_dest_size_terms.index.get_indexer(
dest_size_terms.index
)
assert (stable_alt_positions >= 0).all()
n_total_alts = len(full_dest_size_terms)
else:
stable_alt_positions = None
n_total_alts = None

choices = _location_sample(
state,
segment_name,
Expand All @@ -257,6 +276,8 @@ def location_sample(
chunk_size,
chunk_tag,
trace_label,
stable_alt_positions=stable_alt_positions,
n_total_alts=n_total_alts,
)

return choices
Expand Down Expand Up @@ -366,6 +387,7 @@ def location_presample(
chunk_size,
chunk_tag,
trace_label,
full_dest_size_terms=None,
):
trace_label = tracing.extend_trace_label(trace_label, "presample")

Expand All @@ -378,6 +400,39 @@ def location_presample(
state, dest_size_terms, network_los, model_settings
)

if full_dest_size_terms is None:
full_dest_size_terms = dest_size_terms

if state.settings.use_explicit_error_terms:
full_taz_index = pd.Index(
network_los.map_maz_to_taz(full_dest_size_terms.index), name=DEST_TAZ
)
full_taz_index = full_taz_index[~full_taz_index.duplicated()]
stable_alt_positions = full_taz_index.get_indexer(TAZ_size_terms.index)
assert (stable_alt_positions >= 0).all()
n_total_alts = len(full_taz_index)

# The TAZ presample call below passes stable_alt_positions for both EET and Poisson sampling, so each TAZ is
# keyed to its position in the full TAZ universe. The MAZ-for-TAZ second stage only receives full_taz_index for
# Poisson: that stage uses one per-(chooser, TAZ) uniform to pick a MAZ within each sampled TAZ. Under Poisson
# each sampled TAZ appears at most once per chooser, so the per-TAZ uniform produces an independent MAZ choice.
# Under EET sampling (importance sampling with replacement) the same TAZ can appear multiple times in a
# chooser's sample and would all share one uniform, forcing every duplicate to pick the same MAZ. An EET-stable
# MAZ-for-TAZ would need a (TAZ, occurrence-rank)-keyed draw and many more random numbers per chooser; that's
# too expensive with the current RNG, revisit if a counter-based RNG is adapted.
sample_compute_settings = getattr(model_settings, "compute_settings", None)
if sample_compute_settings is not None:
sample_compute_settings = sample_compute_settings.subcomponent_settings(
"sample"
)
taz_sample_method = _resolve_sample_method(state, sample_compute_settings)
use_stable_taz_index = taz_sample_method == "poisson"
else:
full_taz_index = None
stable_alt_positions = None
n_total_alts = None
use_stable_taz_index = False

# convert MAZ zone_id to 'TAZ' in choosers (persons_merged)
# persons_merged[HOME_TAZ] = persons_merged[HOME_MAZ].map(maz_to_taz)
assert HOME_MAZ in persons_merged
Expand Down Expand Up @@ -411,6 +466,8 @@ def location_presample(
chunk_tag,
trace_label,
zone_layer="taz",
stable_alt_positions=stable_alt_positions,
n_total_alts=n_total_alts,
)

# print(f"taz_sample\n{taz_sample}")
Expand All @@ -423,7 +480,12 @@ def location_presample(

# choose a MAZ for each DEST_TAZ choice, choice probability based on MAZ size_term fraction of TAZ total
maz_choices = tour_destination.choose_MAZ_for_TAZ(
state, taz_sample, MAZ_size_terms, trace_label, model_settings
state,
taz_sample,
MAZ_size_terms,
trace_label,
model_settings,
full_taz_index=full_taz_index if use_stable_taz_index else None,
)

assert DEST_MAZ in maz_choices
Expand Down Expand Up @@ -462,6 +524,8 @@ def run_location_sample(
23751, 14, 0.972732479292, 2
"""

full_dest_size_terms = dest_size_terms

logger.debug(
f"dropping {(~(dest_size_terms.size_term > 0)).sum()} "
f"of {len(dest_size_terms)} rows where size_term is zero"
Expand Down Expand Up @@ -496,6 +560,7 @@ def run_location_sample(
chunk_size,
chunk_tag=f"{chunk_tag}.presample",
trace_label=trace_label,
full_dest_size_terms=full_dest_size_terms,
)

else:
Expand All @@ -505,6 +570,7 @@ def run_location_sample(
persons_merged,
network_los,
dest_size_terms,
full_dest_size_terms,
estimator,
model_settings,
chunk_size,
Expand Down Expand Up @@ -603,6 +669,7 @@ def run_location_simulate(
chunk_tag,
trace_label,
skip_choice=False,
alts_context: AltsContext | None = None,
):
"""
run location model on location_sample annotated with mode_choice logsum
Expand Down Expand Up @@ -712,6 +779,7 @@ def run_location_simulate(
compute_settings=model_settings.compute_settings.subcomponent_settings(
"simulate"
),
alts_context=alts_context,
)

if not want_logsums:
Expand Down Expand Up @@ -756,6 +824,7 @@ def run_location_choice(
model_settings : dict
chunk_size : int
trace_label : str
skip_choice : bool

Returns
-------
Expand Down Expand Up @@ -789,6 +858,13 @@ def run_location_choice(
logger.info(f"{trace_label} skipping segment {segment_name}: no choosers")
continue

if state.settings.use_explicit_error_terms:
# dest_size_terms contains 0-attraction zones so using this directly here, important for stable error terms
# when a zone goes from 0 base -> nonzero project
alts_context = AltsContext.from_series(dest_size_terms.index)
else:
alts_context = None

# - location_sample
location_sample_df = run_location_sample(
state,
Expand Down Expand Up @@ -841,6 +917,7 @@ def run_location_choice(
trace_label, "simulate.%s" % segment_name
),
skip_choice=skip_choice,
alts_context=alts_context,
)

if estimator:
Expand Down Expand Up @@ -1031,6 +1108,18 @@ def iterate_location_choice(
]
persons_merged_df_ = persons_merged_df_.sort_index()

# reset rng offsets to identical state on each iteration. This ensures that the same set of random numbers is
# used on each iteration for the persons being re-simulated, so sampling and final choice draws are
# reproducible across shadow-pricing iterations.
# Scoped to the persons channel for these specific rows via reset_offsets_for_df so the dedicated
# shadow_pricing_persons channel (registered under EET) keeps its offset across iterations and advances
# naturally on each iteration's update_shadow_prices call.
if state.settings.use_explicit_error_terms and iteration > 1:
logger.debug(
f"{trace_label} resetting random number generator offsets for iteration {iteration}"
)
state.get_rn_generator().reset_offsets_for_df(persons_merged_df_)

choices_df_, save_sample_df = run_location_choice(
state,
persons_merged_df_,
Expand Down Expand Up @@ -1092,6 +1181,11 @@ def iterate_location_choice(
)
break

# Drop the dedicated shadow_pricing RNG channel (registered lazily under EET by spc.update_shadow_prices) so it
# doesn't survive into the next location_choice model (e.g., school after work) — both models share the same
# channel name and would otherwise collide on the no-overlap assert in SimpleChannel.extend_domain. No-op for MC.
spc.cleanup_rng_channel(state)

# - shadow price table
if locutor:
if spc.use_shadow_pricing and model_settings.SHADOW_PRICE_TABLE:
Expand Down
7 changes: 7 additions & 0 deletions activitysim/abm/models/parking_location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from activitysim.core.configuration.base import PreprocessorSettings
from activitysim.core.configuration.logit import LogitComponentSettings
from activitysim.core.interaction_sample_simulate import interaction_sample_simulate
from activitysim.core.logit import AltsContext
from activitysim.core.tracing import print_elapsed_time
from activitysim.core.util import assign_in_place, drop_unused_columns
from activitysim.core.exceptions import DuplicateWorkflowTableError
Expand Down Expand Up @@ -112,6 +113,7 @@ def parking_destination_simulate(
chunk_size,
trace_hh_id,
trace_label,
alts_context: AltsContext | None = None,
):
"""
Chose destination from destination_sample (with od_logsum and dp_logsum columns added)
Expand Down Expand Up @@ -150,6 +152,7 @@ def parking_destination_simulate(
trace_label=trace_label,
trace_choice_name="parking_loc",
explicit_chunk_size=model_settings.explicit_chunk,
alts_context=alts_context,
)

# drop any failed zero_prob destinations
Expand Down Expand Up @@ -211,6 +214,9 @@ def choose_parking_location(
)
destination_sample.index = np.repeat(trips.index.values, len(alternatives))
destination_sample.index.name = trips.index.name
# use full land_use index to ensure AltsContext spans full range of potential zones
land_use = state.get_dataframe("land_use")
alts_context = AltsContext.from_series(land_use.index)

destinations = parking_destination_simulate(
state,
Expand All @@ -223,6 +229,7 @@ def choose_parking_location(
chunk_size=chunk_size,
trace_hh_id=trace_hh_id,
trace_label=trace_label,
alts_context=alts_context,
)

if want_sample_table:
Expand Down
Loading
Loading