Cambrian.EvolutionType

Every AbstractEvolution subclass needs to have the following fields: config::NamedTuple logger::CambrianLogger population::Array{<:Individual} for config, see getdefaultconfig

Evolution classes should implement the following methods: populate(e::Evolution) evaluate(e::Evolution) generation(e::Evolution) see the default functions for reference

Cambrian.EvolutionMethod
Evolution(cfg::NamedTuple; logfile::String="logs/id.csv")

create a base Evolution class. This is provided as an example class and for tests. Intended usage of Cambrian is to subclass the AbstractEvolution type and define the evolutionary methods which define the intended algorithm.

Cambrian.GAEvoType

GAEvo implements a classic genetic algorithm. To do this, a new subtype of AbstractEvolution is created, GAEvo, and the following functions are defined for this type:

evaluate populate

the function generation can also be defined. Without specification, the default generation function (which is void) is applied.

Cambrian.IndividualType

every Individual subtype needs to implement: Individual(cfg::NamedTuple) Individual(json::String) mutate(ind::Individual) crossover(parents::Vararg{Individual})

and have the fields genes fitness::Array

BoolIndvidiual and FloatIndividual are provided as Cambrian defaults

Cambrian.OnePlusEvoType

OnePlusEvo implements a 1+λ evolutionary algorithm. To do this, a new subtype of AbstractEvolution is created, OnePlusEvo, and the following functions are defined for this type:

evaluate populate

the function generation can also be defined. Without specification, the default generation function (which is void) is applied.

Cambrian.crossoverMethod

default crossover method, using uniform crossover for N parents

Cambrian.elites_generationMethod

update e.elites with the best individuals from the current population or existing elites, based on fitness

Cambrian.evaluateMethod
evaluate(e::AbstractEvolution)

Default evaluate function. Sets each element of the fitness array of each individual to -Inf.

Cambrian.fitness_evaluateFunction
function fitness_evaluate(e::AbstractEvolution; fitness::Function=null_evaluate)

sets the fitness of each individual to the Array of values returned by fitness

Cambrian.generationMethod

generation should be used for any additional record keeping necessary in an algorithm. It is called after populate and evaluate, so all individuals should have genes and fitness reflecting their current state. The default function calls elites_generation if e.elites is defined, otherwise does nothing.

Cambrian.log_genMethod

log a generation, including max, mean, and std of each fitness dimension

Cambrian.mutateMethod

mutate(parent::BoolIndividual, mrate::Float64). To use, define mutate(parent::BoolIndividual) = mutate(parent, mrate) with configured m_rate for a Boolean individual, this random flips the bits of the parent

Cambrian.run!Method

Call step!(e) e.config.n_gen times consecutively

Cambrian.step!Method

The generic iteration of an evolution. Calls populate, evaluate, and generation. Also calls loggen and savegen based on the provided config values. Subclasses of AbstractEvolution should override the populate, evaluate, or generation functions rather than overriding this function.