class

Stochasta::Genetic::Engine(T)

Inherits Reference < Object

Constructors

new(population_size : Int32, mutation_rate : Float64, crossover_rate : Float64, fitness_fn : T -> Float64, crossover_fn : T, T -> T, mutate_fn : T -> T, initial_genomes : Array(T), tournament_size : Int32 = 3, elitism : Bool = true)
Source

Instance methods

best_individual
Source
crossover_fn
Source
crossover_fn=(crossover_fn : T, T -> T)
Source
crossover_rate
Source
crossover_rate=(crossover_rate : Float64)
Source
elitism
Source
elitism=(elitism : Bool)
Source
evolve(generations : Int32) : Individual(T)

Evolves for the specified number of generations

Source
evolve(generations : Int32, &block : Int32, Individual(T) -> ) : Individual(T)

Evolves for the specified number of generations and yields progress

Source
evolve_generation

Evolves the population by one generation

Source
fitness_fn
Source
fitness_fn=(fitness_fn : T -> Float64)
Source
mutate_fn
Source
mutate_fn=(mutate_fn : T -> T)
Source
mutation_rate
Source
mutation_rate=(mutation_rate : Float64)
Source
population
Source
population=(population : Array(Individual(T)))
Source
population_size
Source
population_size=(population_size : Int32)
Source
select_tournament

Selects an individual using tournament selection

Source
tournament_size
Source
tournament_size=(tournament_size : Int32)
Source