diff --git a/Scripts/assignment/assignment_period.py b/Scripts/assignment/assignment_period.py index 3df13a11..5145fa45 100644 --- a/Scripts/assignment/assignment_period.py +++ b/Scripts/assignment/assignment_period.py @@ -124,22 +124,22 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict: self._calc_background_traffic() self._assign_cars(param.stopping_criteria_coarse) self._calc_extra_wait_time() - self._assign_transit() + self._assign_congested_transit() if param.always_congested else self._assign_transit() elif iteration==0: self._set_car_and_transit_vdfs() if not self._separate_emme_scenarios: self._calc_background_traffic() self._assign_cars(param.stopping_criteria_coarse) self._calc_extra_wait_time() - self._assign_transit() + self._assign_congested_transit() if param.always_congested else self._assign_transit() elif iteration==1: if not self._separate_emme_scenarios: self._set_car_and_transit_vdfs() self._calc_background_traffic() self._assign_cars(param.stopping_criteria_coarse) self._calc_extra_wait_time() - self._assign_transit() - self._calc_background_traffic(include_trucks=True) + self._assign_congested_transit() + self._assign_congested_transit() if param.always_congested else self._assign_transit() elif isinstance(iteration, int) and iteration>1: if not self._separate_emme_scenarios: self._set_car_and_transit_vdfs() @@ -147,7 +147,7 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict: self._assign_cars( param.stopping_criteria_coarse, lightweight=True) self._calc_extra_wait_time() - self._assign_transit() + self._assign_congested_transit() if param.always_congested else self._assign_transit() elif iteration=="last": self._set_bike_vdfs() self._assign_bikes(self.emme_matrices["bike"]["dist"], "all") @@ -424,7 +424,7 @@ def _set_emmebank_matrices(self, tmp_mtx = { "bike": 0, } - if not is_last_iteration: + if not (param.always_congested or is_last_iteration): tmp_mtx["transit"] = 0 for mtx in matrices: mode = mtx.split('_')[0] @@ -474,7 +474,7 @@ def _get_matrices(self, matrices = {} for ass_class, mtx_types in self.emme_matrices.items(): if (mtx_type in mtx_types and - (is_last_iteration or ass_class not in last_iter_classes)): + (param.always_congested or is_last_iteration or ass_class not in last_iter_classes)): if mtx_type == "time" and ass_class in param.assignment_modes: mtx = self._extract_timecost_from_gcost(ass_class) elif mtx_type == "time" and ass_class in param.transit_classes: @@ -482,7 +482,7 @@ def _get_matrices(self, else: mtx = self._get_matrix(ass_class, mtx_type) matrices[ass_class] = mtx - if not is_last_iteration: + if not (param.always_congested or is_last_iteration): matrices["transit_leisure"] = matrices["transit_work"] return matrices diff --git a/Scripts/modelsystem.py b/Scripts/modelsystem.py index 67fcb32b..11986f9f 100644 --- a/Scripts/modelsystem.py +++ b/Scripts/modelsystem.py @@ -135,7 +135,7 @@ def _add_internal_demand(self, previous_iter_impedance, is_last_iteration): purpose_impedance = self.imptrans.transform( purpose, previous_iter_impedance) purpose.generate_tours() - if is_last_iteration: + if param.always_congested or is_last_iteration: for mode in purpose.model.dest_choice_param: self._distribute_sec_dests( purpose, mode, purpose_impedance) @@ -322,7 +322,8 @@ def run_iteration(self, previous_iter_impedance, iteration=None): impedance[tp] = ap.assign(self.dtm.demand[tp], iteration) if tp == "aht": self._update_ratios(impedance[tp], tp) - if iteration=="last": + if iteration=="last": # TODO: Get uncongested time from assignment results + log.warn('TODO: Get uncongested transit time from the assignment results') impedance[tp]["time"]["transit_uncongested"] = previous_iter_impedance[tp]["time"]["transit_work"] self._save_to_omx(impedance[tp], tp) if iteration=="last": @@ -594,7 +595,7 @@ def _add_internal_demand(self, previous_iter_impedance, is_last_iteration): elif nr_threads <= 0: nr_threads = 1 bounds = next(iter(purpose.sources)).bounds - modes = purpose.modes if is_last_iteration else ["car"] + modes = purpose.modes if param.always_congested or is_last_iteration else ["car"] for mode in modes: threads = [] for i in range(nr_threads):