metaheuristic_designer.operators.factories.generic module#
Top-level operator factory and registry.
- 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)
- 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)
- 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.