class

Population(T)

Inherits Reference < Object

Keeps track of population, generations, selection.

Constructors

new(n : Int32)
Source

Instance methods

best_solution
Source
evolve!

Selects chromosomes for breeding (using #select_pair), creates the next generation. Adds random mutation depending on #mutate?

Source
generation
Source
max_fitness
Source
mutate?

A bit naive perhaps, but easy to override.

Source
seed(population : Array(T) = [] of T)

Seed the genesis generation.

Source
select_pair

Select a pair of chromosomes using proportional selection.

Source
winner

Calls fitness function on ALL chromosomes, and returns highest. Be mindful of the expense.

Source