goevolve

package module
v0.0.0-...-cb18bc7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2016 License: Apache-2.0 Imports: 19 Imported by: 2

README

GoEvolve

GoEvolve is a evolutionary computation framework written in Go. It uses a custom virtual machine to evolve a program to satisfy a requirement or solve a problem.

Documentation

Index

Constants

View Source
const (
	MaxInt   = int(^uint(0) >> 1)
	MinInt   = int(-MaxInt - 1)
	MaxInt32 = int32(math.MaxInt32)
	MinInt32 = int32(math.MinInt32)
	MaxInt64 = int64(math.MaxInt64)
	MinInt64 = int64(math.MinInt64)
)

Integer limit values.

Variables

View Source
var SolutionCache map[string]*Solution
View Source
var USDict = NewDictionary("US.dic")

Functions

func Abs

func Abs(x int) int

Abs returns the absolute value of x.

func Abs32

func Abs32(x int32) int32

Abs32 returns the absolute value of x.

func Abs64

func Abs64(x int64) int64

Abs64 returns the absolute value of x.

func ArgsForInstruction

func ArgsForInstruction(op *govirtual.Instruction, existing, labels []string) string

func DecodeSolutionCache

func DecodeSolutionCache(b *bytes.Buffer) *map[string]*Solution

func EncodeSolutionCache

func EncodeSolutionCache() (b *bytes.Buffer)

func Max

func Max(left, right int) int

func Max32

func Max32(left, right int32) int32

func Max64

func Max64(left, right int64) int64

func Max8

func Max8(left, right int8) int8

func Min

func Min(left, right int) int

func Min32

func Min32(left, right int32) int32

func Min64

func Min64(left, right int64) int64

func Min8

func Min8(left, right int8) int8

func Now

func Now() int

func ReadSolutionCache

func ReadSolutionCache() *bytes.Buffer

func WriteSolutionCache

func WriteSolutionCache(b *bytes.Buffer)

Types

type AndSelector

type AndSelector []Selector

func AndSelect

func AndSelect(selectors ...Selector) *AndSelector

func (*AndSelector) AddSelector

func (multi *AndSelector) AddSelector(s Selector)

func (AndSelector) Select

func (multi AndSelector) Select(s *SolutionList) *SolutionList

type Breeder

type Breeder interface {
	Breed(seeds []string) []string
}

type Champion

type Champion struct {
	Reward   int
	Programs []string
}

type Champions

type Champions []Champion

func (Champions) Len

func (s Champions) Len() int

func (Champions) Less

func (s Champions) Less(i, j int) bool

func (Champions) Swap

func (s Champions) Swap(i, j int)

type CopyBreeder

type CopyBreeder struct {
	PopulationSize int
}

func NewCopyBreeder

func NewCopyBreeder(size int) CopyBreeder

func (CopyBreeder) Breed

func (cp CopyBreeder) Breed(initialPop []string) []string

type CostEvaluator

type CostEvaluator struct{}

func NewCostEvaluator

func NewCostEvaluator() *CostEvaluator

func (*CostEvaluator) Evaluate

func (c *CostEvaluator) Evaluate(p *govirtual.Processor) int

type CrossoverBreeder

type CrossoverBreeder struct {
	PopulationSize int
}

func NewCrossoverBreeder

func NewCrossoverBreeder(popSize int) CrossoverBreeder

func (CrossoverBreeder) Breed

func (breeder CrossoverBreeder) Breed(seeds []string) []string

type Dictionary

type Dictionary []string

func NewDictionary

func NewDictionary(name string) *Dictionary

func (*Dictionary) RandomWord

func (dict *Dictionary) RandomWord() string

type Evaluator

type Evaluator interface {
	Evaluate(*govirtual.Processor) int
}

type InfluxBreeder

type InfluxBreeder chan []string

func (InfluxBreeder) Breed

func (breeder InfluxBreeder) Breed([]string) []string

type InverseEvaluator

type InverseEvaluator struct {
	Evaluator *Evaluator
}

func Inverse

func Inverse(e Evaluator) *InverseEvaluator

func (InverseEvaluator) Evaluate

func (inverse InverseEvaluator) Evaluate(p *govirtual.Processor) int

type IslandEvolver

type IslandEvolver struct {
	ChampionSize         int
	PopulationReportChan chan *PopulationReport
	InfluxBreeder
	// contains filtered or unexported fields
}

func NewIslandEvolver

func NewIslandEvolver() *IslandEvolver

func (*IslandEvolver) AddPopulation

func (self *IslandEvolver) AddPopulation(heap *govirtual.Memory, registerSize int, is *govirtual.InstructionSet, term govirtual.TerminationCondition, breeder Breeder, eval Evaluator, selector Selector)

func (*IslandEvolver) Interbreed

func (self *IslandEvolver) Interbreed()

type MultiBreeder

type MultiBreeder []Breeder

func Breeders

func Breeders(breeders ...Breeder) *MultiBreeder

func (MultiBreeder) Breed

func (multi MultiBreeder) Breed(seeds []string) []string

type MultiEvaluator

type MultiEvaluator []*Evaluator

func NewMultiEvaluator

func NewMultiEvaluator(e ...*Evaluator) *MultiEvaluator

func (*MultiEvaluator) AddEvaluator

func (multi *MultiEvaluator) AddEvaluator(e *Evaluator) *MultiEvaluator

func (*MultiEvaluator) Evaluate

func (multi *MultiEvaluator) Evaluate(p *govirtual.Processor) int

type MutationBreeder

type MutationBreeder struct {
	PopulationSize int
	MutationChance float64
	*govirtual.InstructionSet
}

func NewMutationBreeder

func NewMutationBreeder(popSize int, mutationChance float64, is *govirtual.InstructionSet) MutationBreeder

func (MutationBreeder) Breed

func (breeder MutationBreeder) Breed(seeds []string) []string

type OrSelector

type OrSelector []Selector

func OrSelect

func OrSelect(selectors ...Selector) *OrSelector

func (OrSelector) Select

func (multi OrSelector) Select(s *SolutionList) *SolutionList

type Population

type Population struct {
	Id, RegisterLength   int
	InstructionSet       *govirtual.InstructionSet
	Breeder              *Breeder
	Evaluator            *Evaluator
	Selector             *Selector
	TerminationCondition *govirtual.TerminationCondition
	ControlChan          chan bool
	PopulationReportChan chan *PopulationReport
	Heap                 *govirtual.Memory
}

func NewPopulation

func NewPopulation(id int, sharedMemory *govirtual.Memory, rl int, is *govirtual.InstructionSet, term govirtual.TerminationCondition, gen Breeder, eval Evaluator, selector Selector) *Population

func (*Population) Run

func (s *Population) Run()

type PopulationReport

type PopulationReport struct {
	Id int
	SolutionList
}

type RandomBreeder

type RandomBreeder struct {
	PopulationSize, ProgramLength int
	*govirtual.InstructionSet
}

func NewRandomBreeder

func NewRandomBreeder(popSize int, programLen int, is *govirtual.InstructionSet) *RandomBreeder

func (RandomBreeder) Breed

func (breeder RandomBreeder) Breed([]string) []string

type SafeRNG

type SafeRNG struct {
	// contains filtered or unexported fields
}

func (*SafeRNG) Float64

func (rng *SafeRNG) Float64() float64

func (*SafeRNG) Int

func (rng *SafeRNG) Int() int

func (*SafeRNG) Int63

func (rng *SafeRNG) Int63() int64

func (*SafeRNG) SmallInt

func (rng *SafeRNG) SmallInt() int

type Selector

type Selector interface {
	Select(*SolutionList) *SolutionList
}

type Solution

type Solution struct {
	Reward  int
	Program string
}

func FightInTournament

func FightInTournament(warrior1 *Solution, warrior2 *Solution) *Solution

type SolutionList

type SolutionList []*Solution

func RWS

func RWS(solutions *SolutionList, pointers []int) *SolutionList

func (*SolutionList) GetPrograms

func (sol *SolutionList) GetPrograms() []string

func (SolutionList) Len

func (s SolutionList) Len() int

func (SolutionList) Less

func (s SolutionList) Less(i, j int) bool

func (SolutionList) Swap

func (s SolutionList) Swap(i, j int)

type StochasticUniversalSelector

type StochasticUniversalSelector struct {
	Keep int
}

func NewStochasticUniversalSelector

func NewStochasticUniversalSelector(keep int) *StochasticUniversalSelector

func (StochasticUniversalSelector) Select

type TimeEvaluator

type TimeEvaluator struct{}

func NewTimeEvaluator

func NewTimeEvaluator() *TimeEvaluator

func (*TimeEvaluator) Evaluate

func (t *TimeEvaluator) Evaluate(p *govirtual.Processor) int

type TopXSelector

type TopXSelector struct {
	Keep int
}

func TopX

func TopX(keep int) *TopXSelector

func (TopXSelector) Select

func (topx TopXSelector) Select(s *SolutionList) *SolutionList

type TournamentSelector

type TournamentSelector struct {
	Keep int
}

func Tournament

func Tournament(keep int) TournamentSelector

func (TournamentSelector) Select

func (t TournamentSelector) Select(solutions *SolutionList) *SolutionList

Jump to

Keyboard shortcuts

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