metaheuristic_designer.operators package

Subpackages

Submodules

metaheuristic_designer.operators.BO_operator module

Bayesian Optimization operator based on Gaussian Process regression.

class BOOperator(name: str = 'Gaussian Regression Surrogate Model', encoding: Encoding | None = None, kernel: Callable | None = None, random_state: int | Generator | None = None, batch_size: int = 100, max_samples: int = 100, rbf_scale: float = 1.0, **kwargs)[source]

Bases: Operator

Bayesian Optimization operator using a GP surrogate.

Fits a Gaussian Process model to the current population, then maximises the Expected Improvement acquisition function to propose a new candidate solution. The new solution is merged back into the population.

Parameters:
  • name (str, optional) – Display name (default "Gaussian Regression Surrogate Model").

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • kernel (sklearn Kernel, optional) – GP kernel. Defaults to RBF(length_scale=1.0) + WhiteKernel(noise_level=1.0).

  • random_state (RNGLike, optional) – Random number generator.

  • batch_size (int, optional) – Number of random starting points for acquisition optimisation (default 100).

  • max_samples (int, optional) – Maximum number of training points used (default 100). If the population exceeds this, a random subset is selected.

  • rbf_scale (float, optional) – Multiplicative factor applied to the RBF kernel (default 1.0).

  • **kwargs – Additional keyword arguments stored as schedulable parameters.

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Fit GP, optimise acquisition, and merge the proposed point.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – Used to generate random starting points for acquisition optimisation.

Returns:

The population with the new candidate appended.

Return type:

Population

metaheuristic_designer.operators.adaptive_operator module

Adaptive operator that updates its parameters from the genotype.

class AdaptiveOperator(base_operator: Operator, param_operators: dict, encoding: ParameterExtendingEncoding, name: str | None = None, **kwargs)[source]

Bases: ExtendedOperator

Operator that dynamically adapts its base operator’s parameters.

At each generation, the parameters encoded in the genotype are decoded and used to update the base operator before applying it to the population. This enables self-adaptive algorithms (e.g., Evolution Strategies with evolving mutation strengths).

See ExtendedOperator for constructor parameters.

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Decode parameters, update the base operator, then apply it.

Parameters:
  • population (Population) – The current population (whose genotype contains the parameters).

  • initializer (Initializer, optional) – The population initializer.

Returns:

The evolved population.

Return type:

Population

metaheuristic_designer.operators.branch_operator module

Operator that randomly applies one operator from a list to each individual.

class BranchOpMethods(value)[source]

Bases: Enum

An enumeration.

RANDOM = 1
PICK = 2
static from_str(str_input: str) BranchOpMethods[source]
class BranchOperator(op_list: Iterable[Operator], method: str | None = None, name: str | None = None, encoding: Encoding | None = None, random_state: int | Generator | None = None, idx: int = -1, p: float = 0.5, **kwargs)[source]

Bases: Operator

Operator that stochastically selects among several operators.

For each individual, one operator from op_list is chosen according to the configured method (random with given probability, or manually picked). This allows e.g. applying mutation with a certain probability while leaving the rest untouched.

Parameters:
  • op_list (list of Operator) – The candidate operators.

  • method (str, optional) – Branching method, "random" or "pick" (default "random").

  • name (str, optional) – Display name; defaults to "method(op_names)".

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • random_state (RNGLike, optional) – Random number generator.

  • idx (int, optional) – Index of the operator to use when method is "pick" (default -1).

  • p (float, optional) – Probability of selecting the first operator (default 0.5). The second operator (usually NullOperator) gets probability 1 - p.

  • **kwargs – Additional keyword arguments stored as schedulable parameters.

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply a random operator to each individual according to the branch method.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The modified population.

Return type:

Population

choose_index(idx: int)[source]

Manually chooses the operator to use next

Parameters:

idx (int) – Index of the operator in the list.

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

metaheuristic_designer.operators.composite_operator module

Operator that applies a sequence of operators one after another.

class CompositeOperator(op_list: Iterable[Operator], name: str | None = None, encoding: Encoding | None = None, random_state: int | Generator | None = None)[source]

Bases: Operator

Operator that sequentially applies a list of operators.

Each operator in op_list receives the population returned by the previous one. This is the canonical way to chain crossover and mutation, or to build more complex pipelines.

Parameters:
  • op_list (list of Operator) – The operators to apply in order.

  • name (str, optional) – Display name; defaults to "Sequence (op_names)".

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • random_state (RNGLike, optional) – Random number generator (shared with sub-operators).

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply each operator in sequence.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The population after all operators have been applied.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

metaheuristic_designer.operators.extended_operator module

Base operator for algorithms that split the genotype into solution and parameters.

class ExtendedOperator(base_operator: Operator, param_operators: dict, encoding: ParameterExtendingEncoding, name: str | None = None, **kwargs)[source]

Bases: Operator

Operator that handles a genotype split into solution and extra parameters.

A mask is built from the encoding to separate the solution part from the parameter blocks. The solution is processed by base_operator, while each parameter block can be mutated/adapted by its own operator.

Parameters:
  • base_operator (Operator) – Operator applied to the solution part.

  • param_operators (dict) – Mapping from parameter names to their mutation operators.

  • encoding (ParameterExtendingEncoding) – The encoding that defines the genotype layout.

  • name (str, optional) – Display name; defaults to the base operator’s name.

  • **kwargs – Forwarded to Operator.

gather_params() dict[source]

Collect parameters from the base operator and all parameter operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply the main masked operator (solution + parameter mutations).

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The evolved population.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

metaheuristic_designer.operators.masked_operator module

Operator that applies different operators to disjoint slices of the genotype.

class MaskedOperator(op_list: Iterable[Operator], mask: ndarray[tuple[int, ...], integer] | ndarray[tuple[int, ...], uint8 | bool], name: str | None = None, **kwargs)[source]

Bases: Operator

Operator that partitions the genotype and applies different operators.

A mask (integer array of length vec_size) specifies which operator (index into op_list) handles each gene. This is used internally by ExtendedOperator to separate the solution from auxiliary parameters.

Parameters:
  • op_list (list of Operator) – Operators to apply, one per mask index.

  • mask (array of int) – Array of length vec_size assigning each gene to an operator.

  • name (str, optional) – Display name; defaults to "Split (op_names)".

  • **kwargs – Forwarded to Operator.

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply the appropriate operator to each slice of the genotype.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The modified population.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

Module contents

Operator interfaces and base implementations.

class NullOperator(name: str | None = None)[source]

Bases: Operator

Operator class that returns the individual without changes. Surprisingly useful.

Since it’s a no-op, it has the preserves_order flag set to True.

Parameters:

name (str, optional) – Name that is associated with the operator.

evolve(population: Population, *args) Population[source]

Evolves an population using a given strategy.

Parameters:
  • population (Population) – The population that will be used.

  • initializer (Initialize, optional) – The population initializer of the algorithm (used for randomly generating individuals).

Returns:

new_population – The modified population.

Return type:

Population

class Operator(name: str | None = None, encoding: Encoding | None = None, preserves_order: bool = False, random_state: int | Generator | None = None, **kwargs)[source]

Bases: ParametrizableMixin, ABC

Abstract base for all perturbation operators.

An Operator modifies a population (typically by applying mutation, crossover, or a composite of several steps). Subclasses must implement evolve().

Parameters:
  • name (str, optional) – Display name for this operator.

  • encoding (Encoding, optional) – Post-processing applied to the genotype matrix after the operator runs. Defaults to DefaultEncoding.

  • preserves_order (bool, optional) – If True, the operator keeps individuals in the same order (useful for one-to-one survivor selection). Default False.

  • random_state (RNGLike, optional) – Random number generator.

  • **kwargs – Additional keyword arguments stored as schedulable parameters.

gather_params()[source]

Return the current parameter dictionary (thin wrapper around get_params()).

abstract evolve(population: Population, initializer: Initializer | None = None) Population[source]

Evolves an population using a given strategy.

Parameters:
  • population (Population) – The population that will be used.

  • initializer (Initialize, optional) – The population initializer of the algorithm (used for randomly generating individuals).

Returns:

new_population – The modified population.

Return type:

Population

step(progress: float = 0)[source]

Updates the internal parameters.

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

class OperatorFromLambda(operator_fn: Callable, name: str | None = None, encoding: Encoding | None = None, preserves_order: bool = False, random_state: int | Generator | None = None, **kwargs)[source]

Bases: Operator

Operator that wraps a user‑supplied function.

The function receives a Population, an Initializer, a random state, and any stored keyword arguments, and must return a modified Population.

Parameters:
  • operator_fn (callable) – A function (population, initializer, random_state, **kwargs) -> Population.

  • name (str, optional) – Display name (defaults to the function’s __name__).

  • encoding (Encoding, optional) – See Operator.

  • preserves_order (bool, optional) – See Operator.

  • random_state (RNGLike, optional) – See Operator.

  • **kwargs – Keyword arguments forwarded to Operator and also passed to operator_fn on each call.

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Evolves an population using a given strategy.

Parameters:
  • population (Population) – The population that will be used.

  • initializer (Initialize, optional) – The population initializer of the algorithm (used for randomly generating individuals).

Returns:

new_population – The modified population.

Return type:

Population

class AdaptiveOperator(base_operator: Operator, param_operators: dict, encoding: ParameterExtendingEncoding, name: str | None = None, **kwargs)[source]

Bases: ExtendedOperator

Operator that dynamically adapts its base operator’s parameters.

At each generation, the parameters encoded in the genotype are decoded and used to update the base operator before applying it to the population. This enables self-adaptive algorithms (e.g., Evolution Strategies with evolving mutation strengths).

See ExtendedOperator for constructor parameters.

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Decode parameters, update the base operator, then apply it.

Parameters:
  • population (Population) – The current population (whose genotype contains the parameters).

  • initializer (Initializer, optional) – The population initializer.

Returns:

The evolved population.

Return type:

Population

class BOOperator(name: str = 'Gaussian Regression Surrogate Model', encoding: Encoding | None = None, kernel: Callable | None = None, random_state: int | Generator | None = None, batch_size: int = 100, max_samples: int = 100, rbf_scale: float = 1.0, **kwargs)[source]

Bases: Operator

Bayesian Optimization operator using a GP surrogate.

Fits a Gaussian Process model to the current population, then maximises the Expected Improvement acquisition function to propose a new candidate solution. The new solution is merged back into the population.

Parameters:
  • name (str, optional) – Display name (default "Gaussian Regression Surrogate Model").

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • kernel (sklearn Kernel, optional) – GP kernel. Defaults to RBF(length_scale=1.0) + WhiteKernel(noise_level=1.0).

  • random_state (RNGLike, optional) – Random number generator.

  • batch_size (int, optional) – Number of random starting points for acquisition optimisation (default 100).

  • max_samples (int, optional) – Maximum number of training points used (default 100). If the population exceeds this, a random subset is selected.

  • rbf_scale (float, optional) – Multiplicative factor applied to the RBF kernel (default 1.0).

  • **kwargs – Additional keyword arguments stored as schedulable parameters.

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Fit GP, optimise acquisition, and merge the proposed point.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – Used to generate random starting points for acquisition optimisation.

Returns:

The population with the new candidate appended.

Return type:

Population

class BranchOpMethods(value)[source]

Bases: Enum

An enumeration.

RANDOM = 1
PICK = 2
static from_str(str_input: str) BranchOpMethods[source]
class BranchOperator(op_list: Iterable[Operator], method: str | None = None, name: str | None = None, encoding: Encoding | None = None, random_state: int | Generator | None = None, idx: int = -1, p: float = 0.5, **kwargs)[source]

Bases: Operator

Operator that stochastically selects among several operators.

For each individual, one operator from op_list is chosen according to the configured method (random with given probability, or manually picked). This allows e.g. applying mutation with a certain probability while leaving the rest untouched.

Parameters:
  • op_list (list of Operator) – The candidate operators.

  • method (str, optional) – Branching method, "random" or "pick" (default "random").

  • name (str, optional) – Display name; defaults to "method(op_names)".

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • random_state (RNGLike, optional) – Random number generator.

  • idx (int, optional) – Index of the operator to use when method is "pick" (default -1).

  • p (float, optional) – Probability of selecting the first operator (default 0.5). The second operator (usually NullOperator) gets probability 1 - p.

  • **kwargs – Additional keyword arguments stored as schedulable parameters.

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply a random operator to each individual according to the branch method.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The modified population.

Return type:

Population

choose_index(idx: int)[source]

Manually chooses the operator to use next

Parameters:

idx (int) – Index of the operator in the list.

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

class CompositeOperator(op_list: Iterable[Operator], name: str | None = None, encoding: Encoding | None = None, random_state: int | Generator | None = None)[source]

Bases: Operator

Operator that sequentially applies a list of operators.

Each operator in op_list receives the population returned by the previous one. This is the canonical way to chain crossover and mutation, or to build more complex pipelines.

Parameters:
  • op_list (list of Operator) – The operators to apply in order.

  • name (str, optional) – Display name; defaults to "Sequence (op_names)".

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • random_state (RNGLike, optional) – Random number generator (shared with sub-operators).

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply each operator in sequence.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The population after all operators have been applied.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

class ExtendedOperator(base_operator: Operator, param_operators: dict, encoding: ParameterExtendingEncoding, name: str | None = None, **kwargs)[source]

Bases: Operator

Operator that handles a genotype split into solution and extra parameters.

A mask is built from the encoding to separate the solution part from the parameter blocks. The solution is processed by base_operator, while each parameter block can be mutated/adapted by its own operator.

Parameters:
  • base_operator (Operator) – Operator applied to the solution part.

  • param_operators (dict) – Mapping from parameter names to their mutation operators.

  • encoding (ParameterExtendingEncoding) – The encoding that defines the genotype layout.

  • name (str, optional) – Display name; defaults to the base operator’s name.

  • **kwargs – Forwarded to Operator.

gather_params() dict[source]

Collect parameters from the base operator and all parameter operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply the main masked operator (solution + parameter mutations).

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The evolved population.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

class MaskedOperator(op_list: Iterable[Operator], mask: ndarray[tuple[int, ...], integer] | ndarray[tuple[int, ...], uint8 | bool], name: str | None = None, **kwargs)[source]

Bases: Operator

Operator that partitions the genotype and applies different operators.

A mask (integer array of length vec_size) specifies which operator (index into op_list) handles each gene. This is used internally by ExtendedOperator to separate the solution from auxiliary parameters.

Parameters:
  • op_list (list of Operator) – Operators to apply, one per mask index.

  • mask (array of int) – Array of length vec_size assigning each gene to an operator.

  • name (str, optional) – Display name; defaults to "Split (op_names)".

  • **kwargs – Forwarded to Operator.

gather_params() dict[source]

Collect parameters from this operator and all sub-operators.

Returns:

Flat dictionary with dotted keys.

Return type:

dict

evolve(population: Population, initializer: Initializer | None = None) Population[source]

Apply the appropriate operator to each slice of the genotype.

Parameters:
  • population (Population) – The current population.

  • initializer (Initializer, optional) – The population initializer.

Returns:

The modified population.

Return type:

Population

step(progress: float)[source]

Update schedulable parameters and propagate to sub-operators.

Parameters:

progress (float) – Current progress of the algorithm (0-1).

get_state() dict[source]

Gets the current state of the algorithm as a dictionary.

Returns:

state – The complete state of the operator.

Return type:

dict

class ObtainStatisticDef(operator_fn: callable, params: dict = <factory>, forced_params: dict = <factory>)[source]

Bases: object

Wrap a statistic‑computing function into an Operator.

This adapter is used for functions that compute a single summary vector (e.g., population mean, median, standard deviation) and store it as the new genotype (usually a single-row population).

Parameters:
  • operator_fn (callable) – Function with signature (population_matrix, random_state, **kwargs) -> np.ndarray.

  • params (dict, optional) – Default keyword arguments.

  • forced_params (dict, optional) – Keyword arguments that override user-supplied ones.

operator_fn: callable
params: dict
forced_params: dict
class OperatorRandomDef(operator_fn: callable, params: dict = <factory>, forced_params: dict = <factory>)[source]

Bases: object

Bridge a random-style operator function into an Operator.

This wrapper is intended for operators that replace the genotype with entirely new random values (e.g., uniform sampling, initializer-based reset). It passes the population’s genotype matrix, the initializer, and the random state to the underlying function.

Parameters:
  • operator_fn (callable) – Function with signature (population_matrix, initializer, random_state, **kwargs) -> np.ndarray.

  • params (dict, optional) – Default keyword arguments.

  • forced_params (dict, optional) – Keyword arguments that override any user-supplied ones.

operator_fn: callable
params: dict
forced_params: dict
class OperatorSwarmDef(operator_fn: callable, params: dict = <factory>, forced_params: dict = <factory>)[source]

Bases: object

Bridge a swarm operator function into an Operator.

This wrapper is designed for operators that directly receive the whole Population object and the initializer, and are responsible for returning an updated Population themselves (e.g., PSO operators that need access to historical bests).

Parameters:
  • operator_fn (callable) – Function with signature (population, initializer, random_state, **kwargs) -> Population.

  • params (dict, optional) – Default keyword arguments.

  • forced_params (dict, optional) – Keyword arguments that override user-supplied ones.

operator_fn: callable
params: dict
forced_params: dict
class OperatorFnDef(operator_fn: callable, params: dict = <factory>, forced_params: dict = <factory>)[source]

Bases: object

Bridge a matrix-to-matrix operator function into an Operator.

This wrapper accepts a callable that operates on a genotype matrix, fitness array, and random state, and turns it into an object that can be used directly on a Population. It merges user-supplied keyword arguments with stored defaults and forced parameters, then invokes the underlying function and updates the population’s genotype.

Parameters:
  • operator_fn (callable) – Function with signature (population_matrix, fitness_array, random_state, **kwargs) -> np.ndarray.

  • params (dict, optional) – Default keyword arguments for the operator.

  • forced_params (dict, optional) – Keyword arguments that always override user-supplied ones.

operator_fn: callable
params: dict
forced_params: dict
list_operators() list[str][source]

Return a list of all registered operator keys.

Each key is formatted as "registry.operator_name" and can be passed to create_operator().

Returns:

Fully qualified operator names.

Return type:

list of str

add_operator_entry(operator_fn: callable, operator_name: str, operator_registry: str = 'custom', preserves_order=False)[source]

Register a new operator so it can be created by create_operator().

Parameters:
  • operator_fn (callable) – A callable that follows the operator signature expected by OperatorFromLambda. Usually wrapped with OperatorFnDef, OperatorRandomDef, etc.

  • operator_name (str) – Key under which the operator is registered.

  • operator_registry (str, optional) – Registry name (default "custom"). If the registry does not exist, it is created.

  • preserves_order (bool, optional) – If True, the operator is marked as order-preserving, meaning individuals retain their position when applying it. Default False.

create_crossover_operator(method: str, encoding: Encoding | None = None, random_state: int | Generator | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a crossover operator by name.

Parameters:
  • method (str) – Key into crossover_ops_map (e.g., "one_point", "uniform").

  • encoding (Encoding, optional) – Encoding applied to the genotype after crossover.

  • random_state (RNGLike, optional) – Random number generator.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Additional parameters forwarded to the operator function (e.g., k, crossover_prob, pairing_method).

Returns:

The wrapped crossover operator.

Return type:

OperatorFromLambda

create_debug_operator(method: str, encoding: Encoding | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a debug operator by name.

Parameters:
  • method (str) – Key into debug_ops_map.

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Forwarded to the operator function.

Returns:

The wrapped debug operator.

Return type:

OperatorFromLambda

create_differential_evolution_operator(method: str, encoding: Encoding | None = None, vectorized: bool = True, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a DE operator by name.

Parameters:
  • method (str) – DE variant string, e.g., "de/rand/1".

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • vectorized (bool, optional) – Unused; kept for interface compatibility.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Forwarded to the DE operator function (e.g., F, Cr).

Returns:

The wrapped DE operator.

Return type:

OperatorFromLambda

create_mutation_operator(method: str, encoding: Encoding | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a mutation operator by name.

Parameters:
  • method (str) – Key into mutation_ops_map.

  • encoding (Encoding, optional) – Encoding applied to the genotype after mutation.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Parameters forwarded to the mutation function (e.g., N, F, distribution).

Returns:

The wrapped mutation operator.

Return type:

OperatorFromLambda

create_operator(method: str, encoding: Encoding | None = None, random_state: int | Generator | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create an operator by name from any registry.

The method string can be a simple key (e.g., "gauss") or dot-separated "registry.key" (e.g., "crossover.one_point").

Parameters:
  • method (str) – Operator key, possibly with registry prefix.

  • encoding (Encoding, optional) – Encoding applied to the genotype after the operator runs.

  • random_state (RNGLike, optional) – Random number generator.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Parameters forwarded to the underlying operator function.

Returns:

The wrapped operator.

Return type:

OperatorFromLambda

Raises:

ValueError – If the operator cannot be found.

create_permutation_operator(method: str, encoding: Encoding | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a permutation operator by name.

Parameters:
  • method (str) – Key into permutation_ops_map.

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Forwarded to the operator function.

Returns:

The wrapped permutation operator.

Return type:

OperatorFromLambda

create_random_operator(method: str, encoding: Encoding | None = None, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a random operator that uses an Initializer for fresh values.

Parameters:
  • method (str) – Key into random_ops_map.

  • encoding (Encoding, optional) – Encoding applied to the genotype.

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Forwarded to the operator function.

Returns:

The wrapped random operator.

Return type:

OperatorFromLambda

create_swarm_operator(method: str, name: str | None = None, **kwargs) OperatorFromLambda[source]

Create a swarm operator by name.

Parameters:
  • method (str) – Key into swarm_ops_map (e.g., "pso").

  • name (str, optional) – Display name; defaults to method.

  • **kwargs – Forwarded to the operator function.

Returns:

The wrapped swarm operator.

Return type:

OperatorFromLambda