metaheuristic_designer.strategies.EDA package¶
Submodules¶
metaheuristic_designer.strategies.EDA.PBIL module¶
Population-Based Incremental Learning (PBIL) strategies.
- class BernoulliPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, p=None, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for binary vectors using a Bernoulli distribution.
The probability vector p is updated each generation with a learning rate and optional Gaussian noise, then a new population is sampled.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BernoulliPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (array-like, optional) – Initial probability vector. Defaults to uniform over [0,1].
lr (float, optional) – Learning rate for updating p (default 1e-3).
noise (float, optional) – Standard deviation of Gaussian noise added to p (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class BinomialPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, p=0.5, n=None, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for discrete vectors using a Binomial distribution.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BinomialPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial success probability (default 0.5).
n (int or array-like) – Number of trials. Must be provided; there is no default.
lr (float, optional) – Learning rate (default 1e-3).
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class GaussianPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'GaussianPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, loc=None, scale=1, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for continuous vectors using a Gaussian distribution.
The location vector loc is updated each generation with a learning rate and optional Gaussian noise, then a new population is sampled.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"GaussianPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
loc (array-like, optional) – Initial mean vector (default
None; the operator uses a fallback).scale (float or array-like, optional) – Standard deviation (default 1).
lr (float, optional) – Learning rate (default 1e-3).
noise (float, optional) – Gaussian noise standard deviation added to loc (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
metaheuristic_designer.strategies.EDA.UMDA module¶
Univariate Marginal Distribution Algorithm (UMDA) strategies.
- class BernoulliUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliUMDA', offspring_size: int | SchedulableParameter | None = None, random_state=None, p: number | float | int | SchedulableParameter = 0.5, noise: number | float | int | SchedulableParameter = 0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for binary vectors using a Bernoulli distribution.
The probability vector is estimated from the selected parents (no smoothing). Gaussian noise can optionally be added.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BernoulliUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial probability (default 0.5).
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class BinomialUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BinomialUMDA', offspring_size: int | SchedulableParameter | None = None, random_state: int | Generator | None = None, p: number | float | int | SchedulableParameter = 0.5, n: number | float | int | SchedulableParameter | None = None, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for discrete vectors using a Binomial distribution.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BinomialUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial success probability (default 0.5).
n (int or array-like) – Number of trials. Must be provided; there is no default.
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class GaussianUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'GaussianUMDA', offspring_size: int | SchedulableParameter | None = None, random_state=None, loc: number | float | int | ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | SchedulableParameter = 0, scale: number | float | int | ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | SchedulableParameter = 1, noise: number | float | int | SchedulableParameter = 0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for continuous vectors using a Gaussian distribution.
The location vector is estimated from the selected parents. Gaussian noise can optionally be added.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"GaussianUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
loc (float or array-like, optional) – Initial mean (default 0).
scale (float or array-like, optional) – Standard deviation (default 1).
noise (float, optional) – Gaussian noise standard deviation added to loc (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
metaheuristic_designer.strategies.EDA.cross_entropy_method module¶
Cross-Entropy Method (CEM) strategy.
- class CrossEntropyMethod(initializer: Initializer, name: str = 'CrossEntropyMethod', random_state: int | Generator | None = None, elite_amount: int | SchedulableParameter | None = None, scale: ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | str = 'calculated', **kwargs)[source]¶
Bases:
StaticPopulationCross-Entropy Method for continuous optimisation.
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 finalised. Smoothing (learning rate) for the mean still needs to be added.
- Parameters:
initializer (Initializer) – Population initializer.
name (str, optional) – Display name (default
"CrossEntropyMethod").random_state (RNGLike, optional) – Random number generator.
elite_amount (int or SchedulableParameter, optional) – Number of best individuals used to estimate the distribution.
scale (VectorLike or
"calculated", optional) – Standard deviation of the Gaussian. If"calculated", it is estimated from the selected individuals.**kwargs – Forwarded to
StaticPopulation.
Module contents¶
Estimation of Distribution Algorithms (EDA) strategies.
- class BernoulliPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, p=None, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for binary vectors using a Bernoulli distribution.
The probability vector p is updated each generation with a learning rate and optional Gaussian noise, then a new population is sampled.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BernoulliPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (array-like, optional) – Initial probability vector. Defaults to uniform over [0,1].
lr (float, optional) – Learning rate for updating p (default 1e-3).
noise (float, optional) – Standard deviation of Gaussian noise added to p (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class BernoulliUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliUMDA', offspring_size: int | SchedulableParameter | None = None, random_state=None, p: number | float | int | SchedulableParameter = 0.5, noise: number | float | int | SchedulableParameter = 0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for binary vectors using a Bernoulli distribution.
The probability vector is estimated from the selected parents (no smoothing). Gaussian noise can optionally be added.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BernoulliUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial probability (default 0.5).
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class BinomialPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BernoulliPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, p=0.5, n=None, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for discrete vectors using a Binomial distribution.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BinomialPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial success probability (default 0.5).
n (int or array-like) – Number of trials. Must be provided; there is no default.
lr (float, optional) – Learning rate (default 1e-3).
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class BinomialUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'BinomialUMDA', offspring_size: int | SchedulableParameter | None = None, random_state: int | Generator | None = None, p: number | float | int | SchedulableParameter = 0.5, n: number | float | int | SchedulableParameter | None = None, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for discrete vectors using a Binomial distribution.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"BinomialUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
p (float or array-like, optional) – Initial success probability (default 0.5).
n (int or array-like) – Number of trials. Must be provided; there is no default.
noise (float, optional) – Gaussian noise standard deviation (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class CrossEntropyMethod(initializer: Initializer, name: str = 'CrossEntropyMethod', random_state: int | Generator | None = None, elite_amount: int | SchedulableParameter | None = None, scale: ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | str = 'calculated', **kwargs)[source]¶
Bases:
StaticPopulationCross-Entropy Method for continuous optimisation.
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 finalised. Smoothing (learning rate) for the mean still needs to be added.
- Parameters:
initializer (Initializer) – Population initializer.
name (str, optional) – Display name (default
"CrossEntropyMethod").random_state (RNGLike, optional) – Random number generator.
elite_amount (int or SchedulableParameter, optional) – Number of best individuals used to estimate the distribution.
scale (VectorLike or
"calculated", optional) – Standard deviation of the Gaussian. If"calculated", it is estimated from the selected individuals.**kwargs – Forwarded to
StaticPopulation.
- class GaussianPBIL(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'GaussianPBIL', offspring_size: int | SchedulableParameter | None = None, random_state=None, loc=None, scale=1, lr=0.001, noise=0, **kwargs)[source]¶
Bases:
VariablePopulationPBIL for continuous vectors using a Gaussian distribution.
The location vector loc is updated each generation with a learning rate and optional Gaussian noise, then a new population is sampled.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"GaussianPBIL").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
loc (array-like, optional) – Initial mean vector (default
None; the operator uses a fallback).scale (float or array-like, optional) – Standard deviation (default 1).
lr (float, optional) – Learning rate (default 1e-3).
noise (float, optional) – Gaussian noise standard deviation added to loc (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type:
- class GaussianUMDA(initializer: Initializer, parent_sel: ParentSelection | None = None, survivor_sel: SurvivorSelection | None = None, name: str = 'GaussianUMDA', offspring_size: int | SchedulableParameter | None = None, random_state=None, loc: number | float | int | ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | SchedulableParameter = 0, scale: number | float | int | ndarray[tuple[int], floating] | ndarray[tuple[int], integer] | ndarray[tuple[int], uint8 | bool] | SchedulableParameter = 1, noise: number | float | int | SchedulableParameter = 0, **kwargs)[source]¶
Bases:
VariablePopulationUMDA for continuous vectors using a Gaussian distribution.
The location vector is estimated from the selected parents. Gaussian noise can optionally be added.
Reference: https://doi.org/10.1016/j.swevo.2011.08.003
- Parameters:
initializer (Initializer) – Population initializer.
parent_sel (ParentSelection, optional) – Parent selection method.
survivor_sel (SurvivorSelection, optional) – Survivor selection method.
name (str, optional) – Display name (default
"GaussianUMDA").offspring_size (int or SchedulableParameter, optional) – Number of offspring per generation.
random_state (RNGLike, optional) – Random number generator.
loc (float or array-like, optional) – Initial mean (default 0).
scale (float or array-like, optional) – Standard deviation (default 1).
noise (float, optional) – Gaussian noise standard deviation added to loc (default 0).
**kwargs – Forwarded to
VariablePopulation.
- perturb(parents, **kwargs)[source]¶
Applies operators to the population to get the next generation of individuals.
- Parameters:
parents (Population) – The current parents that will be used in the search strategy.
- Returns:
offspring – The list of individuals modified by the operators of the search strategy.
- Return type: