From 8cccce30d298d77f7699f40f387ebe4f7f2a475d Mon Sep 17 00:00:00 2001 From: JoeJimFlood Date: Tue, 20 Feb 2024 16:41:34 -0800 Subject: [PATCH 1/4] Updated origin adjustment to parking zone to only happen if the trip is an auto mode --- activitysim/abm/models/trip_matrices.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/activitysim/abm/models/trip_matrices.py b/activitysim/abm/models/trip_matrices.py index 2db8f8c5a..97a6361fc 100644 --- a/activitysim/abm/models/trip_matrices.py +++ b/activitysim/abm/models/trip_matrices.py @@ -51,6 +51,16 @@ def write_trip_matrices(network_los): if "parking_location" in config.setting("models"): parking_settings = config.read_model_settings("parking_location_choice.yaml") parking_taz_col_name = parking_settings["ALT_DEST_COL_NAME"] + auto_nest_name = parking_settings["AUTO_MODE_NEST"] + + # Read trip mode choice settings to get auto modes + trip_mode_choice_settings = config.read_model_settings("trip_mode_choice.yaml") + trip_mode_choice_nest = config.get_logit_mocel_settings(trip_mode_choice_settings) + for alternative in trip_mode_choice_nest["alternatives"]: + if alternative["name"] == auto_nest_name: + auto_modes = alternative["alternatives"] + break + if parking_taz_col_name in trips_df: trips_df["true_origin"] = trips_df["origin"] @@ -59,7 +69,11 @@ def write_trip_matrices(network_los): # Get origin parking zone if vehicle not parked at origin trips_df["origin_parking_zone"] = np.where( trips_df["tour_id"] == trips_df["tour_id"].shift(1), - trips_df[parking_taz_col_name].shift(1), + np.where( + trip_df["trip_mode"].apply(lambda x: x in auto_modes), + trips_df[parking_taz_col_name].shift(1), + -1 + ) -1 ) From 851319dc1019fe3d489bbc062d7fbc165c0fb6b2 Mon Sep 17 00:00:00 2001 From: JoeJimFlood Date: Tue, 20 Feb 2024 16:45:21 -0800 Subject: [PATCH 2/4] Final trips table now reports origin and destination TAZs regardless of parking TAZ --- activitysim/abm/models/trip_matrices.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/activitysim/abm/models/trip_matrices.py b/activitysim/abm/models/trip_matrices.py index 97a6361fc..7d592c4e4 100644 --- a/activitysim/abm/models/trip_matrices.py +++ b/activitysim/abm/models/trip_matrices.py @@ -246,6 +246,13 @@ def write_trip_matrices(network_los): trips_df["destination"] = trips_df["true_destination"] del trips_df["true_origin"], trips_df["true_destination"] + trips_df["otaz"] = ( + pipeline.get_table("land_use").reindex(trips_df["origin"]).TAZ.tolist() + ) + trips_df["dtaz"] = ( + pipeline.get_table("land_use").reindex(trips_df["destination"]).TAZ.tolist() + ) + def annotate_trips(trips, network_los, model_settings): """ From 5fb2b839c5712d17ed5220c7a65267dd3b073445 Mon Sep 17 00:00:00 2001 From: JoeJimFlood Date: Tue, 20 Feb 2024 16:47:37 -0800 Subject: [PATCH 3/4] Previous commit is only necessary for 2- and 3-zone systems --- activitysim/abm/models/trip_matrices.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/activitysim/abm/models/trip_matrices.py b/activitysim/abm/models/trip_matrices.py index 7d592c4e4..3e14ef61b 100644 --- a/activitysim/abm/models/trip_matrices.py +++ b/activitysim/abm/models/trip_matrices.py @@ -246,12 +246,13 @@ def write_trip_matrices(network_los): trips_df["destination"] = trips_df["true_destination"] del trips_df["true_origin"], trips_df["true_destination"] - trips_df["otaz"] = ( - pipeline.get_table("land_use").reindex(trips_df["origin"]).TAZ.tolist() - ) - trips_df["dtaz"] = ( - pipeline.get_table("land_use").reindex(trips_df["destination"]).TAZ.tolist() - ) + if network_los.zone_system == los.TWO_ZONE or network_los.zone_system == los.THREE_ZONE: + trips_df["otaz"] = ( + pipeline.get_table("land_use").reindex(trips_df["origin"]).TAZ.tolist() + ) + trips_df["dtaz"] = ( + pipeline.get_table("land_use").reindex(trips_df["destination"]).TAZ.tolist() + ) def annotate_trips(trips, network_los, model_settings): From 11a3d332120f29776f8c2f7327023086118852cc Mon Sep 17 00:00:00 2001 From: JoeJimFlood Date: Tue, 20 Feb 2024 17:24:37 -0800 Subject: [PATCH 4/4] Removed lookup of trip mode choice configs so user specifies auto modes in parking location settings --- activitysim/abm/models/trip_matrices.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/activitysim/abm/models/trip_matrices.py b/activitysim/abm/models/trip_matrices.py index 3e14ef61b..37692ed43 100644 --- a/activitysim/abm/models/trip_matrices.py +++ b/activitysim/abm/models/trip_matrices.py @@ -51,15 +51,8 @@ def write_trip_matrices(network_los): if "parking_location" in config.setting("models"): parking_settings = config.read_model_settings("parking_location_choice.yaml") parking_taz_col_name = parking_settings["ALT_DEST_COL_NAME"] - auto_nest_name = parking_settings["AUTO_MODE_NEST"] - - # Read trip mode choice settings to get auto modes - trip_mode_choice_settings = config.read_model_settings("trip_mode_choice.yaml") - trip_mode_choice_nest = config.get_logit_mocel_settings(trip_mode_choice_settings) - for alternative in trip_mode_choice_nest["alternatives"]: - if alternative["name"] == auto_nest_name: - auto_modes = alternative["alternatives"] - break + assert "AUTO_MODES" in parking_settings, "AUTO_MODES must be specified in parking location settings to properly adjust trip tables for assignment" + auto_modes = parking_settings["AUTO_MODES"] if parking_taz_col_name in trips_df: