genetic

package
v0.0.0-...-c551575 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm struct {
	Log               *log.Logger
	RandForIndex      RandForIndex
	ParentSelector    ParentSelector
	Factory           ChromosomeFactory
	Terminator        Termination
	Crossover         Crossover
	SurvivorSelection SurvivorSelection
	Mutator           Mutation
	NumberOfParents   int
	PopulationSize    int
	NumGoroutine      int
}

func (*Algorithm) Run

func (a *Algorithm) Run() Chromosome

type Array

type Array interface {
	Chromosome
	Swap(i, j int)
	Copy(from Array, start int, end int, into int)
	Randomize(int, Rand)
	Len() int
}

type Chromosome

type Chromosome interface {
	Fitness() int
	Clone() Chromosome
	Shell() Chromosome
	String() string
}

type ChromosomeFactory

type ChromosomeFactory interface {
	Spawn(G Rand) Chromosome
	Family() string
}

type CountingTermination

type CountingTermination struct {
	Limit int
	// contains filtered or unexported fields
}

func (*CountingTermination) StopExecution

func (c *CountingTermination) StopExecution(p Population, _ Rand) bool

func (*CountingTermination) String

func (c *CountingTermination) String() string

type Crossover

type Crossover interface {
	Reproduce(in []Chromosome, r Rand) Chromosome
	String() string
}

type DynamicMutation

type DynamicMutation interface {
	Mutation
	IncreaseMutationRate(r Rand)
	ResetMutationRate(r Rand)
}

type IndexMutation

type IndexMutation struct {
}

func (*IndexMutation) Mutate

func (i *IndexMutation) Mutate(in Chromosome, r Rand) Chromosome

func (*IndexMutation) String

func (i *IndexMutation) String() string

type LocalOptimization

type LocalOptimization interface {
	LocallyOptimize() Chromosome
}

type LockedRand

type LockedRand struct {
	G Rand
	// contains filtered or unexported fields
}

func (*LockedRand) Int

func (l *LockedRand) Int() int

func (*LockedRand) Int63

func (l *LockedRand) Int63() int64

func (*LockedRand) Intn

func (l *LockedRand) Intn(n int) int

type LookAheadMutation

type LookAheadMutation struct {
}

func (*LookAheadMutation) Mutate

func (a *LookAheadMutation) Mutate(in Chromosome, r Rand) Chromosome

func (*LookAheadMutation) String

func (a *LookAheadMutation) String() string

type MultiTermination

type MultiTermination struct {
	Executors []Termination
}

func (*MultiTermination) StopExecution

func (c *MultiTermination) StopExecution(p Population, r Rand) bool

func (*MultiTermination) String

func (c *MultiTermination) String() string

type Mutation

type Mutation interface {
	Mutate(in Chromosome, r Rand) Chromosome
	String() string
}

type NoImprovementTermination

type NoImprovementTermination struct {
	Consecutive int
	// contains filtered or unexported fields
}

func (*NoImprovementTermination) StopExecution

func (c *NoImprovementTermination) StopExecution(p Population, _ Rand) bool

func (*NoImprovementTermination) String

func (c *NoImprovementTermination) String() string

type OnePointCrossover

type OnePointCrossover struct {
}

func (*OnePointCrossover) Reproduce

func (s *OnePointCrossover) Reproduce(in []Chromosome, r Rand) Chromosome

func (*OnePointCrossover) String

func (s *OnePointCrossover) String() string

type ParentSelector

type ParentSelector interface {
	PickParent([]Chromosome, Rand) int
	String() string
}

type ParentSurvivorSelection

type ParentSurvivorSelection struct {
	ParentSelector ParentSelector
}

func (*ParentSurvivorSelection) NextGeneration

func (p *ParentSurvivorSelection) NextGeneration(previous *Population, candidate *Population, r Rand) Population

func (*ParentSurvivorSelection) String

func (p *ParentSurvivorSelection) String() string

type PassThruDynamicMutation

type PassThruDynamicMutation struct {
	PassTo        Mutation
	MutationRatio int
	// contains filtered or unexported fields
}

func (*PassThruDynamicMutation) IncreaseMutationRate

func (p *PassThruDynamicMutation) IncreaseMutationRate(r Rand)

func (*PassThruDynamicMutation) Mutate

func (*PassThruDynamicMutation) ResetMutationRate

func (p *PassThruDynamicMutation) ResetMutationRate(r Rand)

func (*PassThruDynamicMutation) String

func (p *PassThruDynamicMutation) String() string

type Population

type Population struct {
	Individuals []Chromosome
	// contains filtered or unexported fields
}

func SpawnPopulation

func SpawnPopulation(n int, f ChromosomeFactory, r Rand) Population

func (*Population) Average

func (p *Population) Average() float64

func (*Population) Max

func (p *Population) Max() Chromosome

func (*Population) Min

func (p *Population) Min() Chromosome

func (*Population) NextGen

func (p *Population) NextGen(ps ParentSelector, b Crossover, m Mutation, numP int, numGoroutine int, rnd RandForIndex) Population

START PLAY2OMIT

func (*Population) NextGeneration

func (p *Population) NextGeneration(ps ParentSelector, b Crossover, m Mutation, numP int, numGoroutine int, rnd RandForIndex) Population

func (*Population) Sort

func (p *Population) Sort()

type Rand

type Rand interface {
	Intn(int) int
	Int() int
	Int63() int64
}

type RandForIndex

type RandForIndex interface {
	Rand(idx int) Rand
}

func ArrayRandForIdx

func ArrayRandForIdx(size int, seed int64, generator func(seed int64) Rand) RandForIndex

type Simplifyable

type Simplifyable interface {
	Simplify()
}

type SurvivorSelection

type SurvivorSelection interface {
	NextGeneration(previous *Population, candidate *Population, r Rand) Population
	String() string
}

type SwapMutator

type SwapMutator struct {
}

func (*SwapMutator) Mutate

func (a *SwapMutator) Mutate(in Chromosome, r Rand) Chromosome

func (*SwapMutator) String

func (a *SwapMutator) String() string

type Termination

type Termination interface {
	StopExecution(p Population, r Rand) bool
	String() string
}

type TimingTermination

type TimingTermination struct {
	Duration time.Duration

	Now func() time.Time
	// contains filtered or unexported fields
}

func (*TimingTermination) StopExecution

func (c *TimingTermination) StopExecution(p Population, _ Rand) bool

func (*TimingTermination) String

func (c *TimingTermination) String() string

type TournamentParentSelector

type TournamentParentSelector struct {
	K int
}

func (TournamentParentSelector) PickParent

func (s TournamentParentSelector) PickParent(c []Chromosome, r Rand) int

func (TournamentParentSelector) String

func (s TournamentParentSelector) String() string

Jump to

Keyboard shortcuts

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