metaheuristic_designer.operators.extended_operator module#

Base operator for algorithms that split the genotype into solution and parameters.

class ExtendedOperator(base_operator, param_operators, encoding, name=None, **kwargs)[source]#

Bases: Operator

Operator that handles a genotype split into solution and extra parameters.

A mask is built from the encoding to separate the solution part from the parameter blocks. The solution is processed by base_operator, while each parameter block can be mutated/adapted by its own operator.

Parameters:
base_operatorOperator

Operator applied to the solution part.

param_operatorsdict

Mapping from parameter names to their mutation operators.

encodingParameterExtendingEncoding

The encoding that defines the genotype layout.

namestr, optional

Display name; defaults to the base operator’s name.

**kwargs

Forwarded to Operator.

Attributes:
params

Access parameter values by attribute-style lookup.

Parameters:

Methods

__call__(population)

Shorthand for evolve().

evolve(population)

Apply the main masked operator (solution + parameter mutations).

gather_params()

Collect parameters from the base operator and all parameter 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 the base operator and all parameter operators.

Return type:

dict

Returns:
dict

Flat dictionary with dotted keys.

evolve(population)[source]#

Apply the main masked operator (solution + parameter mutations).

Return type:

Population

Parameters:
populationPopulation

The current population.

Returns:
Population

The evolved population.

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)