metaheuristic_designer.operators.factories package#
Submodules#
- metaheuristic_designer.operators.factories.crossover module
- metaheuristic_designer.operators.factories.debug module
- metaheuristic_designer.operators.factories.differential_evolution module
- metaheuristic_designer.operators.factories.generic module
- metaheuristic_designer.operators.factories.mutation module
- metaheuristic_designer.operators.factories.permutation module
- metaheuristic_designer.operators.factories.random module
- metaheuristic_designer.operators.factories.swarm module
Module contents#
Operator factory package, provides registries and creation functions.
- list_operators()[source]#
Return a list of all registered operator keys.
Each key is formatted as
"registry.operator_name"and can be passed tocreate_operator().- Return type:
list[str]- Returns:
- list of str
Fully qualified operator names.
- add_operator_entry(operator_fn, operator_name, operator_registry='custom', preserves_order=False)[source]#
Register a new operator so it can be created by
create_operator().- Parameters:
- operator_fncallable
A callable that follows the operator signature expected by
OperatorFromLambda. Usually wrapped withOperatorFnDef,OperatorRandomDef, etc.- operator_namestr
Key under which the operator is registered.
- operator_registrystr, optional
Registry name (default
"custom"). If the registry does not exist, it is created.- preserves_orderbool, optional
If
True, the operator is marked as order-preserving, meaning individuals retain their position when applying it. DefaultFalse.
- Parameters:
operator_fn (callable)
operator_name (str)
operator_registry (str)
- create_crossover_operator(method, encoding=None, rng=None, name=None, **kwargs)[source]#
Create a crossover operator by name.
- Return type:
- Parameters:
- methodstr
Key into
crossover_ops_map(e.g.,"one_point","uniform").- encodingEncoding, optional
Encoding applied to the genotype after crossover.
- rngRNGLike, optional
Random number generator.
- namestr, optional
Display name; defaults to method.
- **kwargs
Additional parameters forwarded to the operator function (e.g.,
k,crossover_prob,pairing_method).
- Returns:
- OperatorFromLambda
The wrapped crossover operator.
- Parameters:
method (str)
encoding (Encoding | None)
rng (int | Generator | None)
name (str | None)
- create_debug_operator(method, encoding=None, name=None, **kwargs)[source]#
Create a debug operator by name.
- Return type:
- Parameters:
- methodstr
Key into
debug_ops_map.- encodingEncoding, optional
Encoding applied to the genotype.
- namestr, optional
Display name; defaults to method.
- **kwargs
Forwarded to the operator function.
- Returns:
- OperatorFromLambda
The wrapped debug operator.
- Parameters:
method (str)
encoding (Encoding | None)
name (str | None)
- create_differential_evolution_operator(method, encoding=None, vectorized=True, name=None, **kwargs)[source]#
Create a DE operator by name.
- Return type:
- Parameters:
- methodstr
DE variant string, e.g.,
"de/rand/1".- encodingEncoding, optional
Encoding applied to the genotype.
- vectorizedbool, optional
Unused; kept for interface compatibility.
- namestr, optional
Display name; defaults to method.
- **kwargs
Forwarded to the DE operator function (e.g.,
F,Cr).
- Returns:
- OperatorFromLambda
The wrapped DE operator.
- Parameters:
method (str)
encoding (Encoding | None)
vectorized (bool)
name (str | None)
- create_mutation_operator(method, encoding=None, name=None, **kwargs)[source]#
Create a mutation operator by name.
- Return type:
- Parameters:
- methodstr
Key into
mutation_ops_map.- encodingEncoding, optional
Encoding applied to the genotype after mutation.
- namestr, optional
Display name; defaults to method.
- **kwargs
Parameters forwarded to the mutation function (e.g.,
N,F,distribution).
- Returns:
- OperatorFromLambda
The wrapped mutation operator.
- Parameters:
method (str)
encoding (Encoding | None)
name (str | None)
- create_operator(method, encoding=None, rng=None, name=None, **kwargs)[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").- Return type:
- Parameters:
- methodstr
Operator key, possibly with registry prefix.
- encodingEncoding, optional
Encoding applied to the genotype after the operator runs.
- rngRNGLike, optional
Random number generator.
- namestr, optional
Display name; defaults to method.
- **kwargs
Parameters forwarded to the underlying operator function.
- Returns:
- OperatorFromLambda
The wrapped operator.
- Raises:
- ValueError
If the operator cannot be found.
- Parameters:
method (str)
encoding (Encoding | None)
rng (int | Generator | None)
name (str | None)
- create_permutation_operator(method, encoding=None, name=None, **kwargs)[source]#
Create a permutation operator by name.
- Return type:
- Parameters:
- methodstr
Key into
permutation_ops_map.- encodingEncoding, optional
Encoding applied to the genotype.
- namestr, optional
Display name; defaults to method.
- **kwargs
Forwarded to the operator function.
- Returns:
- OperatorFromLambda
The wrapped permutation operator.
- Parameters:
method (str)
encoding (Encoding | None)
name (str | None)
- create_random_operator(method, initializer, encoding=None, name=None, **kwargs)[source]#
Create a random operator that uses an Initializer for fresh values.
- Return type:
- Parameters:
- methodstr
Key into
random_ops_map.- encodingEncoding, optional
Encoding applied to the genotype.
- namestr, optional
Display name; defaults to method.
- **kwargs
Forwarded to the operator function.
- Returns:
- OperatorFromLambda
The wrapped random operator.
- Parameters:
method (str)
initializer (Initializer)
encoding (Encoding | None)
name (str | None)
- create_swarm_operator(method, name=None, **kwargs)[source]#
Create a swarm operator by name.
- Return type:
- Parameters:
- methodstr
Key into
swarm_ops_map(e.g.,"pso").- namestr, optional
Display name; defaults to method.
- **kwargs
Forwarded to the operator function.
- Returns:
- OperatorFromLambda
The wrapped swarm operator.
- Parameters:
method (str)
name (str | None)