class Population(T)

Overview

Keeps track of population, generations, selection.

Defined in:

population.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(n : Int32) #

[View source]

Instance Method Detail

def best_solution #

[View source]
def evolve! #

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


[View source]
def generation #

[View source]
def max_fitness #

[View source]
def mutate? #

A bit naive perhaps, but easy to override.


[View source]
def seed(population : Array(T) = [] of T) #

Seed the genesis generation.


[View source]
def select_pair #

Select a pair of chromosomes using proportional selection.


[View source]
def winner #

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


[View source]