|
10 | 10 | from assignment.abstract_assignment import AssignmentModel |
11 | 11 | from assignment.emme_assignment import EmmeAssignmentModel |
12 | 12 | from assignment.mock_assignment import MockAssignmentModel |
| 13 | +from dataclasses import asdict |
13 | 14 |
|
14 | 15 | import utils.log as log |
15 | 16 | from utils.zone_interval import ArrayAggregator |
@@ -167,14 +168,15 @@ def _add_internal_demand(self, previous_iter_impedance, is_last_iteration): |
167 | 168 | purpose.calc_prob(saved_pnr_impedance[purpose.name]) |
168 | 169 | demand = purpose.calc_demand() |
169 | 170 | log.debug(f"Park and ride crowding penalty iteration {i+1} modified {modified} facilities.") |
170 | | - if modified < 1: |
| 171 | + if modified < 1: |
171 | 172 | break |
| 173 | + log.debug(f"Park and ride demand calculation completed.") |
172 | 174 |
|
173 | 175 | if purpose.dest != "source": |
174 | 176 | for mode in demand: |
175 | 177 | self.dtm.add_demand(demand[mode]) |
176 | 178 | self.travel_modes[mode] = True |
177 | | - log.info("Demand calculation completed") |
| 179 | + log.info("Demand calculation completed") |
178 | 180 |
|
179 | 181 | # possibly merge with init |
180 | 182 | def assign_base_demand(self, |
@@ -353,6 +355,7 @@ def run_iteration(self, previous_iter_impedance, iteration=None): |
353 | 355 | self._save_to_omx(impedance[tp], tp) |
354 | 356 | if iteration=="last": |
355 | 357 | self.ass_model.aggregate_results(self.resultdata) |
| 358 | + self._save_pnr_facility_info() |
356 | 359 | self._calculate_noise_areas() |
357 | 360 | self._calculate_accessibility_and_savu_zones() |
358 | 361 | self.resultdata.print_line("\nMode shares", "result_summary") |
@@ -389,6 +392,23 @@ def _save_to_omx(self, impedance, tp): |
389 | 392 | for ass_class in impedance[mtx_type]: |
390 | 393 | mtx[ass_class] = impedance[mtx_type][ass_class] |
391 | 394 |
|
| 395 | + def _save_pnr_facility_info(self): |
| 396 | + pnr_data = [] |
| 397 | + for facility in self.dm.purpose_dict['hw'].park_and_ride_model._facilities: |
| 398 | + pnr_data.append({k: str(v) for k, v in asdict(facility).items()}) |
| 399 | + |
| 400 | + pnr_results = pandas.DataFrame(pnr_data) |
| 401 | + print(pnr_results.head()) |
| 402 | + pnr_results['used_capacity'] = pnr_results['used_capacity'].astype(float).round().astype(int) |
| 403 | + pnr_results['shops'] = pnr_results['shops'].astype(float).round().astype(int) |
| 404 | + pnr_results.index = pnr_results['zone_id'] |
| 405 | + pnr_results.index.name = None |
| 406 | + pnr_results = pnr_results[['cost','shops','capacity','used_capacity','time']] |
| 407 | + print(pnr_results.head()) |
| 408 | + for col in pnr_results.columns: |
| 409 | + self.resultdata.print_data(pnr_results[col], "pnr_facilities.txt", col) |
| 410 | + |
| 411 | + |
392 | 412 | def _calculate_noise_areas(self): |
393 | 413 | noise_areas = self.ass_model.calc_noise() |
394 | 414 | self.resultdata.print_data(noise_areas, "noise_areas.txt", "area") |
|
0 commit comments