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: 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_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:
params

Access parameter values by attribute-style lookup.

Parameters:
  • op_list (Iterable[Operator])

  • name (str)

  • encoding (Optional[Encoding])

  • rng (Optional[RNGLike])

Methods

__call__(population)

Shorthand for evolve().

evolve(population)

Apply each operator in sequence.

gather_params()

Collect parameters from this operator and all sub-operators.

get_params()

Return a copy of the current parameter dictionary.

get_state()

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:

Population

Parameters:
populationPopulation

The current population.

Returns:
Population

The population after all operators have been applied.

Parameters:

population (Population)

update(progress)[source]#

Update schedulable parameters and propagate to sub-operators.

Parameters:
progressfloat

Current progress of the algorithm (0-1).

Parameters:

progress (float)

get_state()[source]#

Gets the current state of the algorithm as a dictionary.

Return type:

dict

Returns:
state: dict

The complete state of the operator.