metaheuristic_designer.operators.masked_operator module#
Operator that applies different operators to disjoint slices of the genotype.
- class MaskedOperator(op_list, mask, name=None, **kwargs)[source]#
Bases:
OperatorOperator that partitions the genotype and applies different operators.
A mask (integer array of length vec_size) specifies which operator (index into op_list) handles each gene. This is used internally by
ExtendedOperatorto separate the solution from auxiliary parameters.- Parameters:
- op_listlist of Operator
Operators to apply, one per mask index.
- maskarray of int
Array of length vec_size assigning each gene to an operator.
- namestr, optional
Display name; defaults to
"Split (op_names)".- **kwargs
Forwarded to
Operator.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
op_list (Iterable[Operator])
mask (MaskLike)
name (str)
Methods
__call__(population)Shorthand for
evolve().evolve(population)Apply the appropriate operator to each slice of the genotype.
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 the appropriate operator to each slice of the genotype.
- Return type:
- Parameters:
- populationPopulation
The current population.
- Returns:
- Population
The modified population.
- Parameters:
population (Population)