metaheuristic_designer.strategies.EDA.cross_entropy_method module#

Cross-Entropy Method (CEM) strategy.

class CrossEntropyMethod(initializer, name='CrossEntropyMethod', rng=None, elite_amount=None, scale='calculated', **kwargs)[source]#

Bases: EDAStrategy

Cross-Entropy Method for continuous optimization.

At each generation, the best individuals are selected and the mean of a Gaussian distribution is updated to their location, optionally with a scale estimated from the data. New solutions are sampled from this distribution.

Note

This class will be refactored when the EDA interface is finalized. Smoothing (learning rate) for the mean still needs to be added.

Parameters:
initializerInitializer

Population initializer.

namestr, optional

Display name (default "CrossEntropyMethod").

rngRNGLike, optional

Random number generator.

elite_amountint or SchedulableParameter, optional

Number of best individuals used to estimate the distribution.

scaleVectorLike or "calculated", optional

Standard deviation of the Gaussian. If "calculated", it is estimated from the selected individuals.

**kwargs

Forwarded to StaticPopulation.

Attributes:
params

Access parameter values by attribute-style lookup.

population_size

Gets the amount of individuals in the population.

Parameters:
  • initializer (Initializer)

  • name (str)

  • rng (int | Generator | None)

  • elite_amount (int | SchedulableParameter | None)

  • scale (ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | str)

Methods

estimate_parameters(population)

Utilizes the samples present in the input population to estimate the parameters used by the operator.

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

estimate_parameters(population)[source]#

Utilizes the samples present in the input population to estimate the parameters used by the operator.

Return type:

Population

Parameters:
populationPopulation

Data to use for estimating parameters.

Returns:
Operator

Newly configured operator.

Parameters:

population (Population)