Cambrian.BoolIndividual
— TypeBoolIndividual : example Individual class using a binary string genotype
Cambrian.Evolution
— TypeEvery 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.Evolution
— MethodEvolution(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.FloatIndividual
— TypeFloatIndividual : example Individual class using a floating point genotype in [0, 1]
Cambrian.GAEvo
— TypeGAEvo 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.Individual
— Typeevery 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.OnePlusEvo
— TypeOnePlusEvo 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.crossover
— Methoddefault crossover method, using uniform crossover for N parents
Cambrian.elites_generation
— Methodupdate e.elites with the best individuals from the current population or existing elites, based on fitness
Cambrian.evaluate
— Methodevaluate(e::AbstractEvolution)
Default evaluate function. Sets each element of the fitness array of each individual to -Inf.
Cambrian.fitness_evaluate
— Functionfunction fitness_evaluate(e::AbstractEvolution; fitness::Function=null_evaluate)
sets the fitness of each individual to the Array of values returned by fitness
Cambrian.ga_populate
— Methodpopulate(e::GAEvo)
Cambrian.generation
— Methodgeneration 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.get_config
— Methodconvert Dict to named tuple
Cambrian.get_config
— Methodcombine YAML file and kwargs, make sure ID is specified
Cambrian.initialize
— Methodcreate all members of the first generation
Cambrian.log_gen
— Methodlog a generation, including max, mean, and std of each fitness dimension
Cambrian.max_selection
— Methodreturn the best individual from a population
Cambrian.mutate
— Methodmutate(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.random_evaluate
— Methodsets the fitness value of each individual to rand()
Cambrian.random_selection
— Methodreturn a random individual from a population
Cambrian.run!
— MethodCall step!(e) e.config.n_gen times consecutively
Cambrian.save_gen
— Methodsave the population in gens/
Cambrian.step!
— MethodThe 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.
Cambrian.tournament_selection
— Methodreturn a winner individual from a tournament of size t_size from a population