metaheuristic_designer.strategies.shuffled_population_strategy module#

Strategy where offspring size differs from population size (μ+λ / μ,λ style).

class ShuffledPopulationStrategy(initializer, operator=None, parent_sel=None, survivor_sel=None, offspring_size=None, shuffle_with_replacement=False, name='Variable Population Evolution', rng=None, **kwargs)[source]#

Bases: SearchStrategy

Population-based strategy with separate parent and offspring sizes.

This is the base for (μ+λ) and (μ,λ) Evolution Strategies, GAs, and similar algorithms. The number of parents selected and the number of offspring generated can be configured independently.

Parameters:
initializerInitializer

Population initializer.

operatorOperator

Perturbation operator.

parent_selParentSelection, optional

Parent selection method.

survivor_selSurvivorSelection, optional

Survivor selection method.

offspring_sizeint or SchedulableParameter, optional

Number of offspring to generate. Defaults to the initializer’s population size.

shuffle_with_replacementbool, optional

If True, shuffle the parent pool with replacement; otherwise without replacement (default False).

namestr, optional

Display name.

rngRNGLike, optional

Random number generator.

**kwargs

Forwarded to SearchStrategy.

Attributes:
initializer
params

Access parameter values by attribute-style lookup.

population_size

Gets the amount of individuals in the population.

Parameters:

Methods

extra_report()

Hook called at the end of the optimization (intended for subclasses).

extra_step_info()

Hook called after each generation (intended for subclasses).

gather_parameters()

Collect the current parameters from all sub-components.

get_params()

Return a copy of the current parameter dictionary.

get_state()

Gets the current state of the search strategy as a dictionary.

initialize(objfunc)

Initializes the optimization search strategy.

step(prev_population, objfunc)

Performs a single iteration of the algorithm on a given population.

store_kwargs([progress])

Store keyword arguments and evaluate them at the given progress.

update(progress)

Advances the state of the search by one iteration.

update_kwargs([progress])

Add or replace parameters and immediately evaluate them.

reset

step(prev_population, objfunc)[source]#

Performs a single iteration of the algorithm on a given population.

Return type:

Population

Parameters:
populationPopulation

Population of solutions in which to perform the operators.

Returns:
Population

Next population after performing all the steps in the iteration.

Parameters: