Solve the site location problem using the specified objective and strategy.
This method validates the problem configuration, handles automatic setup of missing demand or site data, and dispatches the optimization task to the appropriate internal solver.
Parameters
Name
Type
Description
Default
p
int
The number of facilities to be located.
required
objectives
str or list of str
The optimization objective(s). Currently, only single-objective optimization is supported; if a list is provided, only the first element is used. Supported: “p_median”, “p_center”, “mclp”, etc.
"p_median"
capacitated
bool
Whether to enforce site capacity constraints. Note: Currently not implemented.
False
search_strategy
(brute - force, greedy, grasp)
The algorithm used to find the solution: - “brute-force”: Exhaustively checks all combinations (if p is small). - “greedy”: Iteratively adds the best performing site. - “grasp”: Greedy Randomized Adaptive Search Procedure.
"brute-force"
brute_force_ignore_limit
bool
(Brute Force only) If True, allows brute-force searching even if the number of combinations is extremely high.
False
show_progress
bool
If True, displays a progress bar during the optimization process.
True
brute_force_keep_best_n
(Brute Force only) The number of top or bottom results to retain during a brute-force search.
None
max_value_cutoff
float
The maximum allowable travel cost. Only applicable for hybrid objective models.
None
threshold_for_coverage
float
The distance or time threshold. Used as a hard filter for MCLP objectives or as a scoring metric for others.
None
grasp_num_solutions
int
(GRASP only) The number of high-quality solutions to generate.
5
grasp_alpha
float
(GRASP only) The selection restriction parameter (0 is fully greedy, 1 is fully random).
0.2
grasp_max_attempts
int or default
(GRASP only) Maximum iterations to find a valid solution.
"default"
grasp_min_sites_different
int
(GRASP only) Minimum number of sites that must differ between generated solutions. Useful for generating a more diverse solution pool, though you may need to increase the max_attempts at the same time.
1
grasp_local_search_chance
float
(GRASP only) The probability (0.0 to 1.0) of performing a local search to improve a found solution.
0.8
grasp_max_swap_count_local_search
int
(GRASP only) Maximum number of site swaps allowed during the local search phase.
10
random_seed
int
(GRASP only) Seed for reproducibility in randomized strategies like GRASP.
42
**kwargs
dict
Additional arguments passed to the internal solver.
{}
Returns
Name
Type
Description
SiteSolutionSet
An object containing the optimal sites, objective score, and detailed assignment data for each provided solution.
Raises
Name
Type
Description
ValueError
If capacitated is True, if the travel matrix is missing, if an unsupported objective/strategy is provided, or if max_value_cutoff is used with an incompatible objective.
Raises
Name
Type
Description
UserWarning
If multi-objective lists are provided (only the first is taken). If demand or site data is missing and must be auto-generated.
Notes
If demand_data or candidate_sites have not been explicitly added prior to calling .solve(), the method will automatically initialize them based on the travel matrix.