site.SiteSolutionSet

site.SiteSolutionSet(
    solution_df,
    site_problem,
    objectives,
    n_sites=None,
    ranking_metric=None,
)

Container for a set of evaluated site selection solutions.

This class stores and provides convenient access to a collection of candidate solutions from a brute-force or heuristic search, along with their associated evaluation metrics. It supports returning and plotting details of the best-performing solutions.

Parameters

Name Type Description Default
solution_df pandas.DataFrame DataFrame containing one row per evaluated solution. Typically includes: - “site_indices”: Indices of selected sites for the solution. - One or more objective/metric columns (e.g., “weighted_average”, “unweighted_average”, “90th_percentile”, etc.). The DataFrame is reset to a zero-based index upon initialisation. required
site_problem object The originating problem instance used to generate and evaluate the solutions. required
objectives str or list of str Objective(s) used to evaluate and rank the solutions (e.g., “weighted_average”, “mclp”). required
n_sites int Number of sites selected in each solution (e.g., p in a p-median or p-center problem). None
ranking_metric lokigi.multiobjective.Metric The metric the search actually ranked and pruned on. Usually the one implied by objectives, but solve(rank_on=...) can override it, in which case objectives alone no longer describes how these solutions were ordered. None

Attributes

Name Type Description
solution_df pandas.DataFrame DataFrame of evaluated solutions with metrics.
site_problem object Problem definition associated with the solutions.
objectives str or list of str Objective(s) used in evaluation.
n_sites int or None Number of sites in each solution.
ranking_metric lokigi.multiobjective.Metric or None What solution_rank is actually ordered by. Read this rather than objectives when reporting what was optimised.

Notes

Solutions are typically pre-sorted before being passed to this class (e.g., by objective value and tie-breakers). The optional sort_by argument in methods allows overriding this ordering dynamically.

The structure of solution_df is assumed to be consistent with the outputs of the optimisation or search routine that generated it.

Methods

Name Description
show_solutions Return the solution DataFrame with rounded values.
show_solutions_summary Return a stakeholder-facing view of the solution table: a handful
describe_solution_columns Print (or return) solution_df’s columns grouped by what they
return_best_combination_details Return details of the top-ranked solution(s).
return_best_combination_site_indices Return the site indices for the best-performing solution.
return_best_combination_site_names Return the site names for the best-performing solution.
site_allocation_summary Per-site summary of a chosen solution: the share of demand (or of
site_capacity_summary Per-site comparison of a chosen solution’s allocated demand against
two_step_floating_catchment Two-step floating catchment area (2SFCA) accessibility for one
plot_accessibility Map 2SFCA accessibility: a region choropleth of accessibility,
plot_n_best_combinations_bar Plot a bar chart of the top-performing site combinations.
plot_site_allocation_summary Bar chart of site_allocation_summary() for one chosen solution.
plot_site_capacity_summary Bar chart of site_capacity_summary() for one chosen solution.
plot_allocated_utilisation Map each selected site’s allocated_utilisation_ratio from
plot_best_combination Plot a map of the best-performing site combination.
plot_n_best_combinations Plot maps for the top-performing site combinations.
plot_solution_comparison Plot multiple solutions side-by-side for comparison.
plot_travel_time_distribution Plot travel time distributions for selected solutions.
check_solution_equity Summarise and optionally plot equity metrics for a selected solution.
plot_top_n_solution_equity Plot equity summaries for the top N solutions in a grid of subplots.
plot_combination_by_equity Plot maps of travel cost for each equity group, for one solution.
plot_simple_pareto_front_pairs Plot a Pareto front for two selected solution metrics.
plot_all_metric_pareto_front_pairs Plot Pareto fronts for all pairs of solution metrics.
compute_pareto_front Flag which solutions in df are Pareto-optimal across metrics.
pareto_summary Return just the Pareto-optimal solutions, with metric columns
plot_pareto_facets Plot each non-dominated (Pareto-optimal) solution on its own subplot facet.
Back to top