Skip to content

Commit e14a1f9

Browse files
committed
refactor uncongested travel time calculation
1 parent b98f99a commit e14a1f9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Scripts/assignment/assignment_period.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict:
160160
raise ValueError("Iteration number not valid")
161161

162162
mtxs = {imp_type: self._get_matrices(imp_type, iteration=="last")
163-
for imp_type in ("time", "cost", "dist", "congest_time")}
163+
for imp_type in ("time", "cost", "dist")}
164164
# fix the emme path analysis results
165165
# (dist and cost are zero if path not found but we want it to
166166
# be the default value 999999)
@@ -483,6 +483,9 @@ def _get_matrices(self,
483483
matrices[ass_class] = mtx
484484
if not (param.always_congested or is_last_iteration):
485485
matrices["transit_leisure"] = matrices["transit_work"]
486+
if mtx_type == "time" and param.always_congested:
487+
matrices["transit_leisure_uncongested"] = matrices["transit_leisure"] - self._get_matrix("transit_leisure", "congest_time")
488+
matrices["transit_work_uncongested"] = matrices["transit_work"] - self._get_matrix("transit_work", "congest_time")
486489
return matrices
487490

488491
def _get_matrix(self,
@@ -830,7 +833,7 @@ def _assign_congested_transit(self):
830833
stopping_criteria=param.trass_stop,
831834
log_worksheets=False, scenario=self.emme_scenario,
832835
save_strategies=True)
833-
# save uncongested results for both both classes
836+
# save congested travel times for both classes
834837
for tc in specs:
835838
self.emme_project.strategy_analysis(
836839
specs[tc].strategy_analysis_spec, scenario=self.emme_scenario,

Scripts/assignment/mock_assignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def assign(self,
9191
mtx[ass_class] = matrices[ass_class]
9292
log.info("Saved demand matrices for " + str(self.name))
9393
mtxs = {mtx_type: self._get_matrices(mtx_type)
94-
for mtx_type in ("time", "cost", "dist", "congest_time")}
94+
for mtx_type in ("time", "cost", "dist")}
9595
for ass_cl in ("transit_work", "transit_leisure"):
9696
mtxs["time"][ass_cl] = mtxs["time"]["transit_uncongested"]
9797
if iteration != "last":

Scripts/modelsystem.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ 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" 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-
impedance[tp].pop("congest_time")
325+
if iteration=="last" and param.always_congested:
329326
self._save_to_omx(impedance[tp], tp)
330327
elif iteration=="last":
331328
impedance[tp]["time"]["transit_uncongested"] = previous_iter_impedance[tp]["time"]["transit_work"]

0 commit comments

Comments
 (0)