Documentation ¶
Overview ¶
Copyright (c) 2015, Brian Hummer (brian@redq.me) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- Variables
- func DirectActivation(x float64) float64
- func InverseAbsActivation(x float64) float64
- func Run(e *Experiment) error
- func SigmoidActivation(x float64) float64
- func SteependSigmoidActivation(x float64) float64
- func TanhActivation(x float64) float64
- type ActivationType
- type Archiver
- type Behaviorable
- type Comparer
- type Connection
- type Connections
- type Context
- type Contextable
- type Crosser
- type Crossoverable
- type Decoder
- type Demonstrable
- type Evaluator
- type Experiment
- type ExperimentSettings
- type FitnessType
- type Generator
- type Genome
- type Genomes
- type Improvable
- type InnoKey
- type InnoType
- type Mutator
- type Network
- type NeuronType
- type Node
- type Nodes
- type OriginalFitnessable
- type Phenomable
- type Phenome
- type Phenomes
- type Populatable
- type Population
- type Restorer
- type Result
- type Results
- type Searcher
- type Setupable
- type Speciater
- type Species
- type Takedownable
- type Trait
- type Traits
- type Trialable
- type Visualizer
Constants ¶
This section is empty.
Variables ¶
var (
Activations []ActivationType = []ActivationType{SteependSigmoid, Sigmoid, Tanh, InverseAbs}
)
Functions ¶
func DirectActivation ¶
func InverseAbsActivation ¶
func Run ¶
func Run(e *Experiment) error
Runs a configured experiment. If restoring, including just the configuration, this must be done prior to calling Run.
func SigmoidActivation ¶
func TanhActivation ¶
Types ¶
type ActivationType ¶
type ActivationType byte
const ( Direct ActivationType = iota + 1 // 1 SteependSigmoid // 2 Sigmoid // 3 Tanh // 4 InverseAbs // 5 )
func (ActivationType) Range ¶
func (a ActivationType) Range() (float64, float64)
func (ActivationType) String ¶
func (a ActivationType) String() string
type Archiver ¶
type Archiver interface { // Archives the current configuration and state to a more permanent medium Archive(Context) error }
Helper which provides access to archive storage
type Behaviorable ¶
type Behaviorable interface { // Returns the expressed behaviors Behavior() []float64 }
Behaviorable describes an item tracks behaviors expressed during evaluation
type Comparer ¶
type Comparer interface { // Returns the compatibility (similarity) between two genomes Compare(g1, g2 Genome) (float64, error) }
Helper to compare two genomes similarity
type Connection ¶
type Connection struct { Innovation int // Innovation number for this connection Source, Target int // Innovation numbers of the source and target nodes Weight float64 // Connection weight Enabled bool // Is this connection enabled? }
Definition of a synapse
func (Connection) Key ¶
func (c Connection) Key() (k InnoKey)
func (Connection) String ¶
func (c Connection) String() string
type Connections ¶
type Connections map[int]Connection
func (Connections) MarshalJSON ¶
func (cm Connections) MarshalJSON() ([]byte, error)
func (*Connections) UnmarshalJSON ¶
func (cm *Connections) UnmarshalJSON(data []byte) error
type Context ¶
type Context interface { // Component helpers Archiver() Archiver Comparer() Comparer Crosser() Crosser Decoder() Decoder Evaluator() Evaluator Generator() Generator Mutator() Mutator Searcher() Searcher Speciater() Speciater Visualizer() Visualizer // State is a registry of elements to be persisted State() map[string]interface{} // Returns the next ID in the sequence NextID() int // Returns the innovation number for the gene Innovation(t InnoType, k InnoKey) int }
type Contextable ¶
Contextable describes an item that can receive a context
type Crosser ¶
type Crosser interface { // Returns new genome that is a cross between two genomes Cross(g1, g2 Genome) (Genome, error) }
Helper to produce new genome
type Crossoverable ¶
type Decoder ¶
type Decoder interface { // Returns a decoded version of the genome Decode(Genome) (Phenome, error) }
Helper to decode a genome into a phenome
type Demonstrable ¶
type Demonstrable interface { // ShowWork toggles the flag informing the helper to show (or) not the details during execution ShowWork(bool) }
Demonstrable indicates that a helper is capable of showing (or hiding) detail of its work during execution. This is typically employed by an evaluator and turned on when evaluating the "best" genome after the evolution is completed.
type Experiment ¶
type Experiment struct { ExperimentSettings // contains filtered or unexported fields }
Experiment provides the definition of how to solve the problem using NEAT
func (Experiment) Context ¶
func (e Experiment) Context() Context
func (Experiment) Iteration ¶
func (e Experiment) Iteration() int
func (Experiment) Population ¶
func (e Experiment) Population() Population
func (*Experiment) SetContext ¶
func (e *Experiment) SetContext(x Context) error
func (Experiment) Stopped ¶
func (e Experiment) Stopped() bool
func (Experiment) String ¶
func (e Experiment) String() string
String returns a description of the experiment
type ExperimentSettings ¶
type ExperimentSettings interface { Iterations() int Traits() Traits FitnessType() FitnessType ExperimentName() string }
type FitnessType ¶
type FitnessType byte
const ( Absolute FitnessType = iota + 1 // 1 Relative // 2 )
func (FitnessType) String ¶
func (f FitnessType) String() string
type Generator ¶
type Generator interface { // Generates a subsequent population based on the current one Generate(curr Population) (next Population, err error) }
A helper to generate populations
type Genome ¶
type Genome struct { ID int // Identifier for this genome SpeciesIdx int // Index of species in the population Nodes Nodes // Neuron definitions Conns Connections // Synapse definitions Traits []float64 // Trait values Fitness float64 // Fitness of genome as it relates to the problem itself Improvement float64 // Fitness of genome as it relates to the improvement of the population Birth int // Generation during which this genome was born }
An encoded solution
func (Genome) Complexity ¶
func (Genome) GenesByInnovation ¶
func (g Genome) GenesByInnovation() ([]Node, []Connection)
Returns the genome's genes by their markers
func (Genome) GenesByPosition ¶
func (g Genome) GenesByPosition() ([]Node, []Connection)
Returns the genome's genes by their keys
type Improvable ¶
type Improvable interface {
Improvement() float64
}
type Network ¶
type Network interface { // Activates the neural network using the inputs. Returns the ouput values. Activate(inputs []float64) (outputs []float64, err error) }
Represents a neural network
type NeuronType ¶
type NeuronType byte
const ( Bias NeuronType = iota + 1 // 1 Input // 2 Hidden // 3 Output // 4 )
func (NeuronType) String ¶
func (n NeuronType) String() string
type Node ¶
type Node struct { Innovation int X, Y float64 NeuronType ActivationType }
Definition of a neuron
type Nodes ¶
Nodes is a map of nodes by innovation number
func (Nodes) MarshalJSON ¶
MarshalJSON marshals the nodes map into JSON
func (*Nodes) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON into a nodes map
type OriginalFitnessable ¶
type OriginalFitnessable interface {
OriginalFitness() float64
}
type Phenomable ¶
A helper that would like to see the active phenomes
type Phenome ¶
type Phenome interface { ID() int // The identify of the underlying genome Traits() []float64 // Trait values which could be used during evaluation Network // The decoded genome }
A decoded solution
type Populatable ¶
type Populatable interface { // Provides the population to the helper SetPopulation(Population) error }
A helper that would like to see the population
type Population ¶
Population of genomes for a given generation
type Restorer ¶
type Restorer interface { // Restores the configuration and/or the state of a previous experiment Restore(Context) error }
Helper to restore an experiment
type Result ¶
type Result interface { ID() int // Returns the ID of the phenome Fitness() float64 // Returns the fitness of the phenome for the problem Err() error // Returns the error, if any, occuring while evaluating the phenome. Stop() bool // Returns true if the stop condition was met }
The result of an evaluation
type Searcher ¶
type Searcher interface { // Searches the problem's solution space using the phenomes Search([]Phenome) ([]Result, error) }
Helper to search the problem's solution space
type Setupable ¶
type Setupable interface { // Sets up the helper Setup() error }
Provides setup actions in the helper's lifestyle
type Speciater ¶
type Speciater interface { // Assigns the genomes to a species. Returns new collection of species. Speciate(curr []Species, genomes []Genome) (next []Species, err error) }
Helper to assign genomes to an exist or new species
type Takedownable ¶
type Takedownable interface { // Takes down the helper Takedown() error }
Provides takedown actions in the helper's lifecycle
type Visualizer ¶
type Visualizer interface { // Creates visual(s) of the population Visualize(Population) error }
Helper to visualize a population