site.SiteProblem

site.SiteProblem(preferred_crs='EPSG:27700', debug_mode=True)

Facility location optimization for healthcare site planning.

A comprehensive toolkit for solving spatial optimization problems in healthcare service delivery. This class supports multiple location-allocation models including p-median, p-center, and maximal covering location problems (MCLP), with various solution strategies from exact brute-force to heuristic methods.

The class handles the complete workflow from data ingestion (demand patterns, candidate sites, travel costs) through optimization to solution evaluation, with built-in support for geographic data and spatial visualizations.

Parameters

Name Type Description Default
preferred_crs str The coordinate reference system for spatial data. All geographic inputs will be transformed to this CRS. Defaults to British National Grid. "EPSG:27700"
debug_mode bool If True, enables verbose output during optimization and data processing. True

Attributes

Name Type Description
demand_data pandas.DataFrame or geopandas.GeoDataFrame or None Patient or service demand locations with associated weights.
candidate_sites geopandas.GeoDataFrame or None Potential facility locations available for optimization.
travel_matrix pandas.DataFrame or None Cost matrix (time/distance) between demand points and candidate sites.
region_geometry_layer geopandas.GeoDataFrame or None Optional geographic boundaries for visualization (e.g., LSOA polygons).
travel_and_demand_df pandas.DataFrame or geopandas.GeoDataFrame or None Internal merged dataset combining demand and travel cost data.
total_n_sites int or None Total number of candidate facilities available for optimization.

Notes

The class implements three inheritance mixins providing different solution strategies:

  • BruteForceMixin: Exhaustive enumeration for small problems
  • GreedyMixin: Fast constructive heuristic for larger problems
  • GraspMixin: Randomized adaptive search with local optimization

Supported optimization objectives:

  • ‘simple_p_median’: Minimize total unweighted travel distance/time
  • ‘hybrid_simple_p_median’: Simple p-median with maximum distance/time constraint
  • ‘p_median’: Minimize total weighted travel distance/time
  • ‘hybrid_p_median’: P-median with maximum distance/time constraint
  • ‘p_center’: Minimize maximum travel distance/time
  • ‘mclp’: Maximize coverage within a distance/time threshold

Methods

Name Description
add_demand Add demand data to the site problem and validate its structure.
add_equity_data Add a dataframe containing equity data into your problem.
add_region_geometry_layer Add a region geodataframe to the site problem and validate its structure.
add_sites Add candidate facility sites to the problem and handle spatial alignment.
add_travel_matrix Add a travel cost matrix to the problem and handle unit conversions.
describe_models Prints a menu of available optimization strategies for healthcare.
evaluate_single_solution_single_objective Evaluate a specific set of facility sites against a single objective.
plot_region_geometry_layer Visualize the regional geometry layer, optionally overlaid with demand data.
plot_sites Generate a visualization of the candidate facility sites.
show_demand Returns a loaded demand dataframe
show_demand_format Prints the expected structure for the demand DataFrame.
show_region_geometry_layer Returns a loaded region geometry geodataframe
show_sites Returns a loaded candidate site geodataframe
show_travel_format Prints the expected structure for the travel/cost matrix DataFrame.
show_travel_matrix Returns a loaded travel or cost matrix dataframe
solve Solve the site location problem using the specified objective and strategy.
Back to top