evo

package
v0.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package evo provides genetic evolution algorithm for evolving test cases nolint: gosec

Index

Constants

View Source
const (
	DefaultMutationRate float64 = 5
	DefaultTarget       float64 = 95.0
	DefaultNoImprovGens int     = 10
)

Default values for population

Variables

View Source
var (
	ErrOrganismCantBreed error = fmt.Errorf("organisms dont match, expected equal amount of files")
)

error definitions

Functions

This section is empty.

Types

type Population

type Population struct {
	Organisms []*gen.Organism
	BestFit   *gen.Organism
	Opts      PopulationOpts
	Stats     PopulationStats
	Fitness   float64

	Executor tmplexec.IExecutor
}

Population a population which is evolving

func NewPopulation

func NewPopulation(dir string, opts PopulationOpts) (*Population, error)

NewPopulation creates a new population for specified options

func (*Population) CreateBestFitResult

func (p *Population) CreateBestFitResult() error

CreateBestFitResult creates result for best fit

func (*Population) Evolve

func (p *Population) Evolve() error

Evolve evolve a population using natural selection

func (*Population) GetFitnessForOrganisms

func (p *Population) GetFitnessForOrganisms() error

GetFitnessForOrganisms retrieve the fitness for the current generation

func (*Population) NaturalSelection

func (p *Population) NaturalSelection() error

NaturalSelection creates a new generator using natural selection

type PopulationOpts

type PopulationOpts struct {
	MutationRate      float64
	Target            float64
	MaxNoImprovGens   int
	OrgGenerator      *gen.Generator
	OverrideTestCases bool
}

PopulationOpts struct representing options of the population

func DefaultPopOpts

func DefaultPopOpts(gen *gen.Generator) PopulationOpts

DefaultPopOpts create some default options for the population

type PopulationStats

type PopulationStats struct {
	AverageFit     float64
	NoImprovedGens int
	BestFit        float64
	Generation     int
}

PopulationStats struct representing the stats of the population

Jump to

Keyboard shortcuts

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