DOI: 10.6084/m9.figshare.29085137.v1
title: data & code IJGIS

description: <pre># Healthcare Facilities Location-Allocation: A Bi-Level Optimization Framework<br><br>This repository provides a simulation and optimization framework for the location-allocation of healthcare facilities. Due to data sensitivity and privacy constraints, only raw input files and representative sample data are shared. These include:<br><br>- `od.xml`: a sample origin-destination trip file  <br>- `osm.net.xml`: the base SUMO network file  <br>- `od.taz.xml`: TAZ-based OD mapping  <br>- `Base_Station_to_Area_Matching.json`: spatial correspondence between mobile base stations and traffic analysis zones  <br>- `boundary_suzhou.shp`: shapefile of the study area boundary  <br>- `Pop.shp`: spatial distribution of population  <br>- `hospital.csv`: actual candidate facility locations used in the optimization  <br>- `non_colon_edgeids.csv`: File containing a list of valid edge IDs (excluding junction-based virtual edges)<br>- Partial attraction/occurrence coefficients, as defined in `compute_hospital_trip.py`  <br><br>In addition to the raw inputs, we also provide representative **intermediate and output data** for demonstration purposes:<br><br>- `origin_ok_multi.csv`: a sample processed OD matrix used for accessibility computation  <br>- `data/4/emission_004.xml`: sample carbon emission output from the SUMO simulation  <br>- `data/4/dump_004_900.xml`: SUMO network snapshot including edge-level average speeds and flow data (for MSA-based SUE equilibrium results)<br><br>The complete codebase is fully operational, and the entire simulation–evaluation–optimization pipeline is described below.<br><br>Although this study focuses on a resource allocation use case as an example, users may also refer to the placeholder interface in lines 127–128 of `Healthcare_facilities_location_allocation.py` to extend the framework to other location sets. By modifying the candidate facilities in `hospital.csv` (both in terms of number and location), and adjusting the `selected_ids`, users can control the candidate set involved in location planning.<br><br>---<br><br>## 1. Running the Full Bi-Level Optimization Pipeline<br><br>The script `Healthcare_facilities_location_allocation.py` is the main entry point to execute the full bi-level optimization process. The remaining scripts serve as supporting modules in this workflow.<br><br>### 1.1 Base Station to Traffic Zone Matching<br><br>- **Input**: `Base_Station_to_Area_Matching.json`  <br>  (Result of spatial matching between mobile base stations and traffic analysis zones)<br><br>### 1.2 Load Existing OD Data<br><br>- **Input**: Sample OD matrices (uncalibrated) located in the `data` directory  <br>  (Derived from mobile signaling data and validated against official survey reports)<br><br>### 1.3 Generate Traffic Trips Using SUMO’s od2trips<br><br>- **Input**: Calibrated OD data<br>- **Output**: Trip files for SUMO simulation<br><br>### 1.4 Perform Stochastic User Equilibrium (SUE) Assignment via MSA Algorithm<br><br>- **Scripts**:<br>  - `duaIterate.py`<br>  - `stochastic_user_equilibrium.py`<br><br>### 1.5 Extract and Convert Network Flow Dynamics<br><br>- **Input**: SUMO output files<br>- **Script**: `extract_network.py`<br>- **Output**: `.shp` files containing path speed, average travel time, etc. (only samples provided due to data protection)<br><br>### 1.6 Compute Accessibility and Equity with Multi-Modal Network (MMN-2SFCA)<br><br>- **Input**: Multi-modal network files and OD flow data<br>- **Script**: `super_network.py`<br>- **Output**: Accessibility and equity metrics under current planning solution<br><br>### 1.7 Estimate Transportation Carbon Emissions<br><br>- **Script**: `carbon_emission.py`<br>- **Input**: Simulated traffic flows from SUMO<br>- **Output**: Emission statistics under the evaluated solution<br><br>### 1.8 Solve Using NSGA-II and Retrieve Final Pareto Solutions<br><br>- **Output**:<br>  - `ndset_final_results_beds.csv` – Pareto-optimal solutions<br>  - `all_evaluated_solutions.csv` – All evaluated solutions across generations<br><br>---<br><br>## 2. Running the Static (Non-Bi-Level) Optimization Version (without bi-level)<br><br>The simplified version of `(without bi-level) Healthcare_facilities_location_allocation.py` can be executed to perform location-allocation without stochastic user equilibrium modeling. In this mode, the network is treated as **static**, as is common in most conventional location-allocation models.<br><br>This pipeline includes:<br><br>- Step 1.1: Base station matching<br>- Step 1.6: Accessibility and equity computation -`multi_objective_calculation_nobilevel.py`<br>- Step 1.8: NSGA-II optimization and Pareto set evaluation (without bi-level)<br><br>---<br><br>## 3. Visualization and Table Generation Scripts<br><br>These scripts are designed to generate final visualizations (Figure 5 to Figure 8) and summary tables (Table 2) as referenced in the main manuscript.<br><br>### 3.1 `Plot_Fig_5.py` – Generate Figure 5<br><br>- **Input**:<br>  - `data/existing_plan.shp` – Existing facility locations<br>  - `data/single_level_max_acc.shp` – Plan maximizing accessibility<br>  - `data/single_level_min_ineq.shp` – Plan minimizing inequality<br><br>### 3.2 `Plot_Fig_6 (Accessibility & Inequity).py` – Generate Figure 6 & 7<br><br>- **Input**:<br>  - `hospital_config.csv` – Facility capacity and configuration<br>  - `network_data/origin_ok_multi.csv` – Multi-modal OD network<br>- **Output**:<br>  - `output/accessibility_result.shp` – Accessibility index shapefile<br><br>### 3.3 `Extract_Table_2.py` – Generate Table 2<br><br>- **Input**:<br>  - `4/dump_004_900.xml` – SUMO XML dump containing average edge speeds<br><br>### 3.4 `Plot_Fig_7 (Emission).py` – Generate Emission Visualization (Figure 7)<br><br>- **Input**:<br>  - `output_background/osm.net.xml` – SUMO network file<br>  - `4/emission_004.xml` – Emission output file from SUMO simulation<br><br>### 3.5 `Plot_Fig_8.py` – Generate Figure 8<br><br>- **Input**:<br>  - `ndset_final_results_beds.csv` – Final Pareto set<br>  - `all_evaluated_solutions.csv` – Complete NSGA-II search space<br><br>### 3.6 -All the other Figures are presented by the QGIS software and without any code, therefore we don't share them in this markdown.<br>---<br><br>## Notes for Users<br><br>- To extend the candidate facility set, update `hospital.csv` with new coordinates and adjust the `selected_ids` list to control participation in location planning.<br>- All sample data are anonymized and used for demonstration purposes only. Due to privacy agreements, raw OD and flow data cannot be publicly released.<br>- The simulation workflow depends on [Eclipse SUMO](https://www.eclipse.dev/sumo/) – ensure your environment is correctly configured before running trip and flow simulations.<br>- The framework is implemented in **Python 3.8+**. Please install required packages as specified at the beginning of each script.<br><br>---<br><br>For further questions or collaboration inquiries, feel free to open an issue or contact the author directly.</pre>