This repository contains a Jupyter notebook implementation of a preventive health care facility location model based on the framework in Verter and Lapierre (2002), Location of Preventive Health Care Facilities.
The notebooks use ZIP Code Tabulation Area (ZCTA) demand and coordinates to choose facility locations that maximize captured demand while enforcing:
- at most one assignment per demand point
- assignment only to open facilities
- a minimum workload threshold for each open facility
- closest-open-facility logic through an iterative cut procedure inspired by Section 4, Procedure I of the paper
MCLP_Implementation-Final_Master_File_with demand distribution-procedure1.ipynbMCLP_Implementation-Final_Master_File_with demand distribution-procedure1_optimized.ipynbPhiladelphia ZCTAs Sub Service line level_Cardiology_Medical Cardiology.csvLICENSE
This repository now includes two notebook variants:
...-procedure1.ipynb: the current iterative cut-generation implementation based on Section 4, Procedure I...-procedure1_optimized.ipynb: an optimized formulation that replaces the repeated Procedure I cut loop with the paper's equation (9) closest-facility ordering constraints
Both notebooks:
- reads weighted demand by ZCTA
- computes pairwise distances between demand points and candidate sites
- estimates participation as a linear decay function of distance
- solves a mixed-integer optimization model with OR-Tools
- iteratively adds violated closest-facility constraints
- visualizes selected sites and demand capture
These implementations are best described as practical adaptations of the paper rather than line-by-line reproductions.
Key choices in the notebooks:
x[i, j]indicates whether demand pointiis assigned to facilityjy[j]indicates whether facilityjis openedpfac[i, j]represents distance-adjusted captured demand from population centerito sitejmin_demandacts as a facility viability threshold
The notebooks currently use the OR-Tools SCIP backend by default because it is free and easy to run without a commercial solver license. If you have access to a valid Gurobi license, Gurobi is generally the preferred solver for better performance on larger mixed-integer models.
Both notebooks include several runtime-oriented changes that do not change the underlying model intent:
- binary decision variables are declared with
BoolVar - infeasible assignments outside the service radius are omitted from the model
- assignment and workload structures are stored sparsely using feasible
(i, j)pairs only - facilities that can never satisfy
min_demandeven under best-case assignment are screened out before solving - the Procedure I notebook uses precomputed site orderings to speed up closest-open-facility checks
The optimized equation (9) notebook goes further by building the closest-facility ordering directly into the model and solving a single mixed-integer program instead of repeatedly adding cuts.
These changes are especially helpful when min_demand is large.
Each notebook expects a CSV with fields including:
zctaweighted demandinternal_pt_latinternal_pt_lon
The included sample file is:
Philadelphia ZCTAs Sub Service line level_Cardiology_Medical Cardiology.csv
Install the main Python dependencies before running either notebook:
pip install ortools haversine numpy pandas matplotlib plotlyIf you want to test Gurobi separately:
pip install gurobipyYou would also need a valid Gurobi license.
- Open either notebook in Jupyter Notebook or JupyterLab.
- Confirm the CSV path points to the local dataset.
- Run the cells in order from top to bottom.
- Start with
...-procedure1.ipynbif you want the iterative Procedure I version. - Use
...-procedure1_optimized.ipynbif the Procedure I notebook converges slowly and you want the equation (9) reformulation. - Review the selected facilities, demand capture summaries, and maps.
Both notebooks produce:
- selected facility locations
- demand-to-facility assignments
- demand capture by open facility
- scatter and geographic plots
- demand capture summaries by ZCTA
- Distances are computed with haversine distance between coordinates, which is an approximation of real travel distance.
- Results depend strongly on
min_demand, the travel threshold, and the quality of the weighted demand input. - The Procedure I notebook can still take substantial time on larger instances or high minimum-demand thresholds.
- The equation (9) notebook is usually faster, but it relies on distance ordering and can require care in edge cases with tied distances.
- The notebook is intended for research and prototyping, not production deployment.
Verter, V., & Lapierre, S. D. (2002). Location of preventive health care facilities. Annals of Operations Research, 110, 123-132.