metaheuristic_designer.operators.composite_operator module#
Operator that applies a sequence of operators one after another.
- class CompositeOperator(op_list, name=None, encoding=None, rng=None)[source]#
Bases:
OperatorOperator 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_listlist of Operator
The operators to apply in order.
- namestr, optional
Display name; defaults to
"Sequence (op_names)".- encodingEncoding, optional
Encoding applied to the genotype.
- rngRNGLike, optional
Random number generator (shared with sub-operators).
- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
Methods
__call__(population)Shorthand for
evolve().evolve(population)Apply each operator in sequence.
Collect parameters from this operator and all sub-operators.
get_params()Return a copy of the current parameter dictionary.
Gets the current state of the algorithm as a dictionary.
store_kwargs([progress])Store keyword arguments and evaluate them at the given progress.
update(progress)Update schedulable parameters and propagate to sub-operators.
update_kwargs([progress])Add or replace parameters and immediately evaluate them.
- gather_params()[source]#
Collect parameters from this operator and all sub-operators.
- Return type:
dict- Returns:
- dict
Flat dictionary with dotted keys.
- evolve(population)[source]#
Apply each operator in sequence.
- Return type:
- Parameters:
- populationPopulation
The current population.
- Returns:
- Population
The population after all operators have been applied.
- Parameters:
population (Population)