metaheuristic_designer.operators.factories package¶
Submodules¶
metaheuristic_designer.operators.factories.crossover module¶
Crossover operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.debug module¶
Debug operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.differential_evolution module¶
Differential Evolution operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.generic module¶
Top-level operator factory and registry.
- 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:
- Raises:
ValueError – If the operator cannot be found.
- 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 withOperatorFnDef,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. DefaultFalse.
- 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 tocreate_operator().- Returns:
Fully qualified operator names.
- Return type:
list of str
metaheuristic_designer.operators.factories.mutation module¶
Mutation operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.permutation module¶
Permutation operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.random module¶
Random-generation operator registry and factory.
- 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:
metaheuristic_designer.operators.factories.swarm module¶
Swarm operator registry and factory.
- 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:
Module contents¶
Operator factory package, provides registries and creation functions.
- 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 tocreate_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 withOperatorFnDef,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. DefaultFalse.
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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: