speciated

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Population

type Population[T any] struct {
	// Species is a map of species ID to a slice of agents.
	Species map[int][]*goevo.Agent[T]
	// RemoveWorstSpeciesChance is the chance that the worst species will be removed each generation.
	RemoveWorstSpeciesChance float64
	// StdNumAgentsSwap is the standard deviation of the number of agents to swap between species each generation.
	// An agent is swapped by moving it to another random species, and moving another agent from that species to this species.
	StdNumAgentsSwap float64
	// Counter is a counter to keep track of the new species.
	Counter *goevo.Counter
	// The selection strategy to use when selecting agents to reproduce.
	Selection goevo.SelectionStrategy[T]
	// The reproduction strategy to use when creating new agents.
	Reproduction goevo.ReproductionStrategy[T]
}

Population is a speciated population of agents. Each species has the same number of agents, and there are always the same number of species. Each generation, with a chance, the worst species is removed, and replaced with a random species or the best species.

func NewPopulation

func NewPopulation[T any](counter *goevo.Counter, newGenotype func() T, numSpecies, numAgentsPerSpecies int, removeWorstSpeciesChance, stdNumAgentsSwap float64, selection goevo.SelectionStrategy[T], reproduction goevo.ReproductionStrategy[T]) *Population[T]

NewPopulation creates a new speciated population.

func (*Population[T]) All

func (p *Population[T]) All() []*goevo.Agent[T]

All implements goevo.Population.

func (*Population[T]) NextGeneration

func (p *Population[T]) NextGeneration() goevo.Population[T]

NextGeneration implements goevo.Population.

Jump to

Keyboard shortcuts

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