Documentation ¶
Overview ¶
The package describing genetic algorithm populations.
Index ¶
- func Crossover(mother, father *Individual, child *tt.Solution) (childValue tt.Value)
- type Individual
- type Population
- func (p *Population) Best() (*tt.Solution, tt.Value)
- func (p *Population) Insert(soln *tt.Solution)
- func (p *Population) PickIndividual() *Individual
- func (p *Population) PickSolution() []tt.Rat
- func (p *Population) RemoveOne() (soln *tt.Solution)
- func (p *Population) Select()
- func (p *Population) Size() int
- type Success
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.