pop

package
v0.0.0-...-b9e61c6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeySet_Int_SlInt

func KeySet_Int_SlInt(m map[int][]int) []int

Types

type DemeGroup

type DemeGroup struct {
	Demes []Population
	// Migration Chance is the average number
	// of individuals that should swap demes
	// per generation. .5 would have a swap
	// every other generation, on average,
	// 5 would have 5 swaps per generation,
	// etc.
	// Individuals cannot leave a deme without
	// another replacing it, in order to maintain
	// each deme's size does not change.
	// (This assertion is subject to change with
	// further analysis)
	MigrationChance float64
}

func (*DemeGroup) AverageFitness

func (dg *DemeGroup) AverageFitness() float64

func (*DemeGroup) BestMember

func (dg *DemeGroup) BestMember() (Individual, int)

func (*DemeGroup) NextGeneration

func (dg *DemeGroup) NextGeneration() bool

type Individual

type Individual interface {
	Fitness(input, expected [][]float64) int
	Mutate()
	Crossover(other Individual) Individual
	CanCrossover(other Individual) bool
	Print()
}

type PMethod

type PMethod interface {
	Pair(p *Population, populated int) [][]int
}

type Population

type Population struct {
	Members      []Individual
	Size         int
	Selection    SMethod
	Pairing      PMethod
	FitnessTests int
	TestInputs   [][]float64
	TestExpected [][]float64
	Elites       int
	Fitnesses    []int
	LowFitness   int
	MaxFitness   int
	GoalFitness  int
}

func (*Population) AverageFitness

func (p *Population) AverageFitness() float64

func (*Population) BestMember

func (p *Population) BestMember() (Individual, int)

func (*Population) GenerateFitness

func (p_p *Population) GenerateFitness()

func (*Population) GetElites

func (p_p *Population) GetElites() []Individual

func (*Population) NextGeneration

func (p *Population) NextGeneration() bool

NextGeneration selects, mutates, and crosses the population over, returning whether the population reached the goal fitness or not.

func (*Population) Print

func (p_p *Population) Print()

func (*Population) Weights

func (p *Population) Weights(power float64) ([]float64, []float64)

type SMethod

type SMethod interface {
	Select(p *Population) []Individual
	GetParentProportion() int
}

Jump to

Keyboard shortcuts

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