evo

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2016 License: GPL-3.0, LGPL-3.0 Imports: 3 Imported by: 6

README

Evo

Evo is a framework for implementing evolutionary algorithms in Go.

go get github.com/cbarrick/evo

Documentation

https://godoc.org/github.com/cbarrick/evo

Status & Contributing

Evo is a general framework for developing genetic algorithms and more. It began life in fall 2015 as I studied evolutionary algorithms as an undergrad.

Contributions are welcome! I am currently a student and inexperienced maintainer, so please bear with me as I learn. The focus of the project thus far has been on the API design and less on performance. I am particularly interested in hearing about use-cases that are not well covered and success stories of where Evo excels. Testing, code reviews, and performance audits are always welcome and needed.

Examples

You can browse example problems in the example subpackage. The examples are maintained as a development tool rather than to provide optimal solutions to the problems they tackle. Reading the examples should give you a good idea of how easy it is to write code with Evo.

License (LGPL)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

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 both the function being optimized and the representation of solutions. 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 an evolve function. For each genome in a population, the evolve function is called, receiving some subset of the population, called the suitors, as arguments. The evolve function then applies the user's variation operators (selection, mutation, etc) and returns a genome for the next iteration. common operators for a variety of representations are provided as subpackages of Evo.

Populations model the evolution patterns 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. Migration functions are provided to be used in this context, allowing go novel architectures like the island model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConditionFn added in v0.2.0

type ConditionFn func() bool

A ConditionFn describes a termination condition.

type EvolveFn added in v0.2.0

type EvolveFn func(current Genome, suitors []Genome) (replacement Genome)

An EvolveFn describes an iteration of the evolution loop. The evolve function is called once for each member of the population, possibly in parrallel, and is responsible for producing new Genomes given some subset of the population, called the suitors. The replacement Genome replaces the current Genome within the population.

type Genome

type Genome interface {
	// The Fitness method is the function being maximized.
	// For minimization problems, return the negative or the inverse.
	Fitness() float64
}

A Genome describes the function being optimized and the representation of solutions. Genomes are provided by the user, and Evo provides convenience packages for common representations.

type Population

type Population interface {
	// Fitness returns the maximum fitness of the population.
	Fitness() float64

	// Evolve starts the evolution of the population in a separate goroutine.
	// Genomes are evolved in place; it is not safe to access the genome slice
	// while the evolution is running.
	Evolve([]Genome, EvolveFn)

	// Stop terminates the optimization.
	Stop()

	// Poll executes a function at some frequency for the duration of the
	// current optimization. If the function returns true, the current
	// optimization is halted. Use a frequency of 0 for continuous polling.
	Poll(freq time.Duration, cond ConditionFn)

	// Wait blocks until the evolution terminates.
	Wait()

	// Stats returns various statistics about the population.
	Stats() Stats
}

A Population models the interaction between Genomes during evolution. In practice, this determines the kind of parallelism and number of suitors during the optimization.

Populations implement Genome, making them composable. For example, an island model can be built by composing generational populations into a graph population.

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) Count

func (s Stats) Count() int

Count returns the size of the data.

func (Stats) Max

func (s Stats) Max() float64

Max returns the maximum data point.

func (Stats) Mean

func (s Stats) Mean() float64

Mean returns the average of the data.

func (Stats) Merge

func (s Stats) Merge(t Stats) Stats

Merge merges the data of two Stats objects.

func (Stats) Min

func (s Stats) Min() float64

Min returns the minimum data point.

func (Stats) Put

func (s Stats) Put(x float64) Stats

Put inserts a new value into the data.

func (Stats) RSD

func (s Stats) RSD() float64

RSD returns the population relative standard deviation of the data, also known as the coefficient of variation.

func (Stats) Range

func (s Stats) Range() float64

Range returns the difference in the maximum and minimum data points.

func (Stats) SD

func (s Stats) SD() float64

SD returns the population standard deviation of the data.

func (Stats) String

func (s Stats) String() string

String returns a string listing a summary of the statistics.

func (Stats) Var

func (s Stats) Var() float64

Var returns the population variance of the data.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL