Skip to content

Commit 3d4433f

Browse files
authored
finish removing 3 zone (#1072)
1 parent 90c8290 commit 3d4433f

5 files changed

Lines changed: 42 additions & 120 deletions

File tree

activitysim/abm/models/trip_matrices.py

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class MatrixTableSettings(PydanticReadable):
2626
class MatrixSettings(PydanticReadable):
2727
file_name: Path
2828
tables: list[MatrixTableSettings] = []
29-
is_tap: bool = False
3029

3130

3231
class WriteTripMatricesSettings(PydanticReadable):
@@ -62,9 +61,7 @@ def write_trip_matrices(
6261
then aggregates trip counts and writes OD matrices to OMX. Save annotated
6362
trips table to pipeline if desired.
6463
65-
Writes taz trip tables for one and two zone system. Add ``is_tap:True`` to
66-
the settings file to identify an output matrix as tap level trips as opposed
67-
to taz level trips.
64+
Writes taz trip tables for one and two zone system.
6865
6966
For one zone system, uses the land use table for the set of possible tazs.
7067
For two zone system, uses the taz skim zone names for the set of possible
@@ -351,7 +348,6 @@ def write_matrices(
351348
orig_index,
352349
dest_index,
353350
model_settings: WriteTripMatricesSettings,
354-
is_tap=False,
355351
):
356352
"""
357353
Write aggregated trips to OMX format.
@@ -371,42 +367,40 @@ def write_matrices(
371367
logger.error("Missing MATRICES setting in write_trip_matrices.yaml")
372368

373369
for matrix in matrix_settings:
374-
matrix_is_tap = matrix.is_tap
375-
376-
if matrix_is_tap == is_tap: # only write tap matrices to tap matrix files
377-
filename = str(matrix.file_name)
378-
filepath = state.get_output_file_path(filename)
379-
logger.info("opening %s" % filepath)
380-
file = omx.open_file(str(filepath), "w") # possibly overwrite existing file
381-
table_settings = matrix.tables
382-
383-
for table in table_settings:
384-
table_name = table.name
385-
col = table.data_field
386-
387-
if col not in aggregate_trips:
388-
logger.error(f"missing {col} column in aggregate_trips DataFrame")
389-
return
390-
391-
hh_weight_col = model_settings.HH_EXPANSION_WEIGHT_COL
392-
if hh_weight_col:
393-
aggregate_trips[col] = (
394-
aggregate_trips[col] / aggregate_trips[hh_weight_col]
395-
)
396-
397-
data = np.zeros((len(zone_index), len(zone_index)))
398-
data[orig_index, dest_index] = aggregate_trips[col]
399-
logger.debug(
400-
"writing %s sum %0.2f" % (table_name, aggregate_trips[col].sum())
370+
371+
filename = str(matrix.file_name)
372+
filepath = state.get_output_file_path(filename)
373+
logger.info("opening %s" % filepath)
374+
file = omx.open_file(str(filepath), "w") # possibly overwrite existing file
375+
table_settings = matrix.tables
376+
377+
for table in table_settings:
378+
table_name = table.name
379+
col = table.data_field
380+
381+
if col not in aggregate_trips:
382+
logger.error(f"missing {col} column in aggregate_trips DataFrame")
383+
return
384+
385+
hh_weight_col = model_settings.HH_EXPANSION_WEIGHT_COL
386+
if hh_weight_col:
387+
aggregate_trips[col] = (
388+
aggregate_trips[col] / aggregate_trips[hh_weight_col]
401389
)
402-
file[table_name] = data # write to file
403390

404-
# include the index-to-zone map in the file
405-
logger.info(
406-
"adding %s mapping for %s zones to %s"
407-
% (zone_index.name, zone_index.size, filename)
391+
data = np.zeros((len(zone_index), len(zone_index)))
392+
data[orig_index, dest_index] = aggregate_trips[col]
393+
logger.debug(
394+
"writing %s sum %0.2f" % (table_name, aggregate_trips[col].sum())
408395
)
409-
file.create_mapping(zone_index.name, zone_index.to_numpy())
396+
file[table_name] = data # write to file
397+
398+
# include the index-to-zone map in the file
399+
logger.info(
400+
"adding %s mapping for %s zones to %s"
401+
% (zone_index.name, zone_index.size, filename)
402+
)
403+
file.create_mapping(zone_index.name, zone_index.to_numpy())
410404

411-
logger.info("closing %s" % filepath)
412-
file.close()
405+
logger.info("closing %s" % filepath)
406+
file.close()

activitysim/examples/placeholder_multiple_zone/scripts/two_zone_example_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Transform the TM1 TAZ-based model 25 zone inputs to a two-zone (MAZ and TAZ) set of inputs for software development.
44
#
55
# The 25 zones are downtown San Francisco and they are converted to 25 MAZs.
6-
# MAZs 1,2,3,4 are small and adjacent and assigned TAZ 2 and TAP 10002.
7-
# MAZs 13,14,15 are small and adjacent and as signed TAZ 14 and TAP 10014.
6+
# MAZs 1,2,3,4 are small and adjacent and assigned TAZ 2.
7+
# MAZs 13,14,15 are small and adjacent and as signed TAZ 14.
88
# TAZs 1,3,4,13,15 are removed from the final data set.
99
#
1010
# This script should work for the full TM1 example as well.

activitysim/examples/placeholder_multiple_zone/two_zone_example_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Transform the TM1 TAZ-based model 25 zone inputs to a two-zone (MAZ and TAZ) set of inputs for software development.
44
#
55
# The 25 zones are downtown San Francisco and they are converted to 25 MAZs.
6-
# MAZs 1,2,3,4 are small and adjacent and assigned TAZ 2 and TAP 10002.
7-
# MAZs 13,14,15 are small and adjacent and as signed TAZ 14 and TAP 10014.
6+
# MAZs 1,2,3,4 are small and adjacent and assigned TAZ 2.
7+
# MAZs 13,14,15 are small and adjacent and as signed TAZ 14.
88
# TAZs 1,3,4,13,15 are removed from the final data set.
99
#
1010
# This script should work for the full TM1 example as well.

docs/core.rst

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -354,50 +354,6 @@ API
354354
.. automodule:: activitysim.core.timetable
355355
:members:
356356

357-
.. _transit_virtual_path_builder:
358-
359-
Transit Virtual Path Builder
360-
----------------------------
361-
362-
Transit virtual path builder (TVPB) for three zone system (see :ref:`multiple_zone_systems`) transit path utility calculations.
363-
TAP to TAP skims and walk access and egress times between MAZs and TAPs are input to the
364-
demand model. ActivitySim then assembles the total transit path utility based on the user specified TVPB
365-
expression files for the respective components:
366-
367-
* from MAZ to first boarding TAP +
368-
* from first boarding to final alighting TAP +
369-
* from alighting TAP to destination MAZ
370-
371-
This assembling is done via the TVPB, which considers all the possible combinations of nearby boarding and alighting TAPs for each origin
372-
destination MAZ pair and selects the user defined N best paths to represent the transit mode. After selecting N best paths, the logsum across
373-
N best paths is calculated and exposed to the mode choice models and a random number is drawn and a path is chosen. The boarding TAP,
374-
alighting TAP, and TAP to TAP skim set for the chosen path is saved to the chooser table.
375-
376-
The initialize TVPB submodel (see :ref:`initialize_los`) pre-computes TAP to TAP total utilities for the user defined attribute_segments,
377-
which are typically demographic segment (for example household income bin), time-of-day, and access/egress mode. This submodel can be
378-
run in both single process and multiprocess mode, with single process excellent for development/debugging and multiprocess excellent
379-
for application. ActivitySim saves the pre-calculated TAP to TAP total utilities to a memory mapped cache file for reuse by downstream models
380-
such as tour mode choice. In tour mode choice, the pre-computed TAP to TAP total utilities for the attribute_segment, along with the
381-
access and egress impedances, are used to evaluate the best N TAP pairs for each origin MAZ destination MAZ pair being evaluated.
382-
Assembling the total transit path impedance and then picking the best N is quick since it is done in a de-duplicated manner within
383-
each chunk of multiprocessed choosers.
384-
385-
A model with TVPB can take considerably longer to run than a traditional TAZ based model since it does an order of magnitude more
386-
calculations. Thus, it is important to be mindful of your approach to your network model as well, especially the number of TAPs
387-
accessible to each MAZ, which is the key determinant of runtime.
388-
389-
API
390-
~~~
391-
392-
.. automodule:: activitysim.core.pathbuilder
393-
:members:
394-
395-
396-
Cache API
397-
~~~~~~~~~
398-
399-
.. automodule:: activitysim.core.pathbuilder_cache
400-
:members:
401357

402358
.. _visualization:
403359

docs/users-guide/model_anatomy.rst

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ indicators (e.g. skims), the model uses different spatial resolutions for differ
5252
modeling burden and model runtimes. The typical multiple zone system setup is a TAZ zone system for auto travel, a MAZ zone
5353
system for non-motorized travel, and optionally a transit access points (TAPs) zone system for transit.
5454

55-
The three versions of multiple zone systems are one-zone, two-zone, and three-zone.
55+
The two versions of zone systems are one-zone and two-zone.
5656

5757
* **One-zone**: This version is based on TM1 and supports only TAZs. All origins and
5858
destinations are represented at the TAZ level, and all skims including auto, transit,
@@ -65,45 +65,17 @@ The three versions of multiple zone systems are one-zone, two-zone, and three-zo
6565
walk access and egress times with times specified in the MAZ file by transit mode.
6666
Careful pre-calculation of the assumed transit walk access and egress time by MAZ
6767
and transit mode is required depending on the network scenario.
68-
* **Three-zone**: This version is based on the SANDAG generation of CT-RAMP models.
69-
Origins and destinations are represented at the MAZ level. Impedance for walk or
70-
bike all-the-way from the origin to the destination can be specified at the MAZ
71-
level for close together origins and destinations, and at the TAZ level for further
72-
origins and destinations, just like the two-zone system. TAZs are used for auto
73-
times and costs. The difference between this system and the two-zone system is that
74-
transit times and costs are represented between Transit Access Points (TAPs), which
75-
are essentially dummy zones that represent transit stops or clusters of stops.
76-
Transit skims are built between TAPs, since there are typically too many MAZs to
77-
build skims between them. Often multiple sets of TAP to TAP skims (local bus only,
78-
all modes, etc.) are created and input to the demand model for consideration. Walk
79-
access and egress times are also calculated between the MAZ and the TAP, and total
80-
transit path utilities are assembled from their respective components - from MAZ to
81-
first boarding TAP, from first boarding to final alighting TAP, and from alighting
82-
TAP to destination MAZ.
8368

8469
.. caution::
85-
The ActivitySim consortium is moving away from the three-zone approach, in favor of
86-
to the one- or two-zone approaches. The three-zone system has been removed as of version 1.5.2.
70+
Historically, there was also a three-zone option. The three-zone system has been
71+
removed as of version 1.5.2.
8772

8873
Regions that have an interest in more precise transit and non-motorized forecasts
8974
may wish to adopt the two-zone approach, while other regions may adopt the one or two-zone approach. The
9075
microzone version requires coding households and land use at the microzone level.
9176
Typically an all-streets network is used for representation of non-motorized impedances.
9277
This requires a routable all-streets network, with centroids and connectors for
93-
microzones. If the three-zone system is adopted, procedures need to be developed to
94-
code TAPs from transit stops and populate the all-street network with TAP centroids
95-
and centroid connectors. A model with transit virtual path building takes longer to
96-
run than a traditional TAZ only model, but it provides a much richer framework for
97-
transit modeling.
98-
99-
.. note::
100-
The two and three zone system test examples are simple test examples developed from the TM1 example. To develop the two zone system
101-
example, TM1 TAZs were labeled MAZs, each MAZ was assigned a TAZ, and MAZ to MAZ impedance files were created from the
102-
TAZ to TAZ impedances. To develop the three zone example system example, the TM1 TAZ model was further transformed
103-
so select TAZs also became TAPs and TAP to TAP skims and MAZ to TAP impedances files were created. While sufficient for
104-
initial development, these examples were insufficient for validation and performance testing of the new software. As a result,
105-
the :ref:`prototype_marin` example was created.
106-
78+
microzones.
10779

10880
.. _omx_skims :
10981

0 commit comments

Comments
 (0)