Documentation
¶
Index ¶
- Variables
- func Activate(x float64, a Activation) float64
- func Clone[T Cloneable](obj T) T
- func PointCrossover[T PointCrossoverable](parent1, parent2 T) T
- func SelectNGenotypes[T any](selection Selection[T], n int) []T
- type Activation
- type Agent
- type Buildable
- type Cloneable
- type Counter
- type Forwarder
- type GeneticDistance
- type PointCrossoverable
- type Population
- type Reproduction
- type Selection
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
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 PointCrossover ¶ added in v0.4.2
func PointCrossover[T PointCrossoverable](parent1, parent2 T) T
PointCrossover performs a point crossover between two parents. It is generic, so it will perform the cast back to the parent type.
func SelectNGenotypes ¶ added in v0.4.2
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 Buildable ¶ added in v0.4.2
type Buildable interface {
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 goevo.Clone(obj), 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 Forwarder ¶ added in v0.3.0
Forwarder is an interface for somthing that can take a set of inputs ([]float64) and return a set of outputs.
type GeneticDistance ¶ added in v0.2.0
GeneticDistance is an interface for calculating the genetic distance between two genotypes.
type PointCrossoverable ¶ added in v0.4.2
type PointCrossoverable interface {
PointCrossoverWith(other PointCrossoverable) PointCrossoverable
}
PointCrossoverable is an interface that must be implemented by any object that wants to be point crossovered. It should return a new object that is the crossover of two parents. The mutations should have no spatial importance, i.e. two genes next to each other will have re relation.
type Population ¶ added in v0.4.2
type Population[T any] interface { // NextGeneration returns the next generation of the population. // The population should use the selection and reproduction strategies it has stored to determine the next generation. NextGeneration() Population[T] // All returns all agents in the population. All() []*Agent[T] }
type Reproduction ¶ added in v0.4.0
type Reproduction[T any] interface { // Reproduce creates a new genotype from the n parents. The parents are NOT ordered by fitness. Reproduce(agents []T) T // NumParents returns the number of parents required for reproduction NumParents() int }
Reproduction is an interface for the reproduction of n parents to create a child
type Selection ¶ added in v0.4.0
type Selection[T any] interface { // SetAgents sets the agents to select from for this generation. // This is run 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 agents set by SetAgents. Select() *Agent[T] }
Selection is a strategy for selecting agents from a population. It acts on agents of type T.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
geno
|
|
arr
Module
|
|
floatarr
Module
|
|
neat
Module
|
|
pop
|
|
hillclimber
Module
|
|
neatpop
Module
|
|
simple
Module
|
|
speciated
Module
|
|
selec
|
|
elite
Module
|
|
tournament
Module
|