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

Publish #426

Merged
merged 188 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
cf531a5
Provide more flexibility for defining mandatory schedule specifications.
Dec 5, 2019
7233d1b
provide more flexibility for time periods.
Dec 5, 2019
b183297
Improve consistency in slicing and fix code syntax issues.
Dec 5, 2019
8332226
Consistency and code syntax.
Dec 5, 2019
b511456
code syntax.
Dec 5, 2019
bfc6191
code syntax fixes.
Dec 5, 2019
988a935
syntax fix.
Dec 5, 2019
c9f890e
Add necessary change to test script settings.
Dec 5, 2019
333f13b
Modify relevant section of the settings.yml for tests and examples.
Dec 5, 2019
4bb9541
restore 'hours' as deprecated for backwards compatibility.
Dec 10, 2019
ca17f3e
Add default value for period_minutes for backwards compatibilitiy.
Dec 10, 2019
174b5e6
create develop branch so we can merge features here before merging (r…
bstabler Dec 17, 2019
7db24a6
Merge pull request #275 from danielsclint/ft_schedule_flex
bstabler Dec 17, 2019
3de1879
provide more flexibility for time periods.
Dec 5, 2019
c546f7c
Improve consistency in slicing and fix code syntax issues.
Dec 5, 2019
2272b4c
Consistency and code syntax.
Dec 5, 2019
3ebfcbe
code syntax fixes.
Dec 5, 2019
0795ec0
Modify relevant section of the settings.yml for tests and examples.
Dec 5, 2019
a5654a5
restore 'hours' as deprecated for backwards compatibility.
Dec 10, 2019
59dddfe
Add default value for period_minutes for backwards compatibilitiy.
Dec 10, 2019
7751fe9
Merge branch 'ft_time_period_flex' of https://github.com/danielsclint…
Dec 20, 2019
82b6b72
Fix overflows
Dec 20, 2019
345e666
Complete testing of the flexible time periods.
Dec 20, 2019
d3597cd
pep8
Dec 21, 2019
889159b
test some floats too.
Dec 21, 2019
772cb34
pep8
Dec 21, 2019
e7664da
Merge pull request #276 from danielsclint/ft_time_period_flex
bstabler Dec 27, 2019
efc2bc6
Merge pull request #286 from danielsclint/ft_overflow
bstabler Dec 27, 2019
32dc999
start with csvs and write hdf5 outputs if desired (#290)
bstabler Feb 3, 2020
9d21d81
Update travis.yml
Feb 3, 2020
1f02ce7
Pandas 1.0 fixes
Feb 4, 2020
925d40e
Location and mode choice logsums (#298)
bstabler Feb 27, 2020
f3955ec
Deprecate Py2 and add CLI
Mar 7, 2020
4255f03
Tncs (#14)
bstabler Mar 24, 2020
4ff7510
write trip matrices (#311)
bstabler Apr 13, 2020
1041bf6
small fixes for semcog deployment (#319)
bstabler May 6, 2020
efe66b3
major work on phase 5 (#325)
bstabler Jul 29, 2020
05a25f6
additional updates for estimation integration (#328)
bstabler Aug 11, 2020
fba45b3
update license, fix univ coeff bug, update estimation example (#339)
bstabler Sep 3, 2020
e6b8de1
Merge branch 'master' into develop
bstabler Sep 3, 2020
205c391
add license to package (#341)
bstabler Sep 4, 2020
f76f9c0
move notebooks to examples folder so they are installed and update do…
bstabler Sep 10, 2020
4393b5e
Merge branch 'master' into develop
bstabler Sep 10, 2020
152b359
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
bstabler Sep 10, 2020
2d07a37
correct doc links
bstabler Sep 10, 2020
200485a
Merge branch 'master' into develop
bstabler Sep 10, 2020
8b9df09
Address Minor Issues Associated with ARC Update to Develop Branch (#342)
Sep 16, 2020
31f9f65
fix #288 chunk joint_touyr_participation by chunk_id and update tests…
toliwaga Oct 4, 2020
9721efb
Merge branch 'master' into develop
bstabler Oct 20, 2020
9bd85ac
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
bstabler Oct 20, 2020
ed201df
gitignore trivia
toliwaga Oct 23, 2020
df28db7
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
toliwaga Oct 23, 2020
5dc9f15
Support for Multiple Zone Systems and Transit Virtual Path Building (…
bstabler Dec 22, 2020
3a4404a
travis depends on these scripts for testing
bstabler Dec 22, 2020
b93cbe0
improve logging and increase travis timeout
bstabler Dec 23, 2020
1eb89ea
#359 (#364)
bstabler Dec 23, 2020
6615389
longer travis timeout and avoid file permissions between tests relate…
bstabler Dec 24, 2020
905465a
test-travis
bstabler Dec 24, 2020
e86559c
ls fix
bstabler Dec 24, 2020
075a31a
add timeout
bstabler Dec 24, 2020
0dcb06e
fix path
bstabler Dec 24, 2020
7858fee
put in both locations for now
bstabler Dec 24, 2020
b6e69b7
reduce household sample sizes for tests to avoid travis timeout
bstabler Dec 24, 2020
cb4d75f
not sure what's taking so long with the second and third tests. It r…
bstabler Dec 25, 2020
87fd635
linux file paths
bstabler Dec 25, 2020
23e9fb4
cli test depends on py 3.7+
bstabler Dec 25, 2020
f03a85a
add coveralls back
bstabler Dec 25, 2020
6f05922
test new architecture
bstabler Dec 26, 2020
dbf2640
try build matrix
bstabler Dec 26, 2020
e0aa2c3
setup environments
bstabler Dec 26, 2020
2d12f6c
correct matrix expansion
bstabler Dec 26, 2020
a6e1d5b
correct duplicate key
bstabler Dec 26, 2020
913fea7
correct key
bstabler Dec 26, 2020
3254eac
correct env usage
bstabler Dec 26, 2020
32aa900
no need to specify architecture
bstabler Dec 26, 2020
4b4c44d
update inject settings for tests
bstabler Dec 27, 2020
45f1d4e
updated examples to use activitysim resources repo
bstabler Dec 30, 2020
19284c3
rename folder
bstabler Dec 30, 2020
82c6d40
update survey test files so all example_manifest.yaml examples now ru…
bstabler Dec 30, 2020
9db97df
updated notebooks, default settings for examples, and updated rst files
bstabler Jan 5, 2021
3ea4cd8
fix a couple typos
bstabler Jan 5, 2021
333b9fd
add comments to travis script
bstabler Jan 5, 2021
534e5be
ARC Updates (#365)
Jan 9, 2021
8bdae80
add example_mtc_arc_extensions so arc extensions can be run and tested
bstabler Jan 9, 2021
75fe31c
small doc update
bstabler Jan 9, 2021
a096966
fix arc extensions example
bstabler Jan 9, 2021
11618d3
add 3 zone trip matrix write example
bstabler Jan 13, 2021
a2c53e1
Merge branch 'master' into develop
bstabler Jan 14, 2021
a66918f
gitignore
toliwaga Jan 18, 2021
2ef3bb0
multiprocess accessibility and add to example_mp
toliwaga Jan 19, 2021
d3a0994
configs_3_zone_marin_full configs tweals
Jan 25, 2021
4c4aa55
Merge branch 'develop' of https://github.com/activitysim/activitysim …
Jan 25, 2021
6f74101
Develop popsim mp support (#375)
toliwaga Feb 3, 2021
f5709f1
correct chunking documentation
bstabler Feb 8, 2021
c552ea3
Develop2 (#393)
bstabler Mar 16, 2021
7131c90
write joint_tour_participation estimtion data bundle override_choice …
toliwaga Mar 16, 2021
e9ddb4c
pathbuilder compute_tap_tap_time dedupe/redupe
toliwaga Mar 17, 2021
12b08ae
add coverage recording for example_mpo test subprocesses. checkpoint …
toliwaga Mar 19, 2021
62459f1
tour_scheduling combine mandatory and non_mandatory
toliwaga Mar 22, 2021
e0c2b65
spec segmentation, alt annotation, for non_mandatory_tour_scheduling
toliwaga Mar 23, 2021
3589239
correct CDAP choices now that work from home is possible
bstabler Mar 23, 2021
0914111
delete old file
bstabler Mar 24, 2021
5d51e06
example_sandag
toliwaga Mar 25, 2021
4ce8033
Merge branch 'develop' of https://github.com/activitysim/activitysim …
toliwaga Mar 25, 2021
f958ef2
example_sandag tap_line_distance_col seting
toliwaga Mar 25, 2021
f59a26b
example_sandag use backing example_mtc configs
toliwaga Mar 26, 2021
8b3bc98
pathbuilder accessibility tap_to_tap use uid instead of merge to de/r…
toliwaga Mar 28, 2021
9dfe5f5
example_sandag and example_mtc configs performance tweals
toliwaga Mar 28, 2021
f865fd2
Estimation Larch (#400)
jpn-- Mar 31, 2021
c4e2e0b
add larch test, update package version, update docs for packages
bstabler Apr 1, 2021
2141a75
example_sandag data and test
toliwaga Apr 1, 2021
0011e95
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
toliwaga Apr 1, 2021
127cc89
travis needs larch>=5.5 (#413)
jpn-- Apr 2, 2021
cea8e08
work in progress: tidy up of examples and documentation
bstabler Apr 13, 2021
43d0059
work in progress: tidy up of examples and documentation
bstabler Apr 13, 2021
4cf1c09
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
bstabler Apr 13, 2021
4b4c87a
#409
bstabler Apr 15, 2021
f28e1f6
documentation updates, updated work from home model, draft transit pa…
bstabler Apr 20, 2021
b9357d3
add min for work for home constant calc
bstabler Apr 20, 2021
9d9bd2f
a few more doc updates, simpler work from home test case, the latest …
bstabler Apr 20, 2021
aa9705b
update logging for work from home model
bstabler Apr 21, 2021
6f6ccf0
create new branch for transit pass model to hold it back from the rel…
bstabler Apr 21, 2021
6f21a88
hold back transit pass model since we're still working on it
bstabler Apr 21, 2021
404f823
A little more doc clean-up for release
bstabler Apr 21, 2021
6476d10
Merge branch 'master' into develop
bstabler Apr 21, 2021
d9e674a
add back ez_setup
bstabler Apr 23, 2021
8d8bf45
Merge branch 'master' into develop
bstabler Apr 23, 2021
4c3d846
update version number for pypi
bstabler Apr 23, 2021
7491ea3
follow convention
bstabler Apr 23, 2021
e6efe27
first working version of rss chunking mtctm1
toliwaga Apr 27, 2021
ddfd2b7
first working version of rss chunking mtctm1
toliwaga Apr 27, 2021
7bd1b04
passing tests
toliwaga Apr 27, 2021
43ca9e7
adjust_chunk_size_for_shared_memory bug broken
toliwaga Apr 28, 2021
3a84d7d
mem and chunk consolidate_logs and chunk update chunk_log cache
toliwaga Apr 29, 2021
5edf649
rss includes children
toliwaga Apr 30, 2021
9c5f937
additional logging for representative logsums
bstabler Apr 30, 2021
fca3f2b
chunk min_available_chunk_ratio and CHUNK_METRIC
toliwaga May 1, 2021
449e4b7
chunk_method and update_cached_chunk_log settings
toliwaga May 2, 2021
724669c
chunk_method hybrid_uss
toliwaga May 4, 2021
d5853fc
chunk_training setting
toliwaga May 4, 2021
7155c56
flexi hybrid_overhead method for chunking
toliwaga May 5, 2021
8fb6bc7
drop rowsize estimators
toliwaga May 5, 2021
2741d8f
CACHE_ACCESS_MODES but need to fix CACHE_UPDATE
toliwaga May 8, 2021
771f94b
replace CACHE_ACCESS_MODES with TRAINING_MODES
toliwaga May 8, 2021
813ac41
pycosestyle
toliwaga May 8, 2021
fca107e
TRAINING_MODES = [MODE_RETRAIN, MODE_ADAPTIVE, MODE_PRODUCTION]
toliwaga May 9, 2021
e5549f6
vectorize_tour_scheduling chunk_tag consolidate rour_num>1
toliwaga May 9, 2021
b2f8972
MEM_TRACE_TICK_LEN and MEM_SNOOP_TICK_LEN
toliwaga May 9, 2021
7fb1d8c
write MKL_NUM_THREADS env and numpy.__config__ info to log at start o…
toliwaga May 9, 2021
6174741
mem_log time bins
toliwaga May 10, 2021
84a966e
mem.consolidate_logs time_bins
toliwaga May 10, 2021
4d98042
annotated chunk settings in mtc
toliwaga May 11, 2021
9c0a2ac
consolidate chunk_tags for trip destination, tour destination, trip p…
toliwaga May 15, 2021
9edd532
small doc update
bstabler May 17, 2021
a773205
work from home model
bstabler May 21, 2021
2400f2e
update move and rename memory usage notebook
bstabler May 26, 2021
88aa903
add future warning
bstabler May 26, 2021
a9c5172
chunk training_mode production fall back to training if no cache
toliwaga May 27, 2021
b84d266
Merge branch 'rss_chunk' of https://github.com/ActivitySim/activitysi…
toliwaga May 27, 2021
c6dd96f
explicit checkpoints setting
toliwaga May 30, 2021
438268f
some doc updates
bstabler Jun 2, 2021
16e18fd
Merge branch 'rss_chunk' of https://github.com/ActivitySim/activitysi…
bstabler Jun 2, 2021
63c30c3
update docs
bstabler Jun 3, 2021
9909114
one more doc update for chunk training
bstabler Jun 3, 2021
854a296
log_alt_losers
toliwaga Jun 5, 2021
bec5c0b
Merge branch 'rss_chunk' of https://github.com/ActivitySim/activitysi…
toliwaga Jun 5, 2021
fd47a57
udst orca
toliwaga Jun 6, 2021
727fa06
update examples
bstabler Jun 6, 2021
b71c542
Merge branch 'rss_chunk' of https://github.com/ActivitySim/activitysi…
bstabler Jun 6, 2021
b71d1e5
additional doc updates for orca clean-up
bstabler Jun 6, 2021
c3a347a
add log_alt_losers to user docs
bstabler Jun 6, 2021
5bdfd28
merge work from home model and update user docs a bit
bstabler Jun 6, 2021
cb2b61b
updated transit pass and subsidy model with fare discounts for tour m…
bstabler Jun 7, 2021
09294bc
Merge remote-tracking branch 'remotes/origin/transit-pass' into develop
bstabler Jun 7, 2021
ada2fc1
Merge remote-tracking branch 'remotes/origin/rss_chunk' into develop
bstabler Jun 7, 2021
cb0ba8c
add file lost in the merge
bstabler Jun 7, 2021
53bf0a1
correct run order
bstabler Jun 7, 2021
b49c954
update version number for upcoming release
bstabler Jun 7, 2021
24175ad
comment out future warning for now
bstabler Jun 7, 2021
812a9a4
log_alt_losers all simulation types
toliwaga Jun 7, 2021
5a52dda
Merge branch 'develop' of https://github.com/ActivitySim/activitysim …
bstabler Jun 7, 2021
a9a0df3
pycodestyle
bstabler Jun 7, 2021
28030eb
updated expected semcog results
bstabler Jun 7, 2021
989ccea
fix fug wehre in estimation mode interaction_simulate changes utility…
toliwaga Jun 8, 2021
43322fe
documentation updates for release
bstabler Jun 9, 2021
4513162
Merge branch 'master' into develop
bstabler Jun 9, 2021
e9ee09e
some better defaults and a bit more documentation
bstabler Jun 10, 2021
d962a42
chunk docstring
toliwaga Jun 11, 2021
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
3 changes: 2 additions & 1 deletion activitysim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ActivitySim
# See full license in LICENSE.txt.

__version__ = '0.9.9.1'

__version__ = '1.0'
__doc__ = 'Activity-Based Travel Modeling'
4 changes: 3 additions & 1 deletion activitysim/abm/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def trace_od(settings):

@inject.injectable(cache=True)
def chunk_size(settings):
return int(settings.get('chunk_size', 0) or 0)
_chunk_size = int(settings.get('chunk_size', 0) or 0)

return _chunk_size


@inject.injectable(cache=True)
Expand Down
44 changes: 1 addition & 43 deletions activitysim/abm/models/accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,6 @@ def compute_accessibilities_for_zones(
return(accessibility_df)


def accessibility_calc_row_size(accessibility_df, land_use_df, assignment_spec, network_los, trace_label):
"""
rows_per_chunk calculator for accessibility
"""

sizer = chunk.RowSizeEstimator(trace_label)

# if there are skims, and zone_system is THREE_ZONE, and there are any
# then we want to estimate the per-row overhead tvpb skims
# (do this first to facilitate tracing of rowsize estimation below)
if network_los.zone_system == los.THREE_ZONE:
# DISABLE_TVPB_OVERHEAD
logger.debug("disable calc_row_size for THREE_ZONE with tap skims")
return 0

land_use_rows = len(land_use_df.index)
land_use_columns = len(land_use_df.columns)
od_columns = 2

# assignment spec has one row per value to assign
# count number of unique persistent assign_variables targets simultaneously resident during spec eval
# (since dict overwrites recurring targets, only count unique targets)
def is_persistent(target):
return not (assign.is_throwaway(target) or assign.is_temp_scalar(target))
num_spec_values = len([target for target in assignment_spec.target.unique() if is_persistent(target)])

sizer.add_elements(land_use_rows * od_columns, 'od_df')

# each od_df joins to all land_use zones
sizer.add_elements(land_use_rows * land_use_columns, 'land_use_choosers')

# and then we assign_variables to joined land_use from assignment_spec
sizer.add_elements(land_use_rows * num_spec_values, 'spec_values')

row_size = sizer.get_hwm()
return row_size


@inject.step()
def compute_accessibility(land_use, accessibility, network_los, chunk_size, trace_od):

Expand Down Expand Up @@ -178,14 +140,10 @@ def compute_accessibility(land_use, accessibility, network_los, chunk_size, trac

logger.info(f"Running {trace_label} with {len(accessibility_df.index)} orig zones {len(land_use_df)} dest zones")

row_size = \
chunk_size and accessibility_calc_row_size(accessibility_df, land_use_df,
assignment_spec, network_los, trace_label)

accessibilities_list = []

for i, chooser_chunk, chunk_trace_label in \
chunk.adaptive_chunked_choosers(accessibility_df, chunk_size, row_size, trace_label):
chunk.adaptive_chunked_choosers(accessibility_df, chunk_size, trace_label):

accessibilities = \
compute_accessibilities_for_zones(chooser_chunk, land_use_df, assignment_spec,
Expand Down
3 changes: 0 additions & 3 deletions activitysim/abm/models/atwork_subtour_mode_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from .util.mode import run_tour_mode_choice_simulate
from .util import estimation

from activitysim.core.mem import force_garbage_collect
from activitysim.core.util import assign_in_place

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -171,5 +170,3 @@ def atwork_subtour_mode_choice(
label=tracing.extend_trace_label(trace_label, mode_column_name),
slicer='tour_id',
index_label='tour_id')

force_garbage_collect()
3 changes: 3 additions & 0 deletions activitysim/abm/models/auto_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def auto_ownership_simulate(households,
estimator.write_coefficients(coefficients_df, model_settings)
estimator.write_choosers(choosers)

log_alt_losers = config.setting('log_alt_losers', False)

choices = simulate.simple_simulate(
choosers=choosers,
spec=model_spec,
Expand All @@ -54,6 +56,7 @@ def auto_ownership_simulate(households,
chunk_size=chunk_size,
trace_label=trace_label,
trace_choice_name='auto_ownership',
log_alt_losers=log_alt_losers,
estimator=estimator)

if estimator:
Expand Down
62 changes: 47 additions & 15 deletions activitysim/abm/models/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from activitysim.core import inject
from activitysim.core import pipeline
from activitysim.core import expressions
from activitysim.core import chunk
from activitysim.core import mem

from activitysim.core.steps.output import write_data_dictionary
Expand Down Expand Up @@ -39,6 +40,10 @@

def annotate_tables(model_settings, trace_label):

trace_label = tracing.extend_trace_label(trace_label, 'annotate_tables')

chunk.log_rss(trace_label)

annotate_tables = model_settings.get('annotate_tables', [])

if not annotate_tables:
Expand All @@ -53,7 +58,10 @@ def annotate_tables(model_settings, trace_label):

tablename = table_info['tablename']

chunk.log_rss(f"{trace_label}.pre-get_table.{tablename}")

df = inject.get_table(tablename).to_frame()
chunk.log_df(trace_label, tablename, df)

# - rename columns
column_map = table_info.get('column_map', None)
Expand All @@ -75,42 +83,66 @@ def annotate_tables(model_settings, trace_label):
model_settings=annotate,
trace_label=trace_label)

# fixme - narrow?
chunk.log_df(trace_label, tablename, df)

# - write table to pipeline
pipeline.replace_table(tablename, df)

del df
chunk.log_df(trace_label, tablename, None)


@inject.step()
def initialize_landuse():

trace_label = 'initialize_landuse'

model_settings = config.read_model_settings('initialize_landuse.yaml', mandatory=True)
with chunk.chunk_log(trace_label, base=True):

model_settings = config.read_model_settings('initialize_landuse.yaml', mandatory=True)

annotate_tables(model_settings, trace_label)
annotate_tables(model_settings, trace_label)

# instantiate accessibility (must be checkpointed to be be used to slice accessibility)
accessibility = pipeline.get_table('accessibility')
# instantiate accessibility (must be checkpointed to be be used to slice accessibility)
accessibility = pipeline.get_table('accessibility')
chunk.log_df(trace_label, "accessibility", accessibility)


@inject.step()
def initialize_households():

trace_label = 'initialize_households'

model_settings = config.read_model_settings('initialize_households.yaml', mandatory=True)
annotate_tables(model_settings, trace_label)
with chunk.chunk_log(trace_label, base=True):

# - initialize shadow_pricing size tables after annotating household and person tables
# since these are scaled to model size, they have to be created while single-process
shadow_pricing.add_size_tables()
mem.trace_memory_info(f"initialize_households after shadow_pricing.add_size_tables")
chunk.log_rss(f"{trace_label}.inside-yield")

# - preload person_windows
t0 = tracing.print_elapsed_time()
inject.get_table('person_windows').to_frame()
t0 = tracing.print_elapsed_time("preload person_windows", t0, debug=True)
households = inject.get_table('households').to_frame()
assert not households._is_view
chunk.log_df(trace_label, "households", households)
del households
chunk.log_df(trace_label, "households", None)

persons = inject.get_table('persons').to_frame()
assert not persons._is_view
chunk.log_df(trace_label, "persons", persons)
del persons
chunk.log_df(trace_label, "persons", None)

model_settings = config.read_model_settings('initialize_households.yaml', mandatory=True)
annotate_tables(model_settings, trace_label)

# - initialize shadow_pricing size tables after annotating household and person tables
# since these are scaled to model size, they have to be created while single-process
# this can now be called as a stand alone model step instead, add_size_tables
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()

# - preload person_windows
person_windows = inject.get_table('person_windows').to_frame()
chunk.log_df(trace_label, "person_windows", person_windows)


@inject.injectable(cache=True)
Expand Down
60 changes: 14 additions & 46 deletions activitysim/abm/models/initialize_los.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,47 +112,6 @@ def initialize_los(network_los):
np.copyto(data, np.nan)


def initialize_tvpb_calc_row_size(choosers, network_los, trace_label):
"""
rows_per_chunk calculator for trip_purpose
"""

sizer = chunk.RowSizeEstimator(trace_label)

model_settings = \
network_los.setting(f'TVPB_SETTINGS.tour_mode_choice.tap_tap_settings')
attributes_as_columns = \
network_los.setting('TVPB_SETTINGS.tour_mode_choice.tap_tap_settings.attributes_as_columns', [])

# expression_values for each spec row
sizer.add_elements(len(choosers.columns), 'choosers')

# expression_values for each spec row
sizer.add_elements(len(attributes_as_columns), 'attributes_as_columns')

preprocessor_settings = model_settings.get('PREPROCESSOR')
if preprocessor_settings:

preprocessor_spec_name = preprocessor_settings.get('SPEC', None)

if not preprocessor_spec_name.endswith(".csv"):
preprocessor_spec_name = f'{preprocessor_spec_name}.csv'
expressions_spec = assign.read_assignment_spec(config.config_file_path(preprocessor_spec_name))

sizer.add_elements(expressions_spec.shape[0], 'preprocessor')

# expression_values for each spec row
spec = simulate.read_model_spec(file_name=model_settings['SPEC'])
sizer.add_elements(spec.shape[0], 'expression_values')

# expression_values for each spec row
sizer.add_elements(spec.shape[1], 'utilities')

row_size = sizer.get_hwm()

return row_size


def compute_utilities_for_atttribute_tuple(network_los, scalar_attributes, data, chunk_size, trace_label):

# scalar_attributes is a dict of attribute name/value pairs for this combination
Expand All @@ -175,19 +134,25 @@ def compute_utilities_for_atttribute_tuple(network_los, scalar_attributes, data,
# get od skim_offset dataframe with uid index corresponding to scalar_attributes
choosers_df = uid_calculator.get_od_dataframe(scalar_attributes)

row_size = chunk_size and initialize_tvpb_calc_row_size(choosers_df, network_los, trace_label)
# choosers_df is pretty big and was custom made for compute_utilities but we don't need to chunk_log it
# since it is created outside of adaptive_chunked_choosers and so will show up in baseline
assert not chunk.chunk_logging() # otherwise we should chunk_log this

chunk_tag = 'initialize_tvpb' # all attribute_combinations can use same cached data for row_size calc

for i, chooser_chunk, chunk_trace_label \
in chunk.adaptive_chunked_choosers(choosers_df, chunk_size, row_size, trace_label):
in chunk.adaptive_chunked_choosers(choosers_df, chunk_size, trace_label, chunk_tag=chunk_tag):

# we should count choosers_df as chunk overhead since its pretty big and was custom made for compute_utilities
# (call log_df from inside yield loop so it is visible to adaptive_chunked_choosers chunk_log)
chunk.log_df(trace_label, 'choosers_df', choosers_df)
assert chooser_chunk._is_view # otherwise copying it is wasteful
chooser_chunk = chooser_chunk.copy()
chunk.log_df(trace_label, 'attribute_chooser_chunk', chooser_chunk)

# add any attribute columns specified as column attributes in settings (the rest will be scalars in locals_dict)
for attribute_name in attributes_as_columns:
chooser_chunk[attribute_name] = scalar_attributes[attribute_name]

chunk.log_df(trace_label, 'chooser_chunk', chooser_chunk)
chunk.log_df(trace_label, 'attribute_chooser_chunk', chooser_chunk)

utilities_df = \
pathbuilder.compute_utilities(network_los,
Expand All @@ -204,6 +169,9 @@ def compute_utilities_for_atttribute_tuple(network_los, scalar_attributes, data,

data[chooser_chunk.index.values, :] = utilities_df.values

del chooser_chunk
chunk.log_df(trace_label, 'attribute_chooser_chunk', None)

logger.debug(f"{trace_label} updated utilities")


Expand Down
4 changes: 2 additions & 2 deletions activitysim/abm/models/initialize_tours.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def initialize_tours(network_los, households, persons, trace_hh_id):

tracing.register_traceable_table('tours', tours)

print(f"{len(tours.household_id.unique())} unique household_ids in tours")
print(f"{len(households.index.unique())} unique household_ids in households")
logger.debug(f"{len(tours.household_id.unique())} unique household_ids in tours")
logger.debug(f"{len(households.index.unique())} unique household_ids in households")
assert not tours.index.duplicated().any()

tours_without_persons = ~tours.person_id.isin(persons.index)
Expand Down
4 changes: 2 additions & 2 deletions activitysim/abm/models/joint_tour_participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def participants_chooser(probs, choosers, spec, trace_label):
probs = probs[~satisfied]
candidates = candidates[~satisfied]

logger.info('%s iteration %s : %s joint tours satisfied %s remaining' %
(trace_label, iter, num_tours_satisfied_this_iter, num_tours_remaining,))
logger.debug(f"{trace_label} iteration {iter} : "
f"{num_tours_satisfied_this_iter} joint tours satisfied {num_tours_remaining} remaining")

choices = pd.concat(choices_list)
rands = pd.concat(rands_list).reindex(choosers.index)
Expand Down
Loading