pg.evolution.Repeat¶
Accessible via pg.evolution.Repeat
.
- class Repeat(op, k)[source]¶
Bases:
pg.evolution.Operation
Repeat an operation multiple times based on the same input.
A repeat operation passes the input to the child operation for K times, and concatenate their outputs.
Example:
Repeat(pg.evolution.mutators.Uniform(), 3)
which is equivalent to:
pg.evolution.mutators.Uniform() * 3
The code above creates 3 mutated DNA for each DNA from the input.
It’s important to differentiate
*
and**
. For instance, Uniform() ** 3 creates one DNA (mutated on 3 positions) for each DNA from the input.Methods:
call
(inputs, global_state[, step])Subclasses should override this method.
- call(inputs, global_state, step=0)[source]¶
Subclasses should override this method.
The global_state and step are optional for the subclasses’ call signature.
- Return type:
- Parameters:
inputs – A list of values as inputs.
global_state – An AttributeDict object as the global state container, which is readable/writable during the operation.
step – Number of examples historically proposed, which can be used for determining a cross over schedule.
- Returns:
A list of values as output of current operation.