neat

package
v0.0.0-...-77f7900 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: MIT Imports: 8 Imported by: 0

README

neat

====

Based on Dr. Stanley's original NEAT design, the neat package in evo incorporates some changes based on my experience working with

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoParents      = errors.New("NEAT crosser requires at least 1 parent")
	ErrTooManyParents = errors.New("NEAT crosser does not support more than 2 parents")
)

Known errors

View Source
var (
	ErrInvalidNumInputs  = errors.New("num inputs must be greater than or equal to zero")
	ErrInvalidNumOutputs = errors.New("num outputs must be greater than zero")
)

Errors related to the Seeder

View Source
var (
	ErrMissingDistancer  = errors.New("speciator requires a distancer helper")
	ErrNegativeThreshold = errors.New("compatibility threshold should be nonzero")
)

Known errors for the speciator

View Source
var (
	ErrInvalidPopulationSize = errors.New("invalid population size")
)

Known errors

View Source
var (
	ErrMissingSeeder = errors.New("neat populator requires a seeder")
)

Known errors

Functions

This section is empty.

Types

type Compatibility

type Compatibility struct {
	DisableSortCheck      bool
	NodesCoefficient      float64
	BiasCoefficient       float64
	ActivationCoefficient float64
	ConnsCoefficient      float64
	WeightCoefficient     float64
}

Compatibility distance measurer using the methods described by Stanley

func (Compatibility) Distance

func (c Compatibility) Distance(a, b evo.Genome) (d float64, err error)

Distance is the compatibility distance based on encoded substrates

type Crosser

type Crosser struct {
	EnableProbability       float64
	DisableEqualParentCheck bool
	DisableSortCheck        bool
	evo.Comparison
}

Crosser combines 1 or more parents to create an offspring genome.

func (*Crosser) Cross

func (z *Crosser) Cross(parents ...evo.Genome) (child evo.Genome, err error)

Cross the parents and create a new offspring, using the sequence to assign a new ID. There is a chance that connections disabled in one of the parents will also be disabled in the child.

type Distancer

type Distancer interface {
	Distance(a, b evo.Genome) (float64, error)
}

Distancer calculates the compatibility distance between two genomes

type Experiment

type Experiment struct {
	Crosser
	Populator
	Selector
	Speciator
	Transcriber
	forward.Translator
	evo.Searcher
	evo.Mutators
	// contains filtered or unexported fields
}

Experiment implements an EVO experiment with the NEAT helpers.

func NewExperiment

func NewExperiment(cfg config.Configurer) (exp *Experiment)

NewExperiment creates a new NEAT experiment using the configuration. Configurations employ the maximum namespace so user can be as specific or lax (depending on depth of namespace used) as desired.

func (*Experiment) AddSubscription

func (e *Experiment) AddSubscription(s evo.Subscription)

AddSubscription adds a new subscription to the experiment

func (*Experiment) Subscriptions

func (e *Experiment) Subscriptions() []evo.Subscription

Subscriptions returns the subscriptions registered with this experiment.

type Populator

type Populator struct {
	PopulationSize int
	BiasPower      float64
	MaxBias        float64
	WeightPower    float64
	MaxWeight      float64
	evo.Seeder
}

Populator provides a population to the experiment

func (Populator) Populate

func (p Populator) Populate() (pop evo.Population, err error)

Populate creates a new population by creating randomised version of a seed genome.

type Seeder

type Seeder struct {
	NumInputs        int
	NumOutputs       int
	NumTraits        int
	DisconnectRate   float64
	OutputActivation evo.Activation
}

Seeder creates the initial population

func (Seeder) Seed

func (s Seeder) Seed() (g evo.Genome, err error)

Seed creates an unitialised genome from the specifications.

type Selector

type Selector struct {
	PopulationSize              int
	MutateOnlyProbability       float64
	InterspeciesMateProbability float64
	DisableContinuing           bool
	Elitism                     float64
	SurvivalRate                float64
	DecayRate                   float64
	evo.Comparison
	// contains filtered or unexported fields
}

Selector determines which genomes continue and which become parents

func (*Selector) Select

func (s *Selector) Select(pop evo.Population) (continuing []evo.Genome, parents [][]evo.Genome, err error)

Select the genomes to continue and those to become parents

func (*Selector) ToggleMutateOnly

func (s *Selector) ToggleMutateOnly(on bool) error

ToggleMutateOnly puts the selector into a mutate only mode when on is true

type Speciator

type Speciator struct {

	// Properties
	CompatibilityThreshold float64 // Threshold for determining if a genome is compatible with the species
	CompatibilityModifier  float64 // Adjustment to threshold to help achieve target
	TargetSpecies          int     // The desired number of species

	// Helper
	Distancer // Calculates the distance between a genome and the species's example genome
	// contains filtered or unexported fields
}

Speciator assigns genomes to the correct species, adding and removing species as necessary

func (*Speciator) Speciate

func (s *Speciator) Speciate(pop *evo.Population) (err error)

Speciate the population

type Transcriber

type Transcriber struct {
	DisableSortCheck bool
}

Transcriber produces the decoded substrate

func (Transcriber) Transcribe

func (t Transcriber) Transcribe(enc evo.Substrate) (dec evo.Substrate, err error)

Transcribe the encoded substrate into a decoded one

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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