population

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2014 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

The package describing genetic algorithm populations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crossover

func Crossover(mother, father *Individual, child *tt.Solution) (childValue tt.Value)

Types

type Individual

type Individual struct {
	Assignments []tt.Rat   // The assignments.
	Quality     []tt.Value // The assignments' quality.
	Success     *Success   // The success ratio of the individual.
	Value       tt.Value   // The value of the solution.
}

An individual that can be crossed over

type Population

type Population struct {
	// contains filtered or unexported fields
}

A population.

func New

func New(inst *tt.Instance, minSize, maxSize int) (p *Population)

Generate a population of size minSize using the random variable order heuristic.

func (*Population) Best

func (p *Population) Best() (*tt.Solution, tt.Value)

Determine the best member of the population. A solution picked this way must not be modified.

func (*Population) Insert

func (p *Population) Insert(soln *tt.Solution)

Insert a member into the population. If the population is full, do selection first.

func (*Population) PickIndividual

func (p *Population) PickIndividual() *Individual

Return an individual so that it may be crossed over.

func (*Population) PickSolution

func (p *Population) PickSolution() []tt.Rat

Pick a member randomly using the given random number generator. A solution picked this way must not be modified. To pick a member randomly and modify it, use RemoveOne followed by Insert.

func (*Population) RemoveOne

func (p *Population) RemoveOne() (soln *tt.Solution)

Remove one solution from the population, chosen at random.

func (*Population) Select

func (p *Population) Select()

Do selection so that the population has at most MinSize members.

func (*Population) Size

func (p *Population) Size() int

Determine the size of the population.

type Success

type Success struct {
	// contains filtered or unexported fields
}

A success ratio, which describes how often the associated individual in a population is involved in successful reproductions (i.e., ones where the resultant individual is of a higher quality than the parent).

func (*Success) Ratio

func (s *Success) Ratio() (ratio float64)

Get the success ratio.

Jump to

Keyboard shortcuts

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