Documentation ¶
Index ¶
- Variables
- func Activate(x float64, a Activation) float64
- func Clone[T Cloneable](obj T) T
- func SelectNGenotypes[T any](selection Selection[T], n int) []T
- type Activation
- type Agent
- type ArrayCrossoverAsexual
- type ArrayCrossoverKPoint
- type ArrayCrossoverUniform
- type ArrayGenotype
- type ArrayMutationRandomBool
- type ArrayMutationRandomRune
- type ArrayMutationStd
- type Buildable
- type Cloneable
- type Counter
- type Crossover
- type EliteSelection
- type Forwarder
- type GeneticDistance
- type HillClimberPopulation
- type Mutation
- type NeatCrossoverAsexual
- type NeatCrossoverSimple
- type NeatGenotype
- func (g *NeatGenotype) AddRandomNeuron(counter *Counter, activations ...Activation) bool
- func (g *NeatGenotype) AddRandomSynapse(counter *Counter, weightStd float64, recurrent bool) bool
- func (g *NeatGenotype) Build() Forwarder
- func (g *NeatGenotype) Clone() any
- func (g *NeatGenotype) MarshalJSON() ([]byte, error)
- func (g *NeatGenotype) MutateRandomActivation(activations ...Activation) bool
- func (g *NeatGenotype) MutateRandomSynapse(std float64) bool
- func (g *NeatGenotype) NumHiddenNeurons() int
- func (g *NeatGenotype) NumInputNeurons() int
- func (g *NeatGenotype) NumNeurons() int
- func (g *NeatGenotype) NumOutputNeurons() int
- func (g *NeatGenotype) NumSynapses() int
- func (g *NeatGenotype) RemoveRandomSynapse() bool
- func (g *NeatGenotype) RenderDot(width, height float64) string
- func (g *NeatGenotype) RenderImage(width, height float64) image.Image
- func (g *NeatGenotype) ResetRandomSynapse() bool
- func (g *NeatGenotype) UnmarshalJSON(bs []byte) error
- func (g *NeatGenotype) Validate() error
- type NeatMutationStd
- type NeatNeuronID
- type NeatPhenotype
- type NeatSynapseEP
- type NeatSynapseID
- type Population
- type Reproduction
- type Selection
- type SimplePopulation
- type SpeciatedPopulation
- type TournamentSelection
- type TwoPhaseReproduction
- type Validateable
Constants ¶
This section is empty.
Variables ¶
var AllActivations = []Activation{Relu, Linear, Sigmoid, Tanh, Sin, Cos, Binary, Reln, Relum, Sawtooth, Abs}
AllActivations is a list of all possible activations.
Functions ¶
func Activate ¶ added in v0.4.0
func Activate(x float64, a Activation) float64
Activate applies the activation function to the given value.
func Clone ¶ added in v0.4.2
func Clone[T Cloneable](obj T) T
Clone clones an object that implements the Cloneable interface. It also casts the child object to the type of the parent object.
func SelectNGenotypes ¶ added in v0.4.2
SelectNGenotypes selects n genotypes from the given selection strategy, returning them in a slice.
Types ¶
type Activation ¶
type Activation int
Activation is an enum representing the different activation functions that can be used in a neural network.
const ( Relu Activation = iota Linear Sigmoid Tanh Sin Cos Binary Relum Reln Sawtooth Abs )
func (Activation) MarshalJSON ¶ added in v0.4.0
func (a Activation) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (Activation) String ¶ added in v0.4.0
func (a Activation) String() string
String returns the string representation of the activation.
func (*Activation) UnmarshalJSON ¶ added in v0.4.0
func (a *Activation) UnmarshalJSON(bs []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Agent ¶ added in v0.2.0
Agent is a container for a genotype and its fitness. The genotype can be of any type.
type ArrayCrossoverAsexual ¶ added in v0.5.0
type ArrayCrossoverAsexual[T any] struct{}
ArrayCrossoverAsexual is a crossover strategy that clones the parent. It only requires one parent.
func (*ArrayCrossoverAsexual[T]) Crossover ¶ added in v0.5.0
func (p *ArrayCrossoverAsexual[T]) Crossover(gs []*ArrayGenotype[T]) *ArrayGenotype[T]
Crossover implements CrossoverStrategy.
func (*ArrayCrossoverAsexual[T]) NumParents ¶ added in v0.5.0
func (p *ArrayCrossoverAsexual[T]) NumParents() int
NumParents implements CrossoverStrategy.
type ArrayCrossoverKPoint ¶ added in v0.5.0
ArrayCrossoverKPoint is a crossover strategy that selects K locations in the genome to switch parents. It requires two parents.
func (*ArrayCrossoverKPoint[T]) Crossover ¶ added in v0.5.0
func (p *ArrayCrossoverKPoint[T]) Crossover(gs []*ArrayGenotype[T]) *ArrayGenotype[T]
func (*ArrayCrossoverKPoint[T]) NumParents ¶ added in v0.5.0
func (p *ArrayCrossoverKPoint[T]) NumParents() int
type ArrayCrossoverUniform ¶ added in v0.5.0
type ArrayCrossoverUniform[T any] struct{}
ArrayCrossoverUniform is a crossover strategy that selects each gene from one of the parents with equal probability. The location of a gene has no effect on the probability of it being selected from either parent. It requires two parents.
func (*ArrayCrossoverUniform[T]) Crossover ¶ added in v0.5.0
func (p *ArrayCrossoverUniform[T]) Crossover(gs []*ArrayGenotype[T]) *ArrayGenotype[T]
Crossover implements CrossoverStrategy.
func (*ArrayCrossoverUniform[T]) NumParents ¶ added in v0.5.0
func (p *ArrayCrossoverUniform[T]) NumParents() int
NumParents implements CrossoverStrategy.
type ArrayGenotype ¶ added in v0.5.0
type ArrayGenotype[T any] struct { Values []T }
ArrayGenotype is a genotype that is a slice of values.
func NewBoolArrayGenotype ¶ added in v0.5.0
func NewBoolArrayGenotype(size int) *ArrayGenotype[bool]
NewBoolArrayGenotype creates a new genotype with the given size, where each value is a random boolean.
func NewFloatArrayGenotype ¶ added in v0.5.0
func NewFloatArrayGenotype[T floatType](size int, std T) *ArrayGenotype[T]
NewFloatArrayGenotype creates a new genotype with the given size, where each value is a random float (of type T) with a normal distribution with the given standard deviation.
func NewRuneArrayGenotype ¶ added in v0.5.0
func NewRuneArrayGenotype(size int, runeset []rune) *ArrayGenotype[rune]
NewRuneArrayGenotype creates a new genotype with the given size, where each value is a random rune from the given runeset.
func (ArrayGenotype[T]) Clone ¶ added in v0.5.0
func (g ArrayGenotype[T]) Clone() any
Clone returns a new genotype that is a copy of this genotype.
type ArrayMutationRandomBool ¶ added in v0.5.0
type ArrayMutationRandomBool struct { // The probability of mutating each locus MutateProbability float64 }
func (*ArrayMutationRandomBool) Mutate ¶ added in v0.5.0
func (s *ArrayMutationRandomBool) Mutate(gt *ArrayGenotype[bool])
type ArrayMutationRandomRune ¶ added in v0.5.0
type ArrayMutationRandomRune struct { // The probability of mutating each locus MutateProbability float64 // The standard deviation for the mutation Runeset []rune }
func (*ArrayMutationRandomRune) Mutate ¶ added in v0.5.0
func (s *ArrayMutationRandomRune) Mutate(gt *ArrayGenotype[rune])
type ArrayMutationStd ¶ added in v0.5.0
type ArrayMutationStd[T floatType] struct { // The probability of mutating each locus MutateProbability T // The standard deviation for the mutation MutateStd T }
func (*ArrayMutationStd[T]) Mutate ¶ added in v0.5.0
func (s *ArrayMutationStd[T]) Mutate(gt *ArrayGenotype[T])
type Buildable ¶ added in v0.4.2
type Buildable interface { // Build converts this genotype into a [Forwarder]. // This may be an expensive operation, so it should be called sparingly. Build() Forwarder }
Buildable is an interface that defines a method to build a Forwarder. If the genotype is already a Forwarder, it should return itself.
type Cloneable ¶ added in v0.4.2
type Cloneable interface {
Clone() any
}
Cloneable is an interface that must be implemented by any object that wants to be cloned. The clone method must return a new object that is a deep copy of the original object. This new method is typed as any. To clone while including the type, use Clone, which is generic so will perform the cast.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a simple counter that can be used to generate unique IDs.
func NewCounter ¶ added in v0.4.0
func NewCounter() *Counter
NewCounter creates a new counter, starting at 0.
type Crossover ¶ added in v0.5.0
type Crossover[T any] interface { // Crossover performs a crossover with this strategy on the given genotypes. // It can combine any number of genotypes (for example 1 for asexual, 2 for sexual, n for averaging of multiple?) Crossover([]T) T // NumParents returns the number of parents required for this crossover strategy NumParents() int }
Crossover is an interface for a crossover strategy on a genotype with type T.
type EliteSelection ¶ added in v0.5.0
type EliteSelection[T any] struct { // contains filtered or unexported fields }
func (*EliteSelection[T]) Select ¶ added in v0.5.0
func (s *EliteSelection[T]) Select() *Agent[T]
func (*EliteSelection[T]) SetAgents ¶ added in v0.5.0
func (s *EliteSelection[T]) SetAgents(agents []*Agent[T])
type Forwarder ¶ added in v0.3.0
type Forwarder interface { // Forward takes a set of inputs and returns a set of outputs. Forward([]float64) []float64 }
Forwarder is an interface for somthing that can take a set of inputs ([]float64) and return a set of outputs. It can be thought of as a function with a vector input and output.
type GeneticDistance ¶ added in v0.2.0
type GeneticDistance[T any] interface { // DistanceBetween calculates the genetic distance between two genotypes. DistanceBetween(a, b T) float64 }
GeneticDistance is an interface for calculating the genetic distance between two genotypes.
type HillClimberPopulation ¶ added in v0.5.0
type HillClimberPopulation[T any] struct { A *Agent[T] B *Agent[T] Selection Selection[T] Reproduction Reproduction[T] }
func NewHillClimberPopulation ¶ added in v0.5.0
func NewHillClimberPopulation[T any](initialA, initialB T, selection Selection[T], reproduction Reproduction[T]) *HillClimberPopulation[T]
func (*HillClimberPopulation[T]) All ¶ added in v0.5.0
func (p *HillClimberPopulation[T]) All() []*Agent[T]
func (*HillClimberPopulation[T]) NextGeneration ¶ added in v0.5.0
func (p *HillClimberPopulation[T]) NextGeneration() Population[T]
type Mutation ¶ added in v0.5.0
type Mutation[T any] interface { // Mutate performs a mutation in-place with this strategy on the given genotype Mutate(T) }
Mutation is an interface for a mutation strategy on a genotype with type T.
type NeatCrossoverAsexual ¶ added in v0.5.0
type NeatCrossoverAsexual struct{}
func (*NeatCrossoverAsexual) Crossover ¶ added in v0.5.0
func (s *NeatCrossoverAsexual) Crossover(gs []*NeatGenotype) *NeatGenotype
func (*NeatCrossoverAsexual) NumParents ¶ added in v0.5.0
func (s *NeatCrossoverAsexual) NumParents() int
type NeatCrossoverSimple ¶ added in v0.5.0
type NeatCrossoverSimple struct{}
func (*NeatCrossoverSimple) Crossover ¶ added in v0.5.0
func (s *NeatCrossoverSimple) Crossover(gs []*NeatGenotype) *NeatGenotype
Crossover implements CrossoverStrategy.
func (*NeatCrossoverSimple) NumParents ¶ added in v0.5.0
func (s *NeatCrossoverSimple) NumParents() int
NumParents implements CrossoverStrategy.
type NeatGenotype ¶ added in v0.5.0
type NeatGenotype struct {
// contains filtered or unexported fields
}
NeatGenotype is a genotype for a neural network using the NEAT algorithm. It is conceptually similar to the DNA of an organism: it encodes how to build a neural network, but is not the neural network itself. This means if you want to actually run the neural network, you need to use the NeatGenotype.Build method to create a NeatPhenotype.
func NewNeatGenotype ¶ added in v0.5.0
func NewNeatGenotype(counter *Counter, inputs, outputs int, outputActivation Activation) *NeatGenotype
NewNeatGenotype creates a new NEATGenotype with the given number of inputs and outputs, and the given output activation function. All output neurons will have the same activation function, and all input neurons will have the linear activation function. The genotype will have no synapses.
func (*NeatGenotype) AddRandomNeuron ¶ added in v0.5.0
func (g *NeatGenotype) AddRandomNeuron(counter *Counter, activations ...Activation) bool
AddRandomNeuron adds a new neuron to the genotype on a random forward synapse. It will return false if there are no forward synapses to add to. The new neuron will have a random activation function from the given list of activations.
func (*NeatGenotype) AddRandomSynapse ¶ added in v0.5.0
func (g *NeatGenotype) AddRandomSynapse(counter *Counter, weightStd float64, recurrent bool) bool
AddRandomSynapse adds a new synapse to the genotype between two nodes. It will return false if it failed to find a place to put the synapse after 10 tries. The synapse will have a random weight from a normal distribution with the given standard deviation. If recurrent is true, the synapse will be recurrent, otherwise it will not.
func (*NeatGenotype) Build ¶ added in v0.5.0
func (g *NeatGenotype) Build() Forwarder
Build a NEATPhenotype from a NEATGenotype.
func (*NeatGenotype) Clone ¶ added in v0.5.0
func (g *NeatGenotype) Clone() any
Clone returns a new genotype that is an exact copy of this genotype.
func (*NeatGenotype) MarshalJSON ¶ added in v0.5.0
func (g *NeatGenotype) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler, allowing the genotype to be marshalled to JSON.
func (*NeatGenotype) MutateRandomActivation ¶ added in v0.5.0
func (g *NeatGenotype) MutateRandomActivation(activations ...Activation) bool
MutateRandomActivation will change the activation function of a random hidden neuron to a random activation function from the given list of activations. It will return false if there are no hidden neurons to mutate.
func (*NeatGenotype) MutateRandomSynapse ¶ added in v0.5.0
func (g *NeatGenotype) MutateRandomSynapse(std float64) bool
MutateRandomSynapse will change the weight of a random synapse by a random amount from a normal distribution with the given standard deviation. It will return false if there are no synapses to mutate.
func (*NeatGenotype) NumHiddenNeurons ¶ added in v0.5.0
func (g *NeatGenotype) NumHiddenNeurons() int
NumHiddenNeurons returns the number of hidden neurons in the genotype.
func (*NeatGenotype) NumInputNeurons ¶ added in v0.5.0
func (g *NeatGenotype) NumInputNeurons() int
NumInputNeurons returns the number of input neurons in the genotype.
func (*NeatGenotype) NumNeurons ¶ added in v0.5.0
func (g *NeatGenotype) NumNeurons() int
NumNeurons returns the total number of neurons in the genotype.
func (*NeatGenotype) NumOutputNeurons ¶ added in v0.5.0
func (g *NeatGenotype) NumOutputNeurons() int
NumOutputNeurons returns the number of output neurons in the genotype.
func (*NeatGenotype) NumSynapses ¶ added in v0.5.0
func (g *NeatGenotype) NumSynapses() int
NumSynapses returns the total number of synapses in the genotype.
func (*NeatGenotype) RemoveRandomSynapse ¶ added in v0.5.0
func (g *NeatGenotype) RemoveRandomSynapse() bool
RemoveRandomSynapse will remove a random synapse from the genotype. It will return false if there are no synapses to remove.
func (*NeatGenotype) RenderDot ¶ added in v0.5.0
func (g *NeatGenotype) RenderDot(width, height float64) string
RenderDot returns a string in the DOT language that represents the genotype. This DOT code cannot be use to recreate the genotype, but can be used to visualise it using Graphviz.
func (*NeatGenotype) RenderImage ¶ added in v0.5.0
func (g *NeatGenotype) RenderImage(width, height float64) image.Image
RenderImage returns an image of the genotype using graphviz.
func (*NeatGenotype) ResetRandomSynapse ¶ added in v0.5.0
func (g *NeatGenotype) ResetRandomSynapse() bool
ResetRandomSynapse will reset the weight of a random synapse to 0. It will return false if there are no synapses to reset.
func (*NeatGenotype) UnmarshalJSON ¶ added in v0.5.0
func (g *NeatGenotype) UnmarshalJSON(bs []byte) error
UnmarshalJSON implements json.Unmarshaler, allowing the genotype to be unmarshalled from JSON.
TODO(Needs more validation)
func (*NeatGenotype) Validate ¶ added in v0.5.0
func (g *NeatGenotype) Validate() error
Validate runs as many checks as possible to check the genotype is valid. It is really only designed to be used as part of a test suite to catch errors with the package. This should never throw an error, but if it does either there is a bug in the package, or the user has somehow invalidated the genotype.
type NeatMutationStd ¶ added in v0.5.0
type NeatMutationStd struct { // The standard deviation for the number of new synapses StdNumNewSynapses float64 // The standard deviation for the number of new recurrent synapses StdNumNewRecurrentSynapses float64 // The standard deviation for the number of new neurons StdNumNewNeurons float64 // The standard deviation for the number of synapses to mutate StdNumMutateSynapses float64 // The standard deviation for the number of synapses to prune StdNumPruneSynapses float64 // The standard deviation for the number of activations to mutate StdNumMutateActivations float64 // The standard deviation for the weight of new synapses StdNewSynapseWeight float64 // The standard deviation for the weight of mutated synapses StdMutateSynapseWeight float64 // The maximum number of hidden neurons this mutation can add MaxHiddenNeurons int // The counter to use for new synapse IDs Counter *Counter // The possible activations to use for new neurons PossibleActivations []Activation }
NeatMutationStd is a reproduction strategy that uses a standard deviation for the number of mutations in each category. The standard deviation is not scaled by the size of the network, meaning that larger networks will tend to have more mutations than smaller networks.
func (*NeatMutationStd) Mutate ¶ added in v0.5.0
func (r *NeatMutationStd) Mutate(g *NeatGenotype)
Reproduce creates a new genotype by crossing over and mutating the given genotypes.
type NeatNeuronID ¶ added in v0.5.0
type NeatNeuronID int
NeatNeuronID is the unique identifier for a neuron in a NEATGenotype
type NeatPhenotype ¶ added in v0.5.0
type NeatPhenotype struct {
// contains filtered or unexported fields
}
NeatPhenotype is a phenotype for a NEAT genotype. It conceptually represents a neural network, built according to the instructions in the NEATGenotype (DNA). Once built, the NeatPhenotype can be used to forward propagate inputs through the network, but it cannot be modified though mutation or corss-over.
func (*NeatPhenotype) Forward ¶ added in v0.5.0
func (p *NeatPhenotype) Forward(x []float64) []float64
Forward propagate inputs through the network, returning the resulting outputs.
func (*NeatPhenotype) Reset ¶ added in v0.5.0
func (p *NeatPhenotype) Reset()
Reset will clear the recurrent memories of the phenotype.
type NeatSynapseEP ¶ added in v0.5.0
type NeatSynapseEP struct { From NeatNeuronID To NeatNeuronID }
NeatSynapseEP is the endpoints of a synapse in a NEATGenotype
type NeatSynapseID ¶ added in v0.5.0
type NeatSynapseID int
NeatSynapseID is the unique identifier for a synapse in a NEATGenotype
type Population ¶ added in v0.4.2
type Population[T any] interface { // NextGeneration returns the population resulting from agents selected using this population's selection strategy // reproducing using this population's reproduction strategy. NextGeneration() Population[T] // All returns every [Agent] in the population. // This may have no particular order. All() []*Agent[T] }
Population is an interface for a population with genotypes with type T. It stores its genotypes wrapped in the Agent struct, to keep track of fitness. The population may also store a reference to a Reproduction and a Selection to be used in the [NextGeneration] method.
type Reproduction ¶ added in v0.4.0
type Reproduction[T any] interface { // Reproduce takes a set of parent genotypes and returns a child genotype. Reproduce([]T) T // NumParents returns the number of parents required for this reproduction strategy NumParents() int }
Reproduction is an interface for a reproduction strategy on a genotype with type T. Most of the time, this will be a TwoPhaseReproduction, however it is possible to imlement a custom one for more complex behaviour.
type Selection ¶ added in v0.4.0
type Selection[T any] interface { // SetAgents caches the [Agent]s which this selection will use until it is called again. // This is called once per generation. You may wish to perform slow operations here such as sorting by fitness. SetAgents(agents []*Agent[T]) // Select returns an [Agent] selected from the cached pool set by [SelectionStrategy.SetAgents]. Select() *Agent[T] }
Selection is a strategy for selecting an Agent from a slice. It acts on agents of type T.
type SimplePopulation ¶ added in v0.5.0
type SimplePopulation[T any] struct { Agents []*Agent[T] Selection Selection[T] Reproduction Reproduction[T] }
SimplePopulation has a single species, and generates the entire next generation by selcting and breeding from the previous one.
func NewSimplePopulation ¶ added in v0.5.0
func NewSimplePopulation[T any](newGenotype func() T, n int, selection Selection[T], reproduction Reproduction[T]) *SimplePopulation[T]
NewSimplePopulation creates a new SimplePopulation with n agents, each with a new genotype created by newGenotype.
func (*SimplePopulation[T]) All ¶ added in v0.5.0
func (p *SimplePopulation[T]) All() []*Agent[T]
Agents returns the agents in the population.
TODO(change this to an iterator once they get added to the language, as this will increase performance in other cases)
func (*SimplePopulation[T]) NextGeneration ¶ added in v0.5.0
func (p *SimplePopulation[T]) NextGeneration() Population[T]
NextGeneration creates a new SimplePopulation from the current one, using the given selection and reproduction strategies.
type SpeciatedPopulation ¶ added in v0.5.0
type SpeciatedPopulation[T any] struct { // Species is a map of species ID to a slice of agents. Species map[int][]*Agent[T] // RemoveWorstSpeciesChance is the chance that the worst species will be removed each generation. RemoveWorstSpeciesChance float64 // StdNumAgentsSwap is the standard deviation of the number of agents to swap between species each generation. // An agent is swapped by moving it to another random species, and moving another agent from that species to this species. StdNumAgentsSwap float64 // Counter is a counter to keep track of the new species. Counter *Counter // The selection strategy to use when selecting agents to reproduce. Selection Selection[T] // The reproduction strategy to use when creating new agents. Reproduction Reproduction[T] }
SpeciatedPopulation is a speciated population of agents. Each species has the same number of agents, and there are always the same number of species. Each generation, with a chance, the worst species is removed, and replaced with a random species or the best species.
func NewSpeciatedPopulation ¶ added in v0.5.0
func NewSpeciatedPopulation[T any](counter *Counter, newGenotype func() T, numSpecies, numAgentsPerSpecies int, removeWorstSpeciesChance, stdNumAgentsSwap float64, selection Selection[T], reproduction Reproduction[T]) *SpeciatedPopulation[T]
NewSpeciatedPopulation creates a new speciated population.
func (*SpeciatedPopulation[T]) All ¶ added in v0.5.0
func (p *SpeciatedPopulation[T]) All() []*Agent[T]
All implements Population.
func (*SpeciatedPopulation[T]) NextGeneration ¶ added in v0.5.0
func (p *SpeciatedPopulation[T]) NextGeneration() Population[T]
NextGeneration implements Population.
type TournamentSelection ¶ added in v0.5.0
type TournamentSelection[T any] struct { // The number of agents to include in each tournament. TournamentSize int // contains filtered or unexported fields }
TournamentSelection is a TournamentSelection strategy that selects the best agent from a random tournament of agents. It implements TournamentSelection.
func (*TournamentSelection[T]) Select ¶ added in v0.5.0
func (t *TournamentSelection[T]) Select() *Agent[T]
Select returns an agent selected from the population using a tournament.
func (*TournamentSelection[T]) SetAgents ¶ added in v0.5.0
func (t *TournamentSelection[T]) SetAgents(agents []*Agent[T])
SetAgents sets the agents to select from for this generation.
type TwoPhaseReproduction ¶ added in v0.5.0
TwoPhaseReproduction is a Reproduction that first performs a Crossover and then a Mutation on the resulting child.
func NewTwoPhaseReproduction ¶ added in v0.5.0
func NewTwoPhaseReproduction[T any](crossover Crossover[T], mutate Mutation[T]) *TwoPhaseReproduction[T]
NewTwoPhaseReproduction creates a new TwoPhaseReproduction with the given Crossover and Mutation.
func (*TwoPhaseReproduction[T]) NumParents ¶ added in v0.5.0
func (r *TwoPhaseReproduction[T]) NumParents() int
NumParents implements the Reproduction interface.
func (*TwoPhaseReproduction[T]) Reproduce ¶ added in v0.5.0
func (r *TwoPhaseReproduction[T]) Reproduce(parents []T) T
Reproduce implements the Reproduction interface.
type Validateable ¶ added in v0.5.0
type Validateable interface { // Validate checks if the object is valid. // If the object is valid, it should return nil. // If the object is invalid, it should return an error. Validate() error }
Validateable is an interface for types that can be validated. For example, you can check if a neat genotype actually contains all neurons that are used by each synapse. This is aimed to be used for either tests, or validating loaded data.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
geno
|
|
arr
Module
|
|
floatarr
Module
|
|
neat
Module
|
|
pop
|
|
hillclimber
Module
|
|
simple
Module
|
|
speciated
Module
|
|
selec
|
|
elite
Module
|
|
tournament
Module
|