evokit.evolvables.ac package
Submodules
Module contents
- class evokit.evolvables.ac.CollisionSoup[source]
Bases:
HomogeneousAlgorithm[DM]Base class for all artificial chemistry systems.
Artificial chemistry algorithms do not use selectors, variators, and evaluators; rather, change occurs according to a set of
CollisionRules: items that can react according to a rule are consumed to create its products.Individuals used in these algorithms must have hashable genomes.
- __init__(population: Population[DM], rules: list[CollisionRule]) None[source]
- class evokit.evolvables.ac.CollisionRule[source]
Bases:
Variator[DM],ABCBase class for all collision rules. Works with both
MoleculeSetandPopulationAlternative to
Variator. Whereas the variator takes a tuple from the population, a collision rule does the following:1molecules = draw(population) 2molecules.append(draw(population))
Tutorial: Getting Started with OneMax.
- Sequence
alias of
Sequence
- NO_REACTION_TUPLE: tuple[DM] = ()
- vary(parents: Sequence[DM]) tuple[DM, ...][source]
Identity.
In a
CollisionRule, the reaction is handled byreact(). Still,vary()is called to provide framework support (e.g. to register reactants as parents of the results).Do not override this; override
react()instead.
- abstract react(parents: Sequence[DM]) tuple[DM, ...] | None[source]
Attempt a reaction using
parents. The length ofparentsis guaranteed to beCollisionRule.arity.Implementation should only use
Individual.genometo check if an reaction can occur.
- vary_population(population: Population[DM], *args: Any, **kwargs: Any) Population[DM][source]
Vary the population.
The default implementation separates
populationinto groups of sizearity, call .vary with each group as argument, then collect and returns the result.- Parameters:
population – Population to vary.
Note
The default implementation calls
Individual.reset_fitness()on each offspring to clear its fitness. Any implementation that overrides this method should do the same.