Skip to content

Commit

Permalink
updated notebooks, default settings for examples, and updated rst files
Browse files Browse the repository at this point in the history
  • Loading branch information
bstabler committed Jan 5, 2021
1 parent 82c6d40 commit 9db97df
Show file tree
Hide file tree
Showing 13 changed files with 7,506 additions and 1,906 deletions.
2 changes: 2 additions & 0 deletions activitysim/core/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ def assign_columns(df, model_settings, locals_dict={}, trace_label=None):
def skim_time_period_label(time_period):
"""
convert time period times to skim time period labels (e.g. 9 -> 'AM')
Parameters
----------
time_period : pandas Series
Returns
-------
pandas Series
Expand Down
55 changes: 27 additions & 28 deletions activitysim/core/los.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from activitysim.core import mem
from activitysim.core import tracing

#
from activitysim.core.skim_dict_factory import NumpyArraySkimFactory
from activitysim.core.skim_dict_factory import MemMapSkimFactory

Expand Down Expand Up @@ -46,33 +45,32 @@ class Network_LOS(object):
"""
singleton object to manage skims and skim-related tables
los_settings_file_name: str # e.g. 'network_los.yaml'
skim_dtype_name:str # e.g. 'float32'
dict_factory_name: str # e.g. 'NumpyArraySkimFactory'
zone_system: str # str (ONE_ZONE, TWO_ZONE, or THREE_ZONE)
skim_time_periods = None # list of str e.g. ['AM', 'MD', 'PM''
skims_info: dict # dict of SkimInfo keyed by skim_tag
skim_buffers: dict # when multiprocessing, dict of multiprocessing.Array buffers keyed by skim_tag
skim_dicts: dice # dict of SkimDict keyed by skim_tag
# TWO_ZONE and THREE_ZONE
maz_taz_df: pandas.DataFrame # DataFrame with two columns, MAZ and TAZ, mapping MAZ to containing TAZ
maz_to_maz_df: pandas.DataFrame # maz_to_maz attributes for MazSkimDict sparse skims
# indexed by synthetic omaz/dmaz index for faster get_mazpairs lookup)
maz_ceiling: int # max maz_id + 1 (to compute synthetic omaz/dmaz index by get_mazpairs)
max_blend_distance: dict # dict of int maz_to_maz max_blend_distance values keyed by skim_tag
# THREE_ZONE only
tap_df: pandas.DataFrame
tap_lines_df: pandas.DataFrame # if specified in settings, list of transit lines served, indexed by TAP
# used to prune maz_to_tap_dfs to drop more distant TAPS with redundant service
# since a TAP can serve multiple lines, tap_lines_df TAP index is not unique
maz_to_tap_dfs: dict # dict of maz_to_tap DataFrames indexed by access mode (e.g. 'walk', 'drive')
# maz_to_tap dfs have OMAZ and DMAZ columns plus additional attribute columns
tap_tap_uid: TapTapUidCalculator
| los_settings_file_name: str # e.g. 'network_los.yaml'
| skim_dtype_name:str # e.g. 'float32'
|
| dict_factory_name: str # e.g. 'NumpyArraySkimFactory'
| zone_system: str # str (ONE_ZONE, TWO_ZONE, or THREE_ZONE)
| skim_time_periods = None # list of str e.g. ['AM', 'MD', 'PM']
|
| skims_info: dict # dict of SkimInfo keyed by skim_tag
| skim_buffers: dict # when multiprocessing, dict of multiprocessing.Array buffers keyed by skim_tag
| skim_dicts: dice # dict of SkimDict keyed by skim_tag
|
| # TWO_ZONE and THREE_ZONE
| maz_taz_df: pandas.DataFrame # DataFrame with two columns, MAZ and TAZ, mapping MAZ to containing TAZ
| maz_to_maz_df: pandas.DataFrame # maz_to_maz attributes for MazSkimDict sparse skims
| # indexed by synthetic omaz/dmaz index for faster get_mazpairs lookup)
| maz_ceiling: int # max maz_id + 1 (to compute synthetic omaz/dmaz index by get_mazpairs)
| max_blend_distance: dict # dict of int maz_to_maz max_blend_distance values keyed by skim_tag
|
| # THREE_ZONE only
| tap_df: pandas.DataFrame # taps data frame
| tap_lines_df: pandas.DataFrame # if specified in settings, list of transit lines served, indexed by TAP
| # used to prune maz_to_tap_dfs to drop more distant TAPS with redundant service
| # since a TAP can serve multiple lines, tap_lines_df TAP index is not unique
| maz_to_tap_dfs: dict # dict of maz_to_tap DataFrames indexed by access mode (e.g. 'walk', 'drive')
| # maz_to_tap dfs have OMAZ and DMAZ columns plus additional attribute columns
| tap_tap_uid: TapTapUidCalculator
"""

def __init__(self, los_settings_file_name=LOS_SETTINGS_FILE_NAME):
Expand Down Expand Up @@ -418,6 +416,7 @@ def omx_file_names(self, skim_tag):
def multiprocess(self):
"""
return True if this is a multiprocessing run (even if it is a main or single-process subprocess)
Returns
-------
bool
Expand Down
12 changes: 9 additions & 3 deletions activitysim/core/pathbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

def compute_utilities(network_los, model_settings, choosers, model_constants,
trace_label, trace=False, trace_column_names=None):

"""
Compute utilities
"""
with chunk.chunk_log(f'tvpb compute_utilities'):
trace_label = tracing.extend_trace_label(trace_label, 'compute_utils')

Expand Down Expand Up @@ -80,7 +82,9 @@ def compute_utilities(network_los, model_settings, choosers, model_constants,


class TransitVirtualPathBuilder(object):

"""
Transit virtual path builder for three zone systems
"""
def __init__(self, network_los):

self.network_los = network_los
Expand Down Expand Up @@ -782,7 +786,9 @@ def wrap_logsum(self, orig_key, dest_key, tod_key, segment_key,


class TransitVirtualPathLogsumWrapper(object):

"""
Transit virtual path builder logsum wrapper for three zone systems
"""
def __init__(self, pathbuilder, orig_key, dest_key, tod_key, segment_key,
cache_choices, trace_label, tag):

Expand Down
11 changes: 7 additions & 4 deletions activitysim/core/pathbuilder_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def memo(tag, console=False, disable_gc=True):


class TVPBCache(object):
"""
Transit virtual path builder cache for three zone systems
"""
def __init__(self, network_los, uid_calculator, cache_tag):

# lightweight until opened
Expand Down Expand Up @@ -262,9 +265,7 @@ def load_data_to_buffer(self, data_buffer):
def get_data_and_lock_from_buffers(self):
"""
return shared data buffer previously allocated by allocate_data_buffer and injected mp_tasks.run_simulation
Returns
-------
either multiprocessing.Array and lock or multiprocessing.RawArray and None according to RAWARRAY
Returns either multiprocessing.Array and lock or multiprocessing.RawArray and None according to RAWARRAY
"""
data_buffers = inject.get_injectable('data_buffers', None)
assert self.cache_tag in data_buffers # internal error
Expand All @@ -281,7 +282,9 @@ def get_data_and_lock_from_buffers(self):


class TapTapUidCalculator(object):

"""
Transit virtual path builder TAP to TAP unique ID calculator for three zone systems
"""
def __init__(self, network_los):

self.network_los = network_los
Expand Down
2 changes: 1 addition & 1 deletion activitysim/examples/example_mtc/configs/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ want_dest_choice_sample_tables: False
# trace household id; comment out or leave empty for no trace
# households with all tour types
# [ 728370 1234067 1402924 1594625 1595333 1747572 1896849 1931818 2222690 2344951 2677154]
#trace_hh_id: 2223759
trace_hh_id: 2223759

# trace origin, destination in accessibility calculation; comment out or leave empty for no trace
# trace_od: [5, 11]
Expand Down
6 changes: 3 additions & 3 deletions activitysim/examples/example_mtc/configs_mp/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ mem_tick: 30
use_shadow_pricing: False

# households_sample_size: 2000
chunk_size: 0
num_processes: 24
#chunk_size: 0
num_processes: 2

# - -------------------------

Expand All @@ -36,7 +36,7 @@ want_dest_choice_sample_tables: False
#write_skim_cache: True

# - tracing
trace_hh_id:
#trace_hh_id:
trace_od:

# to resume after last successful checkpoint, specify resume_after: _
Expand Down
Loading

0 comments on commit 9db97df

Please sign in to comment.