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

Config Settings and Documentation #758

Merged
merged 459 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
459 commits
Select commit Hold shift + click to select a range
1681445
yaml.dump paths to strings
jpn-- May 5, 2023
aa1b058
logit configs in separate file [makedocs]
jpn-- May 5, 2023
9b78306
configs for trip dest
jpn-- May 8, 2023
69b93c8
cleanup
jpn-- May 8, 2023
a918c9c
deprecate DESTINATION_SAMPLE_SPEC and DESTINATION_SPEC
jpn-- May 8, 2023
18ec447
cfg for mandatory locations
jpn-- May 9, 2023
a349d93
shadow pricing cfg
jpn-- May 9, 2023
609086b
COEFFS file is optional
jpn-- May 9, 2023
0f9cb3b
common tour location component settings
jpn-- May 9, 2023
d382bb5
pop include_settings
jpn-- May 10, 2023
95c01ab
fix SHADOW_PRICE_METHOD
jpn-- May 10, 2023
cc452cc
fix bugs
jpn-- May 10, 2023
3fa10a6
repair
jpn-- May 10, 2023
45e057b
TourODSettings
jpn-- May 10, 2023
6fad550
robust write_spec
jpn-- May 10, 2023
4037af5
accessibility config
jpn-- May 12, 2023
ef4346a
tour mode
jpn-- May 15, 2023
ee71901
prefer float to str
jpn-- May 15, 2023
9806b3b
clean up
jpn-- May 16, 2023
7f4eb0b
overflow protection in utils_to_probs
jpn-- May 17, 2023
c40632a
only enable overflow_protect when not allow_zero_probs
jpn-- May 17, 2023
532e9e9
logsums w probs
jpn-- May 17, 2023
c6b15c7
tweaks in regression test due to overflow protection
jpn-- May 18, 2023
dad22d0
Merge branch 'develop' into overflow-protection
jpn-- May 19, 2023
52b8b79
Merge branch 'overflow-protection' into cfg-TourMode
jpn-- May 19, 2023
3a3088d
test logging
jpn-- May 25, 2023
f1e894d
annotate rng
jpn-- May 25, 2023
b483556
Merge branch 'upstream-develop' into generic-whale
jpn-- May 25, 2023
325eb3d
update semcog model
jpn-- May 25, 2023
939f323
docs for logging
jpn-- May 25, 2023
5d4c4db
fix semcog example test
jpn-- May 25, 2023
6b9d8b8
only one add_size_tables func
jpn-- May 25, 2023
d5fdfe1
better error msg
jpn-- May 25, 2023
c84925d
remove extra lines
jpn-- May 25, 2023
a2bb99d
multiple output dirs for tests
jpn-- May 25, 2023
f35fa59
push recoding
jpn-- Jun 1, 2023
1956e87
recoding both ways
jpn-- Jun 1, 2023
027a575
recoding on mp
jpn-- Jun 2, 2023
b851226
Merge branch 'fix-684' into cfg-TourMode
jpn-- Jun 2, 2023
dee5ea4
avoid error sorting on no index
jpn-- Jun 2, 2023
19bc4f7
validate settings
jpn-- Jun 2, 2023
099bcd0
public BaseLogitComponentSettings
jpn-- Jun 19, 2023
6160f4b
fix for chunking
jpn-- Jun 19, 2023
f626778
blacken
jpn-- Jun 19, 2023
d2992f0
remove vestigial log_df
jpn-- Jun 19, 2023
038a408
undo junk
jpn-- Jun 19, 2023
4963260
docstring
jpn-- Jun 19, 2023
a3e430d
write log to output dir
jpn-- Jun 20, 2023
11d2902
more docs on logging
jpn-- Jun 20, 2023
59e8dd7
bigger chunksize, too small times out
jpn-- Jun 20, 2023
ad9e23b
clean up when missing TAZ input table
jpn-- Jun 20, 2023
c592f94
historian
jpn-- Jun 20, 2023
ee7bc37
allow state to be None
jpn-- Jun 20, 2023
8435976
change recode_pipeline_columns default to false
jpn-- Jun 21, 2023
2f4bec5
update prototype_psrc_in_development
jpn-- Jun 21, 2023
5868bb3
fix cdap for sharrow
jpn-- Jun 21, 2023
4c4838c
import skim_dataset
jpn-- Jun 21, 2023
22eee5b
recode pipeline for mtc
jpn-- Jun 21, 2023
0f01901
Multiprocessing Performance
jpn-- Jun 22, 2023
a45304b
Arithmetic on Logical Values
jpn-- Jun 23, 2023
c8c492b
clarify
jpn-- Jun 23, 2023
318d7f7
Merge branch 'generic-whale' into cfg-TourMode
jpn-- Jun 26, 2023
831ec5c
annotations
jpn-- Jun 26, 2023
eb38e6b
config for joint tour freq
jpn-- Jun 26, 2023
9bfd5ee
TimeSettings
jpn-- Jun 30, 2023
1c065ac
allow deprecated hours
jpn-- Jun 30, 2023
84f1829
Merge branch 'orca-cleanup' into time-settings
jpn-- Aug 7, 2023
5b5e401
test commit
vivekyadav26 Sep 7, 2023
7300a90
updating work from home documentation
vivekyadav26 Sep 8, 2023
2c9b071
update model settings of work from home model
vivekyadav26 Sep 9, 2023
b392750
school and work location choice documentation
vivekyadav26 Sep 18, 2023
9fb33ec
auto ownership
vivekyadav26 Sep 19, 2023
5f6033d
accessibility documentation
vivekyadav26 Sep 19, 2023
089d9c8
format fix
vivekyadav26 Sep 19, 2023
c5f51d4
Merge branch 'time-settings' into cfg-doc-2
jpn-- Sep 19, 2023
4775eda
auto_ownership is a logit model
jpn-- Sep 19, 2023
7eb97db
docbuild uses pydantic 1.10
jpn-- Sep 19, 2023
617530a
add more components to docs
jpn-- Sep 19, 2023
4657ec3
ao docs [makedocs]
jpn-- Sep 19, 2023
3c45b16
Adding examples to accessibility
vivekyadav26 Sep 19, 2023
fbcc9a1
Merge branch 'cfg-doc-2' into cfg-documentation-vy
jpn-- Sep 19, 2023
372da21
updated transit pass subsidy model
vivekyadav26 Oct 24, 2023
fe60d15
Updating model components
vivekyadav26 Oct 24, 2023
fb3f72e
update telecommute frequency
vivekyadav26 Oct 24, 2023
ba9ec40
updating telecommute frequency and mandatory tour frequency
vivekyadav26 Oct 24, 2023
37eaa4f
update joint tout composition
vivekyadav26 Oct 24, 2023
7bf96fc
update joint tour participation. There is model_settings.get that nee…
vivekyadav26 Oct 24, 2023
dba895d
Update joint tour scheduling
vivekyadav26 Oct 24, 2023
84106a4
Update non mandatory tour frequency. Needs closer review
vivekyadav26 Oct 24, 2023
fa10214
update vehicle allocation and atwork subtour frequency
vivekyadav26 Oct 24, 2023
5fe2603
update several models
vivekyadav26 Oct 24, 2023
1866330
updated documentation for few models
navsarmajs Oct 27, 2023
187633f
Merge branch 'cfg-documentation-vy' into Branch_nav_cfg-documentation-vy
navsarmajs Oct 27, 2023
95d5a9a
Updating component documentation
vivekyadav26 Oct 27, 2023
a26a1e4
bug fix
vivekyadav26 Oct 27, 2023
7151fc9
fix bug
vivekyadav26 Oct 27, 2023
982973e
how to build docs [makedocs]
jpn-- Oct 27, 2023
2b667d1
Added component documentation for more models
navsarmajs Oct 30, 2023
3507e67
Merge branch 'cfg-documentation-vy' into Branch_nav_cfg-documentation-vy
navsarmajs Oct 30, 2023
66d6989
Documented more model componets and added to index toctree
navsarmajs Oct 30, 2023
257b5aa
Model Component Documentation
navsarmajs Oct 30, 2023
8fe0ea3
updating stop frequency, trip purpose and trip scheduling documentation
vivekyadav26 Oct 30, 2023
4df5b32
Merge branch 'cfg-documentation-vy' into cfg-documentation-navjs
navsarmajs Oct 30, 2023
db2a5c4
updating component documentation
vivekyadav26 Oct 30, 2023
f415d43
Update vehicle allocation and build docs [makedocs]
vivekyadav26 Oct 30, 2023
b10c538
documentation fixes [makedocs]
vivekyadav26 Oct 30, 2023
1f93167
minor fixes [makedocs]
vivekyadav26 Oct 30, 2023
2eb75f9
Added Documentation for more models
navsarmajs Oct 30, 2023
ba2d165
Adding annotate_tables settings class
vivekyadav26 Oct 30, 2023
246e611
Update cdap.md
vivekyadav26 Oct 31, 2023
195c1ed
Update disaggregate_accessibility.md
vivekyadav26 Oct 31, 2023
d990db3
Update initialize.md
vivekyadav26 Oct 31, 2023
83c1b2d
Update initialize_los.md
vivekyadav26 Oct 31, 2023
90bb7a2
Update mandatory_scheduling.md
vivekyadav26 Oct 31, 2023
e9acd33
Update mandatory_tour_frequency.md
vivekyadav26 Oct 31, 2023
2d558c4
Update telecommute_frequency.md
vivekyadav26 Oct 31, 2023
d9e7c93
Update telecommute_frequency.md
vivekyadav26 Oct 31, 2023
538f405
Update transit_pass_ownership.md
vivekyadav26 Oct 31, 2023
28b3fa3
Update transit_pass_subsidy.md
vivekyadav26 Oct 31, 2023
b0e6131
Update vehicle_type_choice.md
vivekyadav26 Oct 31, 2023
d5b24dd
Merge branch 'cfg-documentation-vy' into cfg-documentation-navjs
vivekyadav26 Oct 31, 2023
200d73d
Merge pull request #11 from camsys/cfg-documentation-navjs
vivekyadav26 Oct 31, 2023
0b7efcf
Updated documentation for joint tour compostion model
navsarmajs Oct 31, 2023
42abe71
Merge branch 'cfg-documentation-navjs' of https://github.com/camsys/a…
navsarmajs Oct 31, 2023
c9615ce
Added documentation for more models and minor bug fixes
navsarmajs Oct 31, 2023
5f16583
Update non_mandatory_scheduling.md
vivekyadav26 Nov 1, 2023
13cfa28
Merge pull request #12 from camsys/cfg-documentation-navjs
vivekyadav26 Nov 1, 2023
a24d8e4
minor edits [makedocs]
vivekyadav26 Nov 6, 2023
7f5693e
verbose action [makedocs]
jpn-- Oct 27, 2023
26d54c6
bump pytables to 3.9
jpn-- Nov 6, 2023
199ae2e
pin autodoc_pydantic<2.0
jpn-- Nov 6, 2023
ff87616
[makedocs]
jpn-- Nov 6, 2023
fc5d9a5
escorting
jpn-- Nov 6, 2023
73fc620
Merge pull request #13 from camsys/cfg-docs-jn-2
vivekyadav26 Nov 7, 2023
b40dffc
[makedocs]
vivekyadav26 Nov 7, 2023
34adea1
Merge branch 'cfg-documentation-vy' of https://github.com/camsys/acti…
vivekyadav26 Nov 7, 2023
4f5d56d
minor edits [makedocs]
vivekyadav26 Nov 7, 2023
4be2058
test initialize
vivekyadav26 Nov 7, 2023
fc17ced
test
vivekyadav26 Nov 7, 2023
501430f
AnnotateTableSettings
jpn-- Nov 7, 2023
86c3820
init tables things
jpn-- Nov 7, 2023
ac5ca47
bug fixes [makedocs]
vivekyadav26 Nov 7, 2023
8b9596c
Merge branch 'cfg-documentation-vy' into cfg-docs-jn-escort
jpn-- Nov 9, 2023
529a4df
documentation updates [makedocs]
vivekyadav26 Nov 9, 2023
dead81a
Merge commit '529a4df3f18c2f44d856b4339c7c391e503b7f67' into cfg-docs…
jpn-- Nov 9, 2023
237c0c6
more precise type
jpn-- Nov 9, 2023
9b8fd95
fix jtp
jpn-- Nov 9, 2023
2901363
adding size tables
vivekyadav26 Nov 9, 2023
2772d7e
read coefficients of mandatory tour frequency
vivekyadav26 Nov 9, 2023
7600776
Revert "read coefficients of mandatory tour frequency"
vivekyadav26 Nov 9, 2023
6f95526
read coeff
vivekyadav26 Nov 9, 2023
9eaebe4
NonMandatoryTourFrequencySettings as logit
jpn-- Nov 9, 2023
50bfe41
Merge branch 'cfg-docs-jn-escort' into cfg-documentation-vy
jpn-- Nov 9, 2023
3c4369c
drop dupe MandatoryTourFrequencySettings
jpn-- Nov 9, 2023
7985f2c
updating joint tour frequency composition
vivekyadav26 Nov 10, 2023
5e90e65
progress on tests
jpn-- Nov 10, 2023
23a9e72
mostly through test1
jpn-- Nov 10, 2023
4d05c28
fix summarize
jpn-- Nov 10, 2023
b184ae0
fix tour schedule test
jpn-- Nov 10, 2023
ca3a42b
3 zone settings for trip mode
jpn-- Nov 10, 2023
d711d5e
fix annotate_table if missing
jpn-- Nov 10, 2023
e6c1a69
various fixing
jpn-- Nov 10, 2023
958f335
TelecommuteFrequencySettings should be LogitComponentSettings
jpn-- Nov 10, 2023
0d25796
repair vehicle type settings
jpn-- Nov 10, 2023
3d512f6
fix - trip scheduling choice
vivekyadav26 Nov 10, 2023
3748f35
fixing
jpn-- Nov 10, 2023
245b872
comment out unused settings
jpn-- Nov 10, 2023
b40fd29
Initial commit for revised user guide, changes to user guide index an…
navsarmajs Nov 10, 2023
4993f76
Merge commit '3d512f64a1df63435429fedd586764522a994826' into cfg-docu…
jpn-- Nov 10, 2023
e4825e9
fix tests for mtc_extended
jpn-- Nov 10, 2023
a5f1476
fix arc
jpn-- Nov 11, 2023
7bce5f2
partial disagg accessblty
jpn-- Nov 11, 2023
16189f1
disagg acc doesn't crash but different results
jpn-- Nov 11, 2023
04c1d14
cdap settings
jpn-- Nov 11, 2023
4288459
trip purpose
jpn-- Nov 11, 2023
18f04ca
also constants
jpn-- Nov 11, 2023
1b75bef
Merge commit '460203c5b54c597e4416bbef30d67fc2a9da3ee8' into cfg-docu…
jpn-- Nov 12, 2023
da00756
updating auto ownership [makedocs]
vivekyadav26 Nov 13, 2023
4d7aac5
prefer float values so fractions are not swallowed
jpn-- Nov 13, 2023
eb05ab7
rollback to have AutoOwnership settings
jpn-- Nov 13, 2023
cfaa5f9
JointTourFreqCompSettings
jpn-- Nov 14, 2023
2c0b700
typos [makedocs]
jpn-- Nov 14, 2023
115f4d8
more doc updates
vivekyadav26 Nov 14, 2023
749ad0a
update cdap
vivekyadav26 Nov 14, 2023
5702e49
Merge branch 'cfg-documentation-vy' of https://github.com/camsys/acti…
vivekyadav26 Nov 14, 2023
6763bc7
clean up disagg accesbly
jpn-- Nov 14, 2023
f357115
format admonition [makedocs]
jpn-- Nov 14, 2023
7ff414e
fix disagg acc
jpn-- Nov 14, 2023
8a844df
Updates to modelsetup documentation page in user-guide
navsarmajs Nov 15, 2023
0bca9fa
Merge branch 'cfg-documentation-vy' into user-guide-doc-navjs
vivekyadav26 Nov 15, 2023
bdb379c
Updates to model run user guide documentation
navsarmajs Nov 16, 2023
18ce345
User guide documentation updates (Ways to run the model)
navsarmajs Nov 16, 2023
dffb45a
Completed documentation of ways to run section in user guide
navsarmajs Nov 16, 2023
d1fd8ae
User guide documentation updates to examples section and other minor …
navsarmajs Nov 18, 2023
b3e48f8
User guide documentation for visualization
navsarmajs Nov 18, 2023
6f1bba5
User guide doc updates (how it works section in progress)
navsarmajs Nov 18, 2023
9abafff
added Semcog model structure figure
navsarmajs Nov 18, 2023
0228785
text formatting
vivekyadav26 Nov 18, 2023
34b669b
Merge branch 'user-guide-doc-navjs' of https://github.com/camsys/acti…
vivekyadav26 Nov 18, 2023
a72289c
doc updates
vivekyadav26 Nov 18, 2023
a97aa5e
Minor bug fixes in user guide doc
navsarmajs Nov 19, 2023
dc8f356
User guide documentation updates - added more sections and minor bug …
navsarmajs Nov 20, 2023
bdd56c0
Adding zone system [makedocs]
vivekyadav26 Nov 20, 2023
c0f6a5e
User guide documentation, minor bug fixes and updates
navsarmajs Nov 20, 2023
0e2d6f8
Merge branch 'user-guide-doc-navjs' into cfg-documentation-vy
vivekyadav26 Nov 20, 2023
9cb9400
[makedocs]
vivekyadav26 Nov 20, 2023
70f24a5
Updates to model setup and anatomy user guide documentation
navsarmajs Nov 26, 2023
70570a1
Minor updates and bug fixes in Ways to Run Model user guide doc
navsarmajs Nov 26, 2023
871cee4
Updates to Model anatomy user doc
navsarmajs Nov 26, 2023
a9f9e13
Added flowchart in How it works section of user guide
navsarmajs Nov 26, 2023
2593477
Updates to howitworks section in user guide
navsarmajs Nov 26, 2023
fadc451
Minor updates to example models user guide
navsarmajs Nov 27, 2023
535a08b
Updating school escorting documentation
vivekyadav26 Nov 27, 2023
b827207
Minor updates to example models user guide - reorganization
navsarmajs Nov 27, 2023
169335b
Merge branch 'user-guide-doc-navjs' into cfg-documentation-vy
vivekyadav26 Nov 27, 2023
939e637
[makedocs]
vivekyadav26 Nov 27, 2023
b4fb5a5
Merge branch 'cfg-documentation-vy' into user-guide-doc-navjs
navsarmajs Nov 27, 2023
56843ac
User guide updates
navsarmajs Nov 27, 2023
25a4dab
Merge branch 'user-guide-doc-navjs' into cfg-documentation-vy
vivekyadav26 Nov 27, 2023
ff559a2
[makedocs]
vivekyadav26 Nov 27, 2023
5bec1f9
Removing tables as they are not being rendered properly [makedocs]
vivekyadav26 Nov 27, 2023
fe9f8e6
[makedocs]
navsarmajs Nov 28, 2023
a92cb66
[makedocs] Fixed broken image links in visualization user guide
navsarmajs Nov 28, 2023
fcc99f8
adding tables and removing models.rst [makedocs]
vivekyadav26 Nov 28, 2023
a46c737
error fix [makedocs]
vivekyadav26 Nov 28, 2023
1310dce
Merge branch 'develop' into cfg-documentation-vy
jpn-- Dec 5, 2023
12b8a49
fix estimation mode to use correct default SIZE_TERM_SELECTOR
jpn-- Dec 5, 2023
e99e564
drop buggy test for now
jpn-- Dec 6, 2023
03c3e38
Updates to user guide - Minor additions and bug fixes.
navsarmajs Dec 11, 2023
3799c08
Navigation bug fixes in Model Anatomy User guide
navsarmajs Dec 13, 2023
75703b1
[makedocs]
navsarmajs Dec 13, 2023
f4f4ba3
Minor bug fixes and user guide improvements
navsarmajs Dec 13, 2023
6b351a7
[makedocs]
navsarmajs Dec 15, 2023
e26e67f
Updates to users guide - model setup page
navsarmajs Dec 21, 2023
03d53d6
Merge branch 'develop' of https://github.com/camsys/activitysim into …
jpn-- Dec 22, 2023
3bbee7b
User guide updates - example models section
navsarmajs Dec 22, 2023
e4f3003
[makedocs] Updates to userguide documentation
navsarmajs Dec 22, 2023
bc88594
Merge branch 'cfg-documentation-vy' into user-guide-doc-navjs
vivekyadav26 Dec 28, 2023
aea3903
Merge pull request #14 from camsys/user-guide-doc-navjs
vivekyadav26 Dec 28, 2023
3e07dbe
[makedocs]
vivekyadav26 Dec 28, 2023
3358002
harmonize on consistent read_file_settings
jpn-- Jan 29, 2024
d70bc16
drop extra file load
jpn-- Jan 29, 2024
5e89e32
InitializeToursSettings
jpn-- Jan 29, 2024
1d9c4d6
use JointTourParticipationSettings
jpn-- Jan 29, 2024
486a4f3
use TourModeComponentSettings for logsum_settings
jpn-- Jan 29, 2024
7f4c1e1
remove old comment
jpn-- Jan 29, 2024
0fa85e2
add missing import
jpn-- Jan 29, 2024
25644f9
docstrings
jpn-- Jan 29, 2024
a5ee11b
bugfix
jpn-- Jan 29, 2024
b24874a
Merge branch 'develop' into cfg-documentation-vy
jpn-- Feb 1, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/branch-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
id: cache

- name: Update environment
run: mamba env update -n docbuild -f conda-environments/docbuild.yml
run: mamba env update --verbose -n docbuild -f conda-environments/docbuild.yml
if: steps.cache.outputs.cache-hit != 'true'

- name: Install activitysim
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sandbox/
.pytest_cache
.vagrant


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
17 changes: 9 additions & 8 deletions activitysim/abm/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging

import numpy as np
import pandas as pd

from activitysim.core import workflow
Expand All @@ -16,16 +17,16 @@


@workflow.cached_object
def households_sample_size(state: workflow.State, override_hh_ids):
def households_sample_size(state: workflow.State, override_hh_ids) -> int:

if override_hh_ids is None:
return state.settings, households_sample_size
return state.settings.households_sample_size
else:
return 0 if override_hh_ids is None else len(override_hh_ids)
return len(override_hh_ids)


@workflow.cached_object
def override_hh_ids(state: workflow.State):
def override_hh_ids(state: workflow.State) -> np.ndarray | None:

hh_ids_filename = state.settings.hh_ids
if hh_ids_filename is None:
Expand Down Expand Up @@ -63,12 +64,12 @@ def override_hh_ids(state: workflow.State):


@workflow.cached_object
def trace_od(state: workflow.State):
def trace_od(state: workflow.State) -> tuple[int, int] | None:

od = state.settings.trace_od

if od and not (
isinstance(od, (list, tuple))
isinstance(od, list | tuple)
and len(od) == 2
and all(isinstance(x, int) for x in od)
):
Expand All @@ -81,12 +82,12 @@ def trace_od(state: workflow.State):


@workflow.cached_object
def chunk_size(state: workflow.State):
def chunk_size(state: workflow.State) -> int:
_chunk_size = int(state.settings.chunk_size or 0)

return _chunk_size


@workflow.cached_object
def check_for_variability(state: workflow.State):
def check_for_variability(state: workflow.State) -> bool:
return bool(state.settings.check_for_variability)
52 changes: 40 additions & 12 deletions activitysim/abm/models/accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@
from __future__ import annotations

import logging
from typing import Any

import numba as nb
import numpy as np
import pandas as pd

from activitysim.core import assign, chunk, los, workflow
from activitysim.core.configuration.base import PydanticReadable

logger = logging.getLogger(__name__)


class AccessibilitySettings(PydanticReadable):
"""
Settings for aggregate accessibility component.
"""

CONSTANTS: dict[str, Any] = {}

land_use_columns: list[str] = []
"""Only include the these columns in the computational tables

Memory usage is reduced by only listing the minimum columns needed by
the SPEC, and nothing extra.
"""

SPEC: str = "accessibility.csv"
"""Filename for the accessibility specification (csv) file."""


@nb.njit
def _accumulate_accessibility(arr, orig_zone_count, dest_zone_count):
assert arr.size == orig_zone_count * dest_zone_count
Expand Down Expand Up @@ -144,6 +164,10 @@ def compute_accessibility(
land_use: pd.DataFrame,
accessibility: pd.DataFrame,
network_los: los.Network_LOS,
model_settings: AccessibilitySettings | None = None,
model_settings_file_name: str = "accessibility.yaml",
trace_label: str = "compute_accessibility",
output_table_name: str = "accessibility",
) -> None:
"""
Compute accessibility for each zone in land use file using expressions from accessibility_spec
Expand All @@ -160,40 +184,44 @@ def compute_accessibility(
product mutes large differences. The decay function on the walk accessibility measure is
steeper than automobile or transit. The minimum accessibility is zero.
"""
if model_settings is None:
model_settings = AccessibilitySettings.read_settings_file(
state.filesystem, model_settings_file_name
)

trace_label = "compute_accessibility"
model_settings = state.filesystem.read_model_settings("accessibility.yaml")
assignment_spec = assign.read_assignment_spec(
state.filesystem.get_config_file_path("accessibility.csv")
state.filesystem.get_config_file_path(model_settings.SPEC)
)

accessibility_df = accessibility
if len(accessibility_df.columns) > 0:
logger.warning(
f"accessibility table is not empty. Columns:{list(accessibility_df.columns)}"
f"accessibility table is not empty. "
f"Columns:{list(accessibility_df.columns)}"
)
raise RuntimeError("accessibility table is not empty.")

constants = model_settings.get("CONSTANTS", {})
constants = model_settings.CONSTANTS

# only include the land_use columns needed by spec, as specified by land_use_columns model_setting
land_use_columns = model_settings.get("land_use_columns", [])
# only include the land_use columns needed by spec,
# as specified by land_use_columns model_setting
land_use_columns = model_settings.land_use_columns
land_use_df = land_use
land_use_df = land_use_df[land_use_columns]

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

accessibilities_list = []

for (
i,
_i,
chooser_chunk,
chunk_trace_label,
_chunk_trace_label,
chunk_sizer,
) in chunk.adaptive_chunked_choosers(state, accessibility_df, trace_label):

accessibilities = compute_accessibilities_for_zones(
state,
chooser_chunk,
Expand All @@ -211,4 +239,4 @@ def compute_accessibility(
logger.info(f"{trace_label} computed accessibilities {accessibility_df.shape}")

# - write table to pipeline
state.add_table("accessibility", accessibility_df)
state.add_table(output_table_name, accessibility_df)
22 changes: 14 additions & 8 deletions activitysim/abm/models/atwork_subtour_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from activitysim.abm.models.util import tour_destination
from activitysim.core import config, estimation, los, tracing, workflow
from activitysim.core.configuration.logit import TourLocationComponentSettings
from activitysim.core.util import assign_in_place

logger = logging.getLogger(__name__)
Expand All @@ -20,25 +21,30 @@ def atwork_subtour_destination(
tours: pd.DataFrame,
persons_merged: pd.DataFrame,
network_los: los.Network_LOS,
model_settings: TourLocationComponentSettings | None = None,
model_settings_file_name: str = "atwork_subtour_destination.yaml",
trace_label: str = "atwork_subtour_destination",
) -> None:
trace_label = "atwork_subtour_destination"
model_settings_file_name = "atwork_subtour_destination.yaml"
model_settings = state.filesystem.read_model_settings(model_settings_file_name)
if model_settings is None:
model_settings = TourLocationComponentSettings.read_settings_file(
state.filesystem,
model_settings_file_name,
)

future_settings = {
"SIZE_TERM_SELECTOR": "atwork",
"SEGMENTS": ["atwork"],
"ORIG_ZONE_ID": "workplace_zone_id",
}
model_settings = config.future_model_settings(
model_settings = config.future_component_settings(
model_settings_file_name, model_settings, future_settings
)

destination_column_name = "destination"
logsum_column_name = model_settings.get("DEST_CHOICE_LOGSUM_COLUMN_NAME")
logsum_column_name = model_settings.DEST_CHOICE_LOGSUM_COLUMN_NAME
want_logsums = logsum_column_name is not None

sample_table_name = model_settings.get("DEST_CHOICE_SAMPLE_TABLE_NAME")
sample_table_name = model_settings.DEST_CHOICE_SAMPLE_TABLE_NAME
want_sample_table = (
state.settings.want_dest_choice_sample_tables and sample_table_name is not None
)
Expand All @@ -54,8 +60,8 @@ def atwork_subtour_destination(
if estimator:
estimator.write_coefficients(model_settings=model_settings)
# estimator.write_spec(model_settings, tag='SAMPLE_SPEC')
estimator.write_spec(model_settings, tag="SPEC")
estimator.set_alt_id(model_settings["ALT_DEST_COL_NAME"])
estimator.write_spec(file_name=model_settings.SPEC, tag="SPEC")
estimator.set_alt_id(model_settings.ALT_DEST_COL_NAME)
estimator.write_table(
state.get_injectable("size_terms"), "size_terms", append=False
)
Expand Down
27 changes: 22 additions & 5 deletions activitysim/abm/models/atwork_subtour_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
tracing,
workflow,
)
from activitysim.core.configuration.base import PreprocessorSettings, PydanticReadable
from activitysim.core.configuration.logit import LogitComponentSettings

logger = logging.getLogger(__name__)

Expand All @@ -26,20 +28,30 @@ def add_null_results(state, trace_label, tours):
state.add_table("tours", tours)


class AtworkSubtourFrequencySettings(LogitComponentSettings, extra="forbid"):
"""
Settings for the `atwork_subtour_frequency` component.
"""

preprocessor: PreprocessorSettings | None = None
"""Setting for the preprocessor."""


@workflow.step
def atwork_subtour_frequency(
state: workflow.State,
tours: pd.DataFrame,
persons_merged: pd.DataFrame,
model_settings: AtworkSubtourFrequencySettings | None = None,
model_settings_file_name: str = "atwork_subtour_frequency.yaml",
trace_label: str = "atwork_subtour_frequency",
) -> None:
"""
This model predicts the frequency of making at-work subtour tours
(alternatives for this model come from a separate csv file which is
configured by the user).
"""

trace_label = "atwork_subtour_frequency"
model_settings_file_name = "atwork_subtour_frequency.yaml"
trace_hh_id = state.settings.trace_hh_id
work_tours = tours[tours.tour_type == "work"]

Expand All @@ -48,10 +60,15 @@ def atwork_subtour_frequency(
add_null_results(state, trace_label, tours)
return

model_settings = state.filesystem.read_model_settings(model_settings_file_name)
if model_settings is None:
model_settings = AtworkSubtourFrequencySettings.read_settings_file(
state.filesystem,
model_settings_file_name,
)

estimator = estimation.manager.begin_estimation(state, "atwork_subtour_frequency")

model_spec = state.filesystem.read_model_spec(file_name=model_settings["SPEC"])
model_spec = state.filesystem.read_model_spec(file_name=model_settings.SPEC)
coefficients_df = state.filesystem.read_model_coefficients(model_settings)
model_spec = simulate.eval_coefficients(
state, model_spec, coefficients_df, estimator
Expand All @@ -72,7 +89,7 @@ def atwork_subtour_frequency(
constants = config.get_model_constants(model_settings)

# - preprocessor
preprocessor_settings = model_settings.get("preprocessor", None)
preprocessor_settings = model_settings.preprocessor
if preprocessor_settings:
expressions.assign_columns(
state,
Expand Down
23 changes: 14 additions & 9 deletions activitysim/abm/models/atwork_subtour_mode_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from activitysim.abm.models.util.mode import run_tour_mode_choice_simulate
from activitysim.core import config, estimation, expressions, los, tracing, workflow
from activitysim.core.configuration.logit import TourModeComponentSettings
from activitysim.core.util import assign_in_place

logger = logging.getLogger(__name__)
Expand All @@ -20,19 +21,23 @@ def atwork_subtour_mode_choice(
tours: pd.DataFrame,
persons_merged: pd.DataFrame,
network_los: los.Network_LOS,
model_settings: TourModeComponentSettings | None = None,
model_settings_file_name: str = "tour_mode_choice.yaml",
trace_label: str = "atwork_subtour_mode_choice",
) -> None:
"""
At-work subtour mode choice simulate
"""

trace_label = "atwork_subtour_mode_choice"

trace_hh_id = state.settings.trace_hh_id

model_settings_file_name = "tour_mode_choice.yaml"
model_settings = state.filesystem.read_model_settings(model_settings_file_name)
if model_settings is None:
model_settings = TourModeComponentSettings.read_settings_file(
state.filesystem,
model_settings_file_name,
)

logsum_column_name = model_settings.get("MODE_CHOICE_LOGSUM_COLUMN_NAME")
logsum_column_name = model_settings.MODE_CHOICE_LOGSUM_COLUMN_NAME
mode_column_name = "tour_mode"

subtours = tours[tours.tour_category == "atwork"]
Expand All @@ -57,7 +62,7 @@ def atwork_subtour_mode_choice(
)

constants = {}
constants.update(config.get_model_constants(model_settings))
constants.update(model_settings.CONSTANTS)

skim_dict = network_los.get_default_skim_dict()

Expand Down Expand Up @@ -149,7 +154,7 @@ def atwork_subtour_mode_choice(

# add cached tvpb_logsum tap choices for modes specified in tvpb_mode_path_types
if network_los.zone_system == los.THREE_ZONE:
tvpb_mode_path_types = model_settings.get("tvpb_mode_path_types")
tvpb_mode_path_types = model_settings.tvpb_mode_path_types
for mode, path_types in tvpb_mode_path_types.items():
for direction, skim in zip(
["od", "do"], [tvpb_logsum_odt, tvpb_logsum_dot]
Expand Down Expand Up @@ -189,12 +194,12 @@ def atwork_subtour_mode_choice(
state.add_table("tours", tours)

# - annotate tours table
if model_settings.get("annotate_tours"):
if model_settings.annotate_tours:
tours = state.get_dataframe("tours")
expressions.assign_columns(
state,
df=tours,
model_settings=model_settings.get("annotate_tours"),
model_settings=model_settings.annotate_tours,
trace_label=tracing.extend_trace_label(trace_label, "annotate_tours"),
)
state.add_table("tours", tours)
Expand Down
Loading
Loading