pg.evolution.Evolution¶
Accessible via pg.evolution.Evolution
.
- class Evolution(reproduction, population_init=(Random(seed=None), 50), population_update=None, *, multi_objective=False)[source]¶
Bases:
pg.DNAGenerator
An evolutionary algorithm based on compositional operations.
Common evolutionary algorithms can be abstracted with 3 operations:
Select parent(s) from the population.
Recombine the DNA from the parents into a list of child DNA.
Mutate each child DNA.
Plus 2 population related operations:
Initialize the population.
Update the population when the fitness is determined for the child DNA.
All the operations above except population initialization can be described by the Operation interface, which transforms a list of DNA into another list of DNA. Moreover, Operation allows complex algorithms to be represented as a composition of elementary operations. For example, Regularized Evolution can be described as:
pg.evolution.Evolution( op=(pg.evolution.selectors.Random(10) >> pg.evolution.selectors.Top(1) >> pg.evolution.mutators.Uniform()), population_init=(pg.geno.Random(), 50), population_update=pg.evolution.selectors.Last(50))
Attributes:
Returns the global state.
Returns True if fitness is a tuple of float numbers.
Returns current population.
Methods:
recover
(history)Recover states by replaying the proposal history.
- property global_state: AttributeDict[source]¶
Returns the global state.