Documentation
¶
Overview ¶
Evo is a framework for implementing evolutionary algorithms in Go.
Evo exposes a clean and flexible API oriented around two interfaces: `Genome` and `Population`. Genomes represent candidate solutions to the user's problem and are implemented by the user. Genomes define their own means of evolution, allowing for a multiplicity of techniques ranging from genetic algorithms to evolution strategies and beyond. Populations represent the architecture under which genomes are evolved. Multiple population types are provided by Evo to enable the construction of both common and novel architectures.
The body of the evolutionary loop is defined by the Evolve method of the Genome type being evolved. For each genome in a population, the Evolve method is called, receiving some subset of the population, called the suitors, as arguments. The Evolve method then applies operators to the suiters (selection, mutation, etc) and returns a genome that will replace the caller within the population for the next iteration. The concrete genome type is problem specific and defined by the user, while common operators for a variety of domains are provided as subpackages of Evo.
Populations orchestrate the evolution of genomes. A few different population types are provided by Evo under the package `evo/pop`. Populations themselves implement the Genome interface, making them composeable. The Evolve method of the builtin populations implements uniform random migration: A random population is chosen from the pool of suitors. Then the first population and its suitor exchange random members. This allows novel architectures like the island model to be implemented by nesting populations.
Index ¶
- type Genome
- type Iterator
- type Population
- type Stats
- func (s Stats) Count() int
- func (s Stats) Max() float64
- func (s Stats) Mean() float64
- func (s Stats) Merge(t Stats) Stats
- func (s Stats) Min() float64
- func (s Stats) Put(x float64) Stats
- func (s Stats) RSD() float64
- func (s Stats) Range() float64
- func (s Stats) SD() float64
- func (s Stats) String() string
- func (s Stats) Var() float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Genome ¶
Genomes represent candidate solutions and are implemented by the user. Your genome type defines the inner loop of the evolutionary algorithm as the Evolve method: For each genome in a population, the Evolve method is called, passing some subset of the population, called the suitors, as arguments. The value returned is will replace the caller within the population. In a typical geneticl algorithm, the Evolve method will select one or more parents from the suiters, apply some kind of recombination operator to generate a new child genome, possibly apply a mutation operator, and return the child. A more complicated replacement scheme may require coordinating with other genomes in the population.
Genomes may implement two optional methods, Fitness and Close. The Fitness method has no effect on the population, but may be used by helper methods included within Evo. The Stats method of the Population type returns statistics of the population's fitness, thus Fitness must be non-trivial to use this feature. You may simply return 0 if you do not wish to implement Fitness.
The Close method will be registered as a finalizer on the genome. This can be used to recycle memory from dying genomes to newborn genomes. The Close method is not guarenteed to be called. See https://godoc.org/runtime#SetFinalizer
Genomes must be pointer types.
type Iterator ¶
type Iterator interface {
Value() Genome
Next()
}
Iterators iterate over the genomes in a population and are returned by Population.Iter().
The Value method returns the current Genome pointed to by the iterator, or nil if the iterator has reached the end of the population.
The Next method advances the iterator.
To iterate over a population:
for i := pop.Iter(); i.Value() != nil; i.Next() {
// do something with i.Value()
}
type Population ¶
type Population interface {
Genome
// The Start method starts evolving the population in a separate goroutine.
// Use the Close method to stop.
Start()
// SetDelay sets a delay between each iteration of the evolution loop.
SetDelay(time.Duration)
// The Stats method returns statistics about the fitness of genomes in the
// population.
Stats() Stats
// The Iter method returns an iterator over the genomes in the population.
// If called on a meta-population, i.e. one whose members are themselves
// populations, then the iterator walks over the leaf-level genomes.
Iter() Iterator
}
Populations orchestrate the evolution of genomes.
Populations are composable, i.e. the can be used as Genomes in other populations. The Evolve method implements a migration between the method receiver and one or more populations in the mating pool. Architectures like the island model can be implemented by nesting populations.
The builtin populations live in the package evo/pop.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
A Stats object is a statistics collector. A common source of Stats objects is the return value of Population.Stats() which gives statistics about the fitness of genomes in the population.
func (Stats) RSD ¶
RSD returns the population relative standard deviation of the data, also known as the coefficient of variation.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package perm provides common operators and helpers for integer permutations.
|
Package perm provides common operators and helpers for integer permutations. |
|
pop
|
|
|
gen
Package gen provides a traditional generational population.
|
Package gen provides a traditional generational population. |
|
graph
Package graph provides a spatial population for diffusion and island models.
|
Package graph provides a spatial population for diffusion and island models. |
|
Package sel provides helpers for different selection techniques.
|
Package sel provides helpers for different selection techniques. |