Skip to content

Commit 0858a5b

Browse files
committed
Save uncongested travel time matrices to Results when using congested transit assignment every iteration
1 parent 2eb5906 commit 0858a5b

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

Scripts/assignment/assignment_period.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict:
161161
raise ValueError("Iteration number not valid")
162162

163163
mtxs = {imp_type: self._get_matrices(imp_type, iteration=="last")
164-
for imp_type in ("time", "cost", "dist")}
164+
for imp_type in ("time", "cost", "dist", "congest_time")}
165165
# fix the emme path analysis results
166166
# (dist and cost are zero if path not found but we want it to
167167
# be the default value 999999)
@@ -831,6 +831,11 @@ def _assign_congested_transit(self):
831831
stopping_criteria=param.trass_stop,
832832
log_worksheets=False, scenario=self.emme_scenario,
833833
save_strategies=True)
834+
# save uncongested results for both both classes
835+
for tc in specs:
836+
self.emme_project.strategy_analysis(
837+
specs[tc].strategy_analysis_spec, scenario=self.emme_scenario,
838+
class_name=tc)
834839
# save results for both classes
835840
for tc in specs:
836841
self.emme_project.matrix_results(

Scripts/assignment/datatypes/transit.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ def __init__(self,
9090
"distance": emme_matrices["dist"],
9191
},
9292
}
93+
self.strategy_analysis_spec = {
94+
"type": "EXTENDED_TRANSIT_STRATEGY_ANALYSIS",
95+
"trip_components": {
96+
"boarding": None,
97+
"in_vehicle": "@ccost",
98+
"alighting": None,
99+
"aux_transit": None,
100+
},
101+
"sub_path_combination_operator": "+",
102+
"sub_strategy_combination_operator": "average",
103+
"selected_demand_and_transit_volumes": {
104+
"sub_strategies_to_retain": "ALL",
105+
"selection_threshold": {
106+
"lower": -999999,
107+
"upper": 999999
108+
}
109+
},
110+
"analyzed_demand": None,
111+
"constraint": None,
112+
"results": {
113+
"strategy_values": emme_matrices["congest_time"],
114+
"selected_demand": None,
115+
"transit_volumes": None,
116+
"aux_transit_volumes": None,
117+
"total_boardings": None,
118+
"total_alightings": None
119+
}
120+
}
93121
if count_zone_boardings:
94122
jlevel1 = JourneyLevel(
95123
headway_attribute, boarded=False, count_zone_boardings=True)

Scripts/assignment/emme_bindings/emme_project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def __init__(self,
6666
"inro.emme.transit_assignment.extended.network_results")
6767
self.create_extra_attribute = self.modeller.tool(
6868
"inro.emme.data.extra_attribute.create_extra_attribute")
69+
self.strategy_analysis = self.modeller.tool(
70+
"inro.emme.transit_assignment.extended.strategy_based_analysis")
6971

7072
def write(self, message: str):
7173
"""Write to logbook."""

Scripts/modelsystem.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ def run_iteration(self, previous_iter_impedance, iteration=None):
322322
impedance[tp] = ap.assign(self.dtm.demand[tp], iteration)
323323
if tp == "aht":
324324
self._update_ratios(impedance[tp], tp)
325-
if iteration=="last": # TODO: Get uncongested time from assignment results
326-
log.warn('TODO: Get uncongested transit time from the assignment results')
325+
if iteration=="last" and param.always_congested:
326+
impedance[tp]["time"]["transit_uncongested_work"] = impedance[tp]["time"]["transit_work"] - impedance[tp]["congest_time"]["transit_work"]
327+
impedance[tp]["time"]["transit_uncongested_leisure"] = impedance[tp]["time"]["transit_leisure"] - impedance[tp]["congest_time"]["transit_leisure"]
328+
self._save_to_omx(impedance[tp], tp)
329+
elif iteration=="last":
327330
impedance[tp]["time"]["transit_uncongested"] = previous_iter_impedance[tp]["time"]["transit_work"]
328331
self._save_to_omx(impedance[tp], tp)
329332
if iteration=="last":

Scripts/parameters/assignment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ def calc_segment_cost(transit_volume, line_capacity, segment):
464464
emme_matrices = {
465465
"car_work": ("demand", "time", "dist", "cost", "gen_cost"),
466466
"car_leisure": ("demand", "time", "dist", "cost", "gen_cost"),
467-
"transit_work": ("demand", "time", "dist", "cost"),
468-
"transit_leisure": ("demand", "time", "dist", "cost"),
467+
"transit_work": ("demand", "time", "dist", "cost", "congest_time"),
468+
"transit_leisure": ("demand", "time", "dist", "cost", "congest_time"),
469469
"bike": ("demand", "time", "dist"),
470470
"walk": ("time", "dist"),
471471
"trailer_truck": ("demand", "time", "dist", "cost", "gen_cost"),

0 commit comments

Comments
 (0)