Skip to content

MaxDivSolverBuilder

MaxDivSolverBuilder

MaxDivSolverBuilder(problem: MaxDivProblem)

Builder for configuring and creating MaxDivSolver instances.

Provides a fluent API for setting up initialization and optimization strategies, diversity tie-breakers, random seed, and solver presets. The simplest usage is to call with_preset with a time budget, then build.

Parameters:

Name Type Description Default
problem MaxDivProblem

The MaxDivProblem to solve.

required

with_diversity_tie_breakers

with_diversity_tie_breakers(
    diversity_tie_breakers: list[DiversityMetric],
) -> Self

Set custom diversity tie-breaker metrics, overriding the defaults.

with_default_diversity_tie_breakers

with_default_diversity_tie_breakers() -> Self

Reset to automatically chosen tie-breakers based on the main diversity metric.

set_initialization_strategy

set_initialization_strategy(init_strategy: InitializationStrategy) -> Self

Set the initialization strategy for the first solver step.

add_solver_step

add_solver_step(solver_step: OptimizationStep) -> Self

Append an optimization step to the solver pipeline.

add_solver_steps

add_solver_steps(solver_steps: list[OptimizationStep]) -> Self

Append multiple optimization steps to the solver pipeline.

with_seed

with_seed(seed: int) -> Self

Set the random seed for reproducibility (default: 42).

with_preset

with_preset(
    target_duration: TargetDuration, preset: SolverPreset = DEFAULT
) -> Self

Configure the builder with specified preset settings (overriding any previous settings): - Appropriate initialization strategy (most accurate strategy+settings taking est. <5% of total time) - Appropriate optimization strategy - Default diversity tie-breakers

Please make sure to set diversity metric prior to calling this method, as it influences the choices.

Parameters:

Name Type Description Default
target_duration TargetDuration

Target duration for the init+optim phases (either in time or iterations). --> rule of thumb for #iterations : 10-100x 'k' should be a good starting point.

required
preset SolverPreset

Preset to use (default: SolverPreset.DEFAULT)

DEFAULT