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]
step() None[source]
class evokit.evolvables.ac.CollisionRule[source]

Bases: Variator[DM], ABC

Base class for all collision rules. Works with both MoleculeSet and Population

Alternative 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 by react(). 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 of parents is guaranteed to be CollisionRule.arity.

Implementation should only use Individual.genome to 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 population into groups of size arity, 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.