floatarr

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package floatarr provides a genotype type that is a slice of float64 values. It also provides functions for reproduction using these genotypes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Genotype

type Genotype []float64

Genotype is a genotype that is a slice of float64 values.

func NewGenotype

func NewGenotype(size int, std float64) Genotype

NewGenotype creates a new genotype with the given size, where each value is a random float64 with a normal distribution with the given standard deviation.

func (Genotype) Clone

func (f64s Genotype) Clone() any

Clone returns a new genotype that is a copy of this genotype.

func (Genotype) PointCrossoverWith

func (f64s Genotype) PointCrossoverWith(other goevo.PointCrossoverable) goevo.PointCrossoverable

PointCrossoverWith returns a new genotype that is a combination of this genotype and the other genotype.

func (Genotype) UniformStdMutate

func (f64s Genotype) UniformStdMutate(probPerLocus, mutStd float64)

UniformStdMutate modifies the genotype by adding a random value from a normal distribution to each value with the given probability and standard deviation.

type UniformStdReproduction

type UniformStdReproduction struct {
	// The probability of mutating each locus
	MutateProbability float64
	// The standard deviation for the mutation
	MutateStd float64
}

UniformStdReproduction is a reproduction strategy for Float64sGenotype. It performs crossover and mutation.

func (*UniformStdReproduction) NumParents

func (r *UniformStdReproduction) NumParents() int

NumParents returns 2, as this reproduction strategy requires 2 parents.

func (*UniformStdReproduction) Reproduce

func (r *UniformStdReproduction) Reproduce(gs []Genotype) Genotype

Reproduce creates a new genotype by crossing over and mutating the given genotypes.

Jump to

Keyboard shortcuts

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