Documentation ¶
Index ¶
- type Activation
- type Agent
- type Counter
- type Forwarder
- type Genotype
- func (g *Genotype) AddRandomNeuron(counter *Counter, activations ...Activation) bool
- func (g *Genotype) AddRandomSynapse(counter *Counter, weightStd float64, recurrent bool) bool
- func (g *Genotype) Build() *Phenotype
- func (g *Genotype) Clone() *Genotype
- func (g *Genotype) CrossoverWith(g2 *Genotype) *Genotype
- func (g *Genotype) Draw(width, height float64) image.Image
- func (g *Genotype) MarshalJSON() ([]byte, error)
- func (g *Genotype) MutateRandomActivation(activations ...Activation) bool
- func (g *Genotype) MutateRandomSynapse(std float64) bool
- func (g *Genotype) NumHiddenNeurons() int
- func (g *Genotype) NumInputNeurons() int
- func (g *Genotype) NumNeurons() int
- func (g *Genotype) NumOutputNeurons() int
- func (g *Genotype) NumSynapses() int
- func (g *Genotype) RemoveRandomSynapse() bool
- func (g *Genotype) ResetRandomSynapse() bool
- func (g *Genotype) UnmarshalJSON(bs []byte) error
- func (g *Genotype) Validate() error
- type NeuronID
- type Phenotype
- type Reproduction
- type Selection
- type SimplePopulation
- type StdReproduction
- type SynapseEP
- type SynapseID
- type TournamentSelection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activation ¶
type Activation int
const ( Relu Activation = iota Linear Sigmoid Tanh Sin Cos )
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
func (*Activation) UnmarshalJSON ¶ added in v0.4.0
func (a *Activation) UnmarshalJSON(bs []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func NewCounter ¶ added in v0.4.0
func NewCounter() *Counter
type Genotype ¶
type Genotype struct {
// contains filtered or unexported fields
}
Genotype represents the DNA of a creature. It is optimised for mutating, but cannot be run directly.
func NewGenotype ¶
func NewGenotype(counter *Counter, inputs, outputs int, outputActivation Activation) *Genotype
func (*Genotype) AddRandomNeuron ¶
func (g *Genotype) AddRandomNeuron(counter *Counter, activations ...Activation) bool
func (*Genotype) AddRandomSynapse ¶
func (*Genotype) CrossoverWith ¶
Simple crossover of the genotypes, where g is fitter than g2
func (*Genotype) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Genotype) MutateRandomActivation ¶
func (g *Genotype) MutateRandomActivation(activations ...Activation) bool
Change the activation of a rnadom HIDDEN neuron to one of the supplied activations
func (*Genotype) MutateRandomSynapse ¶
func (*Genotype) NumHiddenNeurons ¶
func (*Genotype) NumInputNeurons ¶
func (*Genotype) NumNeurons ¶
func (*Genotype) NumOutputNeurons ¶
func (*Genotype) NumSynapses ¶
func (*Genotype) RemoveRandomSynapse ¶
This will delete a random synapse. It will leave hanging neurons, because they may be useful later.
func (*Genotype) ResetRandomSynapse ¶
This will set the weight of a random synapse to 0. Kind of similar to disabling a synapse, which this implementation does not have.
func (*Genotype) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. TODO: needs more validation
func (*Genotype) Validate ¶
This will run 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 Reproduction ¶ added in v0.4.0
type SimplePopulation ¶ added in v0.5.0
type SimplePopulation struct {
// contains filtered or unexported fields
}
SimplePopulation has a single species, and generates the entire next generation by selcting and breeding from the previous
func NewSimplePopulation ¶ added in v0.5.0
func NewSimplePopulation(newGenotype func() *Genotype, n int) *SimplePopulation
func (*SimplePopulation) Agents ¶ added in v0.5.0
func (p *SimplePopulation) Agents() []*Agent
func (*SimplePopulation) NextGeneration ¶ added in v0.5.0
func (p *SimplePopulation) NextGeneration(selection Selection, reproduction Reproduction) *SimplePopulation
type StdReproduction ¶
type StdReproduction struct { StdNumNewSynapses float64 StdNumNewRecurrentSynapses float64 StdNumNewNeurons float64 StdNumMutateSynapses float64 StdNumPruneSynapses float64 StdNumMutateActivations float64 StdNewSynapseWeight float64 StdMutateSynapseWeight float64 MaxHiddenNeurons int Counter *Counter PossibleActivations []Activation }
func (*StdReproduction) Reproduce ¶
func (r *StdReproduction) Reproduce(a, b *Genotype) *Genotype
type TournamentSelection ¶ added in v0.5.0
type TournamentSelection struct { TournamentSize int // contains filtered or unexported fields }
func (*TournamentSelection) Select ¶ added in v0.5.0
func (t *TournamentSelection) Select() *Agent
func (*TournamentSelection) SetAgents ¶ added in v0.5.0
func (t *TournamentSelection) SetAgents(agents []*Agent)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
geno
|
|
arr
Module
|
|
floatarr
Module
|
|
neat
Module
|
|
pop
|
|
hillclimber
Module
|
|
simple
Module
|
|
speciated
Module
|
|
selec
|
|
elite
Module
|
|
tournament
Module
|