gen

package
v0.0.0-...-024983d Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Unlicense Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FitnessFunc

type FitnessFunc[T any] func(*Genome[T]) float64

type Genome

type Genome[T any] struct {
	Value   []T
	Fitness float64
}

func (*Genome[T]) SetFitness

func (genome *Genome[T]) SetFitness(f FitnessFunc[T])

type Population

type Population[T any] struct {
	Genomes    []*Genome[T]
	Generation int
	Fittest    *Genome[T]
}

func (*Population[T]) SetFitness

func (p *Population[T]) SetFitness(f FitnessFunc[T])

type Randomizer

type Randomizer interface {
	Intn(i int) int
	Float64() float64
}

type Report

type Report[T any] struct {
	Generation int
	Species    int
	Fittest    *Genome[T]
}

type ReporterFunc

type ReporterFunc[T any] func(Report[T])

type Species

type Species[T any] struct {
	ValidGenes          []T
	Fitness             FitnessFunc[T]
	PopulationSize      int
	GenomeSize          int
	MutationRate        float64
	SingleCrossOverRate float64
}

func (*Species[T]) CrossOver

func (e *Species[T]) CrossOver(random Randomizer, a, b *Genome[T]) *Genome[T]

func (*Species[T]) Mutate

func (e *Species[T]) Mutate(random Randomizer, genome *Genome[T])

func (*Species[T]) NextPopulation

func (e *Species[T]) NextPopulation(random Randomizer, pop Population[T]) Population[T]

func (*Species[T]) RandomGenome

func (s *Species[T]) RandomGenome(random Randomizer) *Genome[T]

func (*Species[T]) RandomPopulation

func (e *Species[T]) RandomPopulation(random Randomizer) Population[T]

func (*Species[T]) Selection

func (e *Species[T]) Selection(random Randomizer, population Population[T]) []*Genome[T]

func (*Species[T]) SinglePointCrossOver

func (e *Species[T]) SinglePointCrossOver(random Randomizer, parentA, parentB *Genome[T]) *Genome[T]

func (*Species[T]) Solve

func (e *Species[T]) Solve(ctx context.Context, random Randomizer, speciesNumber int, reporter ReporterFunc[T])

func (*Species[T]) UniformCrossOver

func (e *Species[T]) UniformCrossOver(random Randomizer, parentA, parentB *Genome[T]) *Genome[T]

Jump to

Keyboard shortcuts

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