|
15 | 15 |
|
16 | 16 |
|
17 | 17 | def main(args): |
| 18 | + # Set up filepaths |
| 19 | + base_zonedata_path: str = os.path.join(args.baseline_data_path, "2023_zonedata") |
| 20 | + base_matrices_path: str = os.path.join(args.baseline_data_path, "base_matrices") |
| 21 | + forecast_zonedata_path: str = args.forecast_data_path |
| 22 | + results_path: str = args.results_path |
| 23 | + emme_project_path: str = args.emme_path |
| 24 | + |
18 | 25 | if args.end_assignment_only: |
| 26 | + # Raise error if there is no demand matrix in results folder |
| 27 | + matrix_path = os.path.join(results_path, args.scenario_name, "Matrices") |
| 28 | + demand_matrix_path = os.path.join(results_path, args.scenario_name, "Matrices", "demand_aht.omx") |
| 29 | + if not os.path.exists(demand_matrix_path): |
| 30 | + msg = "Matrices not found for this scenario. Please uncheck the " \ |
| 31 | + + "'Aja vain loppusijoittelu' option in Helmet UI's scenario settings, " \ |
| 32 | + + f"or copy the demand matrices from base scenario to [{matrix_path}]." |
| 33 | + log.error(msg) |
| 34 | + raise FileNotFoundError(msg) |
| 35 | + # Else set iterations to 0, so that only the last iteration is run |
19 | 36 | iterations = 0 |
20 | 37 | elif args.iterations > 0: |
21 | 38 | iterations = args.iterations |
22 | 39 | else: |
23 | 40 | raise ArgumentTypeError( |
24 | 41 | "Iteration number {} not valid".format(args.iterations)) |
25 | | - base_zonedata_path: str = os.path.join(args.baseline_data_path, "2023_zonedata") |
26 | | - base_matrices_path: str = os.path.join(args.baseline_data_path, "base_matrices") |
27 | | - forecast_zonedata_path: str = args.forecast_data_path |
28 | | - results_path: str = args.results_path |
29 | | - emme_project_path: str = args.emme_path |
30 | 42 | log_extra = { |
31 | 43 | "status": { |
32 | 44 | "name": args.scenario_name, |
@@ -115,6 +127,16 @@ def main(args): |
115 | 127 | estimation_data_path) |
116 | 128 | log_extra["status"]["results"] = model.mode_share |
117 | 129 |
|
| 130 | + if args.use_fixed_transit_cost: |
| 131 | + # Raise error if there is no cost matrix in results folder |
| 132 | + cost_matrix_path = os.path.join(results_path, args.scenario_name, "Matrices", "cost_aht.omx") |
| 133 | + if not os.path.exists(cost_matrix_path): |
| 134 | + msg = "Precalculated transit cost matrix not found. " \ |
| 135 | + + "Please uncheck the 'Käytä esilaskettua joukkoliikenteen kustannusmatriisia' " \ |
| 136 | + + "option in Helmet UI's scenario settings to calculate transit cost." |
| 137 | + log.error(msg) |
| 138 | + raise FileNotFoundError(msg) |
| 139 | + |
118 | 140 | # Run traffic assignment simulation for N iterations, |
119 | 141 | # on last iteration model-system will save the results |
120 | 142 | log_extra["status"]["state"] = "preparing" |
|
0 commit comments