Skip to content

Restarts

Restart utilities for distribution-based Evolution Strategies.

A restart controller decides after each generation whether a strategy has converged and, if so, reinitializes it while keeping the best solution found so far. Three controllers are provided:

  • SimpleRestart restarts with a fixed population size.
  • IPOPRestart increases the population size after every restart.
  • BIPOPRestart interleaves restarts with small and large population sizes.

Controllers are called from the Python loop around ask and tell. IPOPRestart and BIPOPRestart return a rebuilt strategy, because a different population size changes array shapes.

Restart conditions such as spread_cond share the signature (population, fitness, state, params, restart_state, restart_params) -> bool and are passed to a controller as stop_criteria.

RestartState

State of a restart controller.

Attributes:

  • restart_counter (int) –

    Number of restarts performed so far.

RestartParams

Hyperparameters of the restart controllers and restart conditions.

Attributes:

  • min_num_gens (int) –

    Minimum number of generations a run must complete before it can be restarted.

  • min_fitness_spread (float) –

    Threshold of spread_cond.

  • copy_mean (bool) –

    If True, a restarted run starts from the mean of the previous run. Otherwise it starts from the solution of the strategy.

  • generation_threshold (int) –

    Threshold of generation_cond.

  • tol_x (float) –

    Lower tolerance on the step size, used by cma_cond.

  • tol_x_up (float) –

    Upper tolerance on the step size, used by cma_cond.

  • tol_condition_C (float) –

    Maximum condition number of the covariance matrix, used by cma_cond.

  • tol (float) –

    Relative tolerance of fitness_std_cond.

  • atol (float) –

    Absolute tolerance of fitness_std_cond.

FitnessStdRestartParams

Bases: RestartParams

Hyperparameters for restarts based on fitness_std_cond.

IPOPRestartState

Bases: RestartState

State of the IPOPRestart controller.

IPOPRestartParams

Bases: RestartParams

Hyperparameters of the IPOPRestart controller.

Extends RestartParams.

Attributes:

  • min_num_gens (int) –

    Minimum number of generations a run must complete before it can be restarted.

  • population_size_multiplier (int) –

    Factor by which the population size grows at every restart.

BIPOPRestartState

Bases: RestartState

State of the BIPOPRestart controller.

BIPOPRestartParams

Bases: RestartParams

Hyperparameters of the BIPOPRestart controller.

Extends RestartParams.

Attributes:

  • min_num_gens (int) –

    Minimum number of generations a run must complete before it can be restarted.

  • population_size_multiplier (int) –

    Factor by which the large population size grows at every large restart.

RestartController

RestartController(stop_criteria: Sequence[RestartCondition] = (spread_cond,), restart_params: RestartParams | None = None)

Evaluate stop criteria for a single-distribution strategy.

Base class of the restart controllers. Batched strategies such as the Stein Variational Evolution Strategies are not supported.

Parameters:

  • stop_criteria (Sequence[RestartCondition], default: (spread_cond,) ) –

    Restart conditions. A restart is triggered when any of them is met.

  • restart_params (RestartParams | None, default: None ) –

    Hyperparameters of the controller and its conditions. Defaults to RestartParams().

should_restart

should_restart(population: Population, fitness: Fitness, state: State, strategy_params: Params, restart_state: RestartState) -> jax.Array

Return whether a completed generation should trigger a restart.

Call this after tell. A restart is triggered if the run has completed at least min_num_gens generations and any stop criterion is met.

Parameters:

  • population (Population) –

    Population evaluated in this generation.

  • fitness (Fitness) –

    Fitness of the population.

  • state (State) –

    Strategy state returned by tell.

  • strategy_params (Params) –

    Strategy hyperparameters.

  • restart_state (RestartState) –

    Current restart state.

Returns:

  • Array –

    A boolean scalar array.

SimpleRestart

SimpleRestart(stop_criteria: Sequence[RestartCondition] = (spread_cond,), restart_params: RestartParams | None = None)

Bases: RestartController

Reinitialize a distribution-based strategy with a fixed population size.

Parameters:

  • stop_criteria (Sequence[RestartCondition], default: (spread_cond,) ) –

    Restart conditions. A restart is triggered when any of them is met.

  • restart_params (RestartParams | None, default: None ) –

    Hyperparameters of the controller and its conditions. Defaults to RestartParams().

init

init() -> RestartState

Create restart state for a new optimization run.

Returns:

restart

restart(key: Array, strategy: DistributionBasedAlgorithm, state: State, strategy_params: Params, restart_state: RestartState) -> tuple[State, RestartState]

Reinitialize a strategy while preserving its run archive.

Parameters:

  • key (Array) –

    PRNG key.

  • strategy (DistributionBasedAlgorithm) –

    Strategy to restart.

  • state (State) –

    Strategy state of the finished run.

  • strategy_params (Params) –

    Strategy hyperparameters.

  • restart_state (RestartState) –

    Current restart state.

Returns:

  • tuple[State, RestartState] –

    A tuple (state, restart_state). The new strategy state keeps the best solution and fitness of the previous run.

should_restart

should_restart(population: Population, fitness: Fitness, state: State, strategy_params: Params, restart_state: RestartState) -> jax.Array

Return whether a completed generation should trigger a restart.

Call this after tell. A restart is triggered if the run has completed at least min_num_gens generations and any stop criterion is met.

Parameters:

  • population (Population) –

    Population evaluated in this generation.

  • fitness (Fitness) –

    Fitness of the population.

  • state (State) –

    Strategy state returned by tell.

  • strategy_params (Params) –

    Strategy hyperparameters.

  • restart_state (RestartState) –

    Current restart state.

Returns:

  • Array –

    A boolean scalar array.

IPOPRestart

IPOPRestart(strategy_factory: StrategyFactory, initial_population_size: int, stop_criteria: Sequence[RestartCondition] = (spread_cond,), restart_params: IPOPRestartParams | None = None, strategy_params_factory: StrategyParamsFactory | None = None, population_size_transform: PopulationSizeTransform | None = None)

Bases: RestartController

Increase the population size after every restart.

Every restart rebuilds the strategy with the current population size multiplied by population_size_multiplier.

Parameters:

  • strategy_factory (StrategyFactory) –

    Function population_size -> strategy that builds the strategy for a given population size.

  • initial_population_size (int) –

    Population size of the initial strategy.

  • stop_criteria (Sequence[RestartCondition], default: (spread_cond,) ) –

    Restart conditions. A restart is triggered when any of them is met.

  • restart_params (IPOPRestartParams | None, default: None ) –

    Hyperparameters of the controller and its conditions. Defaults to IPOPRestartParams().

  • strategy_params_factory (StrategyParamsFactory | None, default: None ) –

    Function (strategy, previous_params) -> params that maps hyperparameters from the previous strategy to the rebuilt one. Defaults to the default hyperparameters of the rebuilt strategy.

  • population_size_transform (PopulationSizeTransform | None, default: None ) –

    Function population_size -> population_size that adapts requested sizes to strategy constraints such as even antithetic populations. Defaults to the identity.

init

init(strategy: DistributionBasedAlgorithm) -> IPOPRestartState

Create restart state for an IPOP run.

Parameters:

Returns:

restart

restart(key: Array, strategy: DistributionBasedAlgorithm, state: State, strategy_params: Params, restart_state: IPOPRestartState) -> tuple[DistributionBasedAlgorithm, Params, State, IPOPRestartState]

Rebuild a strategy with an increased population size.

Parameters:

  • key (Array) –

    PRNG key.

  • strategy (DistributionBasedAlgorithm) –

    Strategy of the finished run.

  • state (State) –

    Strategy state of the finished run.

  • strategy_params (Params) –

    Strategy hyperparameters of the finished run.

  • restart_state (IPOPRestartState) –

    Current restart state.

Returns:

should_restart

should_restart(population: Population, fitness: Fitness, state: State, strategy_params: Params, restart_state: RestartState) -> jax.Array

Return whether a completed generation should trigger a restart.

Call this after tell. A restart is triggered if the run has completed at least min_num_gens generations and any stop criterion is met.

Parameters:

  • population (Population) –

    Population evaluated in this generation.

  • fitness (Fitness) –

    Fitness of the population.

  • state (State) –

    Strategy state returned by tell.

  • strategy_params (Params) –

    Strategy hyperparameters.

  • restart_state (RestartState) –

    Current restart state.

Returns:

  • Array –

    A boolean scalar array.

BIPOPRestart

BIPOPRestart(strategy_factory: StrategyFactory, initial_population_size: int, stop_criteria: Sequence[RestartCondition] = (spread_cond,), restart_params: BIPOPRestartParams | None = None, strategy_params_factory: StrategyParamsFactory | None = None, population_size_transform: PopulationSizeTransform | None = None, small_population_params_factory: SmallPopulationParamsFactory | None = None)

Bases: RestartController

Interleave small and large population restarts by evaluation budget.

The controller tracks the number of evaluations spent in the small and the large population regime and restarts in the regime that has used fewer. A large restart multiplies the large population size by population_size_multiplier; a small restart draws a random population size no larger than the current large one.

Parameters:

  • strategy_factory (StrategyFactory) –

    Function population_size -> strategy that builds the strategy for a given population size.

  • initial_population_size (int) –

    Population size of the initial strategy.

  • stop_criteria (Sequence[RestartCondition], default: (spread_cond,) ) –

    Restart conditions. A restart is triggered when any of them is met.

  • restart_params (BIPOPRestartParams | None, default: None ) –

    Hyperparameters of the controller and its conditions. Defaults to BIPOPRestartParams().

  • strategy_params_factory (StrategyParamsFactory | None, default: None ) –

    Function (strategy, previous_params) -> params that maps hyperparameters from the previous strategy to the rebuilt one. Defaults to the default hyperparameters of the rebuilt strategy.

  • population_size_transform (PopulationSizeTransform | None, default: None ) –

    Function population_size -> population_size that adapts requested sizes to strategy constraints such as even antithetic populations. Defaults to the identity.

  • small_population_params_factory (SmallPopulationParamsFactory | None, default: None ) –

    Function (key, strategy, params, initial_std) -> params that configures small-regime restarts. The default draws a randomly reduced initial standard deviation for CMA-ES and leaves other hyperparameters unchanged.

init

init(strategy: DistributionBasedAlgorithm) -> BIPOPRestartState

Create restart state for a BIPOP run.

Parameters:

Returns:

restart

restart(key: Array, strategy: DistributionBasedAlgorithm, state: State, strategy_params: Params, restart_state: BIPOPRestartState) -> tuple[DistributionBasedAlgorithm, Params, State, BIPOPRestartState]

Rebuild a strategy using the next BIPOP population size.

Parameters:

  • key (Array) –

    PRNG key.

  • strategy (DistributionBasedAlgorithm) –

    Strategy of the finished run.

  • state (State) –

    Strategy state of the finished run.

  • strategy_params (Params) –

    Strategy hyperparameters of the finished run.

  • restart_state (BIPOPRestartState) –

    Current restart state.

Returns:

should_restart

should_restart(population: Population, fitness: Fitness, state: State, strategy_params: Params, restart_state: RestartState) -> jax.Array

Return whether a completed generation should trigger a restart.

Call this after tell. A restart is triggered if the run has completed at least min_num_gens generations and any stop criterion is met.

Parameters:

  • population (Population) –

    Population evaluated in this generation.

  • fitness (Fitness) –

    Fitness of the population.

  • state (State) –

    Strategy state returned by tell.

  • strategy_params (Params) –

    Strategy hyperparameters.

  • restart_state (RestartState) –

    Current restart state.

Returns:

  • Array –

    A boolean scalar array.

generation_cond

generation_cond(population: Population, fitness: Fitness, state: GenerationRestartState, params: Params, restart_state: RestartState, restart_params: GenerationRestartParams) -> bool

Stop once the generation counter reaches generation_threshold.

spread_cond

spread_cond(population: Population, fitness: Fitness, state: State, params: Params, restart_state: RestartState, restart_params: SpreadRestartParams) -> jax.Array

Stop if fitness max minus fitness min is below min_fitness_spread.

fitness_std_cond

fitness_std_cond(population: Population, fitness: Fitness, state: State, params: Params, restart_state: RestartState, restart_params: FitnessStdRestartParams) -> jax.Array

Stop if the fitness standard deviation is below tolerance.

The condition is met if all fitness values are finite and std(fitness) <= atol + tol * abs(mean(fitness)).

cma_cond

cma_cond(population: Population, fitness: Fitness, state: CMAESRestartState, params: Params, restart_state: RestartState, restart_params: CMAESRestartParams) -> jax.Array

Stop if a condition specific to CMA-ES is met.

The condition is met if any of the following holds:

  • The step size in every coordinate and the evolution path are below tol_x.
  • The step size along the longest principal axis exceeds tol_x_up.
  • Adding 0.2 standard deviations in some coordinate does not change the mean.
  • Adding 0.1 standard deviations along a principal axis does not change the mean.
  • The condition number of the covariance matrix exceeds tol_condition_C.

The default tolerances in RestartParams are tol_x = 1e-12, tol_x_up = 1e4 and tol_condition_C = 1e14.

amalgam_cond

amalgam_cond(population: Population, fitness: Fitness, state: AmalgamRestartState, params: Params, restart_state: RestartState, restart_params: RestartParams) -> jax.Array

Stop if the iAMaLGaM distribution multiplier c_mult is below 1e-10.