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

Composite - Disaggregate Accessibility #635

Merged
merged 221 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
da13d63
school escorting initial commit
dhensle Jun 11, 2022
bd9e4bf
bundles created
dhensle Jun 21, 2022
9dc3190
added pure escort tours after non_mand_sched
dhensle Jun 23, 2022
b3df946
initial commit with basic working proto pop gen
nick-fournier-rsg Jun 29, 2022
6441c9a
fixed bad dependency range
nick-fournier-rsg Jun 29, 2022
1b8511f
fixed vary_on method to vary all with mapped fields after
nick-fournier-rsg Jul 2, 2022
96fca8e
added check if already dataframe
nick-fournier-rsg Jul 20, 2022
e92ed4a
added dataframe check if the table passed is already a dataframe
nick-fournier-rsg Jul 25, 2022
68ff25e
working proto pop gen. still debugging mandatory work/school model
nick-fournier-rsg Jul 25, 2022
5189fc8
check all table is df
nick-fournier-rsg Jul 25, 2022
a8c2376
workplace runs, next testing school
nick-fournier-rsg Jul 25, 2022
c82504f
began setting up to get all logsums, not just chosen ones
nick-fournier-rsg Jul 27, 2022
b9fa41b
restructured to run as either one-off or model step
nick-fournier-rsg Jul 28, 2022
23f26e3
created escorting tours & trips
dhensle Jul 29, 2022
93ee763
integrated escort tours and trips
dhensle Aug 2, 2022
c82db36
downstream model integration
dhensle Aug 8, 2022
194c3dd
nm tour scheduling passing
dhensle Aug 14, 2022
f659405
updating stop freq in tours table
dhensle Aug 14, 2022
fe2ee40
added check for mand tour overlap with pe tours
dhensle Aug 14, 2022
e9ea02b
num chauffeurs and escortees
dhensle Aug 14, 2022
0407108
merging canonical ids from flexible id work
dhensle Aug 14, 2022
8c0d2a0
setting escorting tour and trip ids
dhensle Aug 15, 2022
b49e97c
remove unneeded nmtf settings file
dhensle Aug 15, 2022
c6ce7bd
black formatting
dhensle Aug 15, 2022
25631e8
excluding escort trips from trip scheduling
dhensle Aug 15, 2022
14ccd97
fixing bug where mand tours not getting assigned correct id
dhensle Aug 15, 2022
23734a0
adding school_escorting to mp model list
dhensle Aug 15, 2022
d7bd408
adding school escort tour flavors as own category
dhensle Aug 16, 2022
6691c9b
updating timetable windows with pure escort tours
dhensle Aug 16, 2022
0b1d3c5
additional logging
dhensle Aug 16, 2022
01c84ae
adding non-mand destination changes
dhensle Aug 16, 2022
1a60a9f
fixing bad tdd merge
dhensle Aug 16, 2022
1df6927
merging tdd alts to all tours
dhensle Aug 17, 2022
c3f942e
adding ride share threshold to unvailability for pure escort time ove…
dhensle Aug 18, 2022
7c9fe32
cleanup
dhensle Aug 18, 2022
f7d9d29
mins per time bin
dhensle Aug 18, 2022
f84d7bd
black formatting
dhensle Aug 18, 2022
be63890
merge with develop
dhensle Aug 18, 2022
9c76c17
black formatting
dhensle Aug 18, 2022
28e96c8
fixing reindex import bug
dhensle Aug 18, 2022
1b4203a
fixing missed import
dhensle Aug 19, 2022
6f855f3
replacing trips test table
dhensle Aug 19, 2022
3ee29ec
inserting default setting if no models in config for tests
dhensle Aug 19, 2022
e78a4ec
adding setup function to tests to set configs_dir injectable
dhensle Aug 19, 2022
3ea0f4b
documentation
dhensle Aug 19, 2022
7838d2f
revert to last merge. Removed dataframe check in iterate, no longer n…
nick-fournier-rsg Aug 24, 2022
286b5c9
extracted logsums, need to inject into pipeline or save output?
nick-fournier-rsg Aug 24, 2022
387aaca
fixed origin bug and missing outbound trip to work
dhensle Aug 25, 2022
c835590
working standalone or step model
nick-fournier-rsg Aug 26, 2022
a73e6a4
extractable accessibilities for fixed and nonmandatory
nick-fournier-rsg Aug 30, 2022
194d327
extractable accessibilities for fixed and nonmandatory
nick-fournier-rsg Aug 30, 2022
f8365f5
proper cleanup when trips that get removed if schedule failed
dhensle Aug 30, 2022
a526721
changed failed trip scheduling option for example
dhensle Aug 30, 2022
71f9046
updating regress table
dhensle Aug 30, 2022
ed1ccca
blacken
dhensle Aug 30, 2022
a237cfd
cleanup and add documentation
nick-fournier-rsg Aug 31, 2022
d5a7bdd
resolve minor conflicts in model __init__ and conda env yml
nick-fournier-rsg Aug 31, 2022
2e993d9
resolved duplicates of old 'example' folders
nick-fournier-rsg Aug 31, 2022
3bb82b1
model uses write_tables functionality
nick-fournier-rsg Sep 1, 2022
6791a43
disaggregate accessibility runs as model step or standalone. Runs as …
nick-fournier-rsg Sep 2, 2022
3022f67
working model test. table initialization not yet working
nick-fournier-rsg Sep 2, 2022
3f72e95
allowing multiple escort tours in the same period
dhensle Sep 2, 2022
af50994
sandag 3-zone example fix
dhensle Sep 5, 2022
1aee18c
fixing expression for missing escort participants sandag 3_zone
dhensle Sep 5, 2022
2a63d3a
cleanup
dhensle Sep 5, 2022
256b778
added logsum short circuit to get logsums and avoid drawing unneccesa…
nick-fournier-rsg Sep 7, 2022
ee3a1f1
working model plus major cleanup
nick-fournier-rsg Sep 7, 2022
69efa7b
working model plus major cleanup
nick-fournier-rsg Sep 7, 2022
c6f26b5
override sample size
nick-fournier-rsg Sep 8, 2022
a26902c
fixed trace output files
nick-fournier-rsg Sep 8, 2022
c877a46
skip_choice default to False
nick-fournier-rsg Sep 8, 2022
765fd74
fixed empty logsums bug
nick-fournier-rsg Sep 8, 2022
5b27210
cleanup redundent parameters
nick-fournier-rsg Sep 8, 2022
a2137c3
fixed list index instead of set
nick-fournier-rsg Sep 8, 2022
df97dd1
coordinated model run files
nick-fournier-rsg Sep 8, 2022
2ba4249
added default skip to false
nick-fournier-rsg Sep 8, 2022
a66366e
added multiprocessing line
nick-fournier-rsg Sep 9, 2022
120c760
began setup for multiprocessing
nick-fournier-rsg Sep 12, 2022
9a663dd
fixed sampling problem. Pipeline for multi processing, NOT WORKING YET
nick-fournier-rsg Sep 12, 2022
753fa0b
deleted run file, not needed anymore
nick-fournier-rsg Sep 12, 2022
9dd261b
added helper functions for handling suffix args
nick-fournier-rsg Sep 14, 2022
13df8ed
to enable multiprocessing, overhauled pipeline method to include prot…
nick-fournier-rsg Sep 14, 2022
141bb64
working multiprocess, but requires debugging. fails on other models
nick-fournier-rsg Sep 14, 2022
ac3edd3
working multiprocess, but requires debugging. fails on other models
nick-fournier-rsg Sep 14, 2022
6b2181d
cleanup of mp table registering
nick-fournier-rsg Sep 15, 2022
005307d
fixed tracing and slicing issue
nick-fournier-rsg Sep 15, 2022
2c195f0
removed old 'run' model
nick-fournier-rsg Sep 15, 2022
2fdf7ea
fixing bug for inbound destination for second escortee
dhensle Sep 21, 2022
c6d342b
blacken
dhensle Sep 21, 2022
5198916
setup example 2 zones
nick-fournier-rsg Sep 26, 2022
98efe5c
minimum working 2 zone
nick-fournier-rsg Sep 26, 2022
4771bf1
multizone basic working
nick-fournier-rsg Sep 26, 2022
be5d2ca
fixed buggy settings
nick-fournier-rsg Sep 26, 2022
26c57a7
multiprocessing working, but empty final tables
dhensle Sep 27, 2022
749c65c
fixed blank output bug and cleaned up settings to use verbose table n…
nick-fournier-rsg Sep 27, 2022
01b0e5b
Merge branch 'dev_accessibilities' of github.com:nick-fournier-rsg/ac…
nick-fournier-rsg Sep 27, 2022
0902f88
cleanup run scripts a bit
nick-fournier-rsg Sep 27, 2022
00ba5f9
fixed missing base path for full run
nick-fournier-rsg Sep 27, 2022
ea82c39
fixed missing path
nick-fournier-rsg Sep 27, 2022
570b45c
fixed typo
nick-fournier-rsg Sep 27, 2022
9364cce
fixed 1 per taz sampling
nick-fournier-rsg Sep 27, 2022
25d01c7
fixing person merge bug and filtering workers
dhensle Sep 27, 2022
263cca6
Merge branch 'dev_accessibilities' of https://github.com/nick-fournie…
dhensle Sep 27, 2022
9e5053c
fixed duplicate tours!
nick-fournier-rsg Sep 28, 2022
8739d56
updated settings for initialize disagg
nick-fournier-rsg Sep 29, 2022
f41c769
removed obsolete file
nick-fournier-rsg Sep 29, 2022
b36de0f
cleaned up file and moved initialize to tables/...
nick-fournier-rsg Sep 29, 2022
3013f7c
added find nearest node function
nick-fournier-rsg Sep 29, 2022
4a179a9
added initialize disaggregate_accessibility to initialize_households
nick-fournier-rsg Sep 29, 2022
06e7178
moved initialize steps to 'tables/disaggregate_accessibility'
nick-fournier-rsg Sep 30, 2022
8b1d529
updated settings to include initialize disaggregate accessibilities a…
nick-fournier-rsg Sep 30, 2022
991b2c6
moved initialize disagg accessibilities to tables. Created working me…
nick-fournier-rsg Sep 30, 2022
17b3fea
add mp back in
nick-fournier-rsg Sep 30, 2022
cc97d5f
PEP formatting revisions
nick-fournier-rsg Sep 30, 2022
7b4b780
fixed logsums merge on households instead of persons
nick-fournier-rsg Sep 30, 2022
895438e
fixed _accessibility suffix
nick-fournier-rsg Sep 30, 2022
d9c465c
fixed conflict with persons_merged
nick-fournier-rsg Sep 30, 2022
e1b1b0c
updated yaml to use simpler join method
nick-fournier-rsg Sep 30, 2022
ca1c130
Merge remote-tracking branch 'origin/develop' into dev_accessibilities
nick-fournier-rsg Sep 30, 2022
ba27eb3
PEP formatting fixes
nick-fournier-rsg Oct 1, 2022
9c295f9
refreshed example folder from develop
nick-fournier-rsg Oct 1, 2022
56184ad
added missing line at end of file
nick-fournier-rsg Oct 1, 2022
1e78698
black fixes
nick-fournier-rsg Oct 1, 2022
301ac23
black fixes to disaggregate accessibility changes
nick-fournier-rsg Oct 1, 2022
7be7dd8
Merge branch 'ActivitySim:main' into dev_accessibilities
nick-fournier-rsg Oct 3, 2022
188a05f
fixed missing column pipeline error
nick-fournier-rsg Oct 3, 2022
0da4af9
merged disagg accessibilities into mtc_extended and added doc section
nick-fournier-rsg Oct 3, 2022
a2a743c
ran black on disaggregate_accessibility.py
nick-fournier-rsg Oct 3, 2022
ff51013
updated dependencies
nick-fournier-rsg Oct 3, 2022
25ddd57
removing sklearn imports
dhensle Oct 3, 2022
4298141
blacken
dhensle Oct 3, 2022
9fa6d0b
add if none catch
nick-fournier-rsg Oct 3, 2022
4123c86
fixed None suffix default
nick-fournier-rsg Oct 3, 2022
0941d01
moved order of get_table(persons_merged) to avoid pulling prematurely…
nick-fournier-rsg Oct 3, 2022
40a8170
tested and cleaned up rng channels
nick-fournier-rsg Oct 4, 2022
079dcfb
setup injectable suffixes to allow add_size_table as model step not j…
nick-fournier-rsg Oct 4, 2022
2187a4b
removed accessibility output from test
nick-fournier-rsg Oct 4, 2022
d52666e
re blacken py scripts
nick-fournier-rsg Oct 4, 2022
8ab2f65
fixed tracing typo
nick-fournier-rsg Oct 4, 2022
29a9ddc
added variable index name suffix to pass optionally
nick-fournier-rsg Oct 4, 2022
d4886ee
pipeline housekeeping to cleanup any tables, traceables, or channels …
nick-fournier-rsg Oct 5, 2022
5406541
added multiprocess testing
nick-fournier-rsg Oct 5, 2022
6521f56
blacken updates
nick-fournier-rsg Oct 5, 2022
82c36c7
updated test scripts to include MP, problem with vehicle model in mp …
nick-fournier-rsg Oct 5, 2022
ecd53a6
added improved origin sampling, resolved issue with merging with samp…
nick-fournier-rsg Oct 7, 2022
4e01bf2
added sci-kit learn to test depends
nick-fournier-rsg Oct 7, 2022
b6ac7ef
fixed person merging error causing pytest fail, uses inject method to…
nick-fournier-rsg Oct 7, 2022
f53ec77
cleanup comments
nick-fournier-rsg Oct 7, 2022
35d0a5d
fixed pytest to include accessibility table in regress
nick-fournier-rsg Oct 7, 2022
d5042f5
setup for mp test, but needs debugging
nick-fournier-rsg Oct 7, 2022
d5132fc
'blacken'
nick-fournier-rsg Oct 7, 2022
ca317fc
'blacken'
nick-fournier-rsg Oct 7, 2022
935b42d
cleanup example folder
nick-fournier-rsg Oct 7, 2022
b351eb0
fixed pipeline NoneType bug for disagg accessibility table
nick-fournier-rsg Oct 7, 2022
5ab73ed
add mp test for prototype_mtc_extended
dhensle Oct 11, 2022
a52bb48
merging mp_testing
dhensle Oct 11, 2022
e41fe66
fixed pytest fail on mp, due to exept:True on mp_simulate
nick-fournier-rsg Oct 11, 2022
34e08b3
'blacken'
nick-fournier-rsg Oct 11, 2022
87c251f
added weighted k-means method
nick-fournier-rsg Oct 13, 2022
aeff8e8
created run script for multiple sampling scenarios
nick-fournier-rsg Oct 13, 2022
93544fd
blacken changes
nick-fournier-rsg Oct 13, 2022
47d1e6b
blacken
nick-fournier-rsg Oct 13, 2022
9a9c9cf
fixed copy script
nick-fournier-rsg Oct 17, 2022
a291027
blacken sampling script
nick-fournier-rsg Oct 17, 2022
8180d7d
fixed n_zone when integer
nick-fournier-rsg Oct 17, 2022
5960f40
fixed typo
nick-fournier-rsg Oct 17, 2022
6584f7b
update sampling script
nick-fournier-rsg Oct 25, 2022
dada5cd
'blacken'
nick-fournier-rsg Oct 25, 2022
1096cfb
fixed replacement sample bug
nick-fournier-rsg Oct 25, 2022
0d0a7c3
updated documentation
nick-fournier-rsg Oct 25, 2022
17c6b21
more flexible scenario testing
nick-fournier-rsg Oct 26, 2022
7dde020
blacken
nick-fournier-rsg Oct 26, 2022
73264ab
added test runs to __main__ in test_mtc_extended
dhensle Oct 27, 2022
f5f4a2e
additional logging, random seed option, landuse sample weight column
dhensle Nov 2, 2022
48085bb
review responses
dhensle Dec 2, 2022
bb813c0
revisions per Sijia's comments, except for the proto-table-template i…
nick-fournier-rsg Dec 7, 2022
f738aa3
added template pop option
nick-fournier-rsg Dec 8, 2022
ce78cfb
blacken
nick-fournier-rsg Dec 8, 2022
f02c466
set back to create_tables to pass test against old tables
nick-fournier-rsg Dec 8, 2022
57e726a
updated proto-pop test data
nick-fournier-rsg Dec 8, 2022
f0b6524
resolved bad test data issue
nick-fournier-rsg Dec 8, 2022
6a845e4
optimize nearest zone determination
dhensle Dec 15, 2022
902cb81
Merge branch 'develop' into dev_accessibilities
dhensle Dec 15, 2022
d132ac2
adding sandag 2-zone test
dhensle Dec 17, 2022
6da35a6
escortee modes match chauf modes
dhensle Dec 23, 2022
a568076
merging in develop branch
dhensle Dec 23, 2022
b787859
updating regression tests
dhensle Dec 23, 2022
9c4d96f
fixing bad var name in inbound expressions
dhensle Dec 23, 2022
9db0029
Merge branch 'develop' into dev_accessibilities
jpn-- Dec 30, 2022
838d80d
Merge branch 'develop' into school_escorting
jpn-- Jan 3, 2023
ff5f57d
Update school_escorting.yaml
jpn-- Jan 3, 2023
df2f38a
Update config.py
jpn-- Jan 3, 2023
80d8a53
require sharrow 2.5
jpn-- Jan 9, 2023
684cc9c
fix mtc_ext for sharrow
jpn-- Jan 10, 2023
6bb3660
fix test consistent with escort mode alignments
jpn-- Jan 10, 2023
5063070
allow sharrow skipping
jpn-- Jan 12, 2023
88b0847
remove stray indent
jpn-- Jan 12, 2023
30af6ba
delete expression values after sharrow testing to make debugging easier
jpn-- Jan 12, 2023
28480b0
require sharrow 2.5.2
jpn-- Jan 12, 2023
f800b95
merge with develop
jpn-- Jan 13, 2023
22c743e
recode only once
jpn-- Jan 13, 2023
119dae2
testing repairs
jpn-- Jan 13, 2023
658f5e5
note about why sharrow_skip
jpn-- Jan 16, 2023
113dc22
fork mtc_extended testing on shadow pricing and sharrow
jpn-- Jan 16, 2023
d3dd6ac
note on sharrow_skip
jpn-- Jan 16, 2023
db4db8c
Merge branch 'school_escorting' into dev_accessibilities
jpn-- Jan 16, 2023
ec1acb8
size term scaling only for full run
dhensle Jan 19, 2023
fa64b51
reordering
dhensle Jan 20, 2023
8a150a3
multiprocessing hangs!
dhensle Jan 20, 2023
83aff55
never scale size terms for disagg
dhensle Jan 20, 2023
606fad4
tally pending persons
jpn-- Jan 26, 2023
1779541
tests cleanup
jpn-- Jan 26, 2023
d7666a6
fix error with orca
jpn-- Jan 26, 2023
e94d58a
let pipeline tables be dropped
jpn-- Jan 26, 2023
dedd372
check on available MAZs, comment cleanup
dhensle Jan 26, 2023
25ae93c
work zone to -1 if wfh, removed unneeded extensions
dhensle Jan 26, 2023
8efae4e
fix tests for sandag 2zone
jpn-- Jan 27, 2023
27429d0
Merge pull request #8 from camsys/dev_accessibilities
jpn-- Jan 27, 2023
a75d95d
Merge branch 'develop' into wfh_zone_setting
jpn-- Jan 27, 2023
9133c2e
ignore deprecation warning in tests
jpn-- Jan 27, 2023
5eebf18
Merge pull request #9 from camsys/wfh_zone_setting
jpn-- Jan 27, 2023
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
4 changes: 4 additions & 0 deletions activitysim/abm/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# flake8: noqa
# ActivitySim
# See full license in LICENSE.txt.

from . import (
accessibility,
atwork_subtour_destination,
Expand All @@ -8,6 +10,7 @@
atwork_subtour_scheduling,
auto_ownership,
cdap,
disaggregate_accessibility,
free_parking,
initialize,
initialize_los,
Expand All @@ -24,6 +27,7 @@
non_mandatory_scheduling,
non_mandatory_tour_frequency,
parking_location_choice,
school_escorting,
stop_frequency,
summarize,
telecommute_frequency,
Expand Down
763 changes: 763 additions & 0 deletions activitysim/abm/models/disaggregate_accessibility.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions activitysim/abm/models/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pandas as pd

from activitysim.abm.tables import shadow_pricing
from activitysim.abm.tables import shadow_pricing, disaggregate_accessibility
from activitysim.core import chunk, config, expressions, inject, mem, pipeline, tracing
from activitysim.core.steps.output import (
track_skim_usage,
Expand Down Expand Up @@ -141,7 +141,8 @@ def initialize_households():
add_size_tables = model_settings.get("add_size_tables", True)
if add_size_tables:
# warnings.warn(f"Calling add_size_tables from initialize will be removed in the future.", FutureWarning)
shadow_pricing.add_size_tables()
suffixes = inject.get_injectable("disaggregate_suffixes")
shadow_pricing.add_size_tables(suffixes)

# - preload person_windows
person_windows = inject.get_table("person_windows").to_frame()
Expand Down
5 changes: 5 additions & 0 deletions activitysim/abm/models/location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def aggregate_size_terms(dest_size_terms, network_los, model_settings):
"size_term": "sum",
"shadow_price_size_term_adjustment": "sum",
"shadow_price_utility_adjustment": "sum",
"avail_MAZ": "sum",
}
)

Expand Down Expand Up @@ -552,6 +553,7 @@ def run_location_simulate(
chunk_size,
chunk_tag,
trace_label,
skip_choice=False,
):
"""
run location model on location_sample annotated with mode_choice logsum
Expand Down Expand Up @@ -628,6 +630,7 @@ def run_location_simulate(
trace_label=trace_label,
trace_choice_name=model_settings["DEST_CHOICE_COLUMN_NAME"],
estimator=estimator,
skip_choice=skip_choice,
)

if not want_logsums:
Expand All @@ -652,6 +655,7 @@ def run_location_choice(
chunk_tag,
trace_hh_id,
trace_label,
skip_choice=False,
):
"""
Run the three-part location choice algorithm to generate a location choice for each chooser
Expand Down Expand Up @@ -750,6 +754,7 @@ def run_location_choice(
trace_label=tracing.extend_trace_label(
trace_label, "simulate.%s" % segment_name
),
skip_choice=skip_choice,
)

if estimator:
Expand Down
29 changes: 27 additions & 2 deletions activitysim/abm/models/non_mandatory_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from activitysim.core import config, inject, pipeline, simulate, tracing
from activitysim.core.util import assign_in_place

from .util import estimation, tour_destination
from .util import estimation, tour_destination, annotate


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -43,7 +44,18 @@ def non_mandatory_tour_destination(
# choosers are tours - in a sense tours are choosing their destination
non_mandatory_tours = tours[tours.tour_category == "non_mandatory"]

# - if no mandatory_tours
# separating out pure escort school tours
# they already have their destination set
if pipeline.is_table("school_escort_tours"):
nm_tour_index = non_mandatory_tours.index
pure_school_escort_tours = non_mandatory_tours[
(non_mandatory_tours["school_esc_outbound"] == "pure_escort")
| (non_mandatory_tours["school_esc_inbound"] == "pure_escort")
]
non_mandatory_tours = non_mandatory_tours[
~non_mandatory_tours.index.isin(pure_school_escort_tours.index)
]

if non_mandatory_tours.shape[0] == 0:
tracing.no_results(trace_label)
return
Expand Down Expand Up @@ -85,14 +97,27 @@ def non_mandatory_tour_destination(

non_mandatory_tours["destination"] = choices_df.choice

# merging back in school escort tours and preserving index
if pipeline.is_table("school_escort_tours"):
non_mandatory_tours = pd.concat(
[pure_school_escort_tours, non_mandatory_tours]
).set_index(nm_tour_index)

assign_in_place(tours, non_mandatory_tours[["destination"]])

if want_logsums:
non_mandatory_tours[logsum_column_name] = choices_df["logsum"]
assign_in_place(tours, non_mandatory_tours[[logsum_column_name]])

assert all(
~tours["destination"].isna()
), f"Tours are missing destination: {tours[tours['destination'].isna()]}"

pipeline.replace_table("tours", tours)

if model_settings.get("annotate_tours"):
annotate.annotate_tours(model_settings, trace_label)

if want_sample_table:
assert len(save_sample_df.index.get_level_values(0).unique()) == len(choices_df)
# save_sample_df.set_index(model_settings['ALT_DEST_COL_NAME'], append=True, inplace=True)
Expand Down
3 changes: 0 additions & 3 deletions activitysim/abm/models/non_mandatory_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from activitysim.core import timetable as tt
from activitysim.core import tracing
from activitysim.core.util import assign_in_place

from .util import estimation
from .util.tour_scheduling import run_tour_scheduling
from .util.vectorize_tour_scheduling import vectorize_tour_scheduling

logger = logging.getLogger(__name__)
DUMP = False
Expand Down
10 changes: 10 additions & 0 deletions activitysim/abm/models/non_mandatory_tour_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from activitysim.core.interaction_simulate import interaction_simulate

from .util import estimation
from .util import annotate
from .util.school_escort_tours_trips import recompute_tour_count_statistics

from .util.overlap import person_max_window
from .util.tour_frequency import process_non_mandatory_tours

Expand Down Expand Up @@ -376,6 +379,13 @@ def non_mandatory_tour_frequency(persons, persons_merged, chunk_size, trace_hh_i
tracing.register_traceable_table("tours", non_mandatory_tours)
pipeline.get_rn_generator().add_channel("tours", non_mandatory_tours)

if pipeline.is_table("school_escort_tours"):
# need to re-compute tour frequency statistics to account for school escort tours
recompute_tour_count_statistics()

if model_settings.get("annotate_tours"):
annotate.annotate_tours(model_settings, trace_label)

expressions.assign_columns(
df=persons,
model_settings=model_settings.get("annotate_persons"),
Expand Down
Loading