Class: Evolvable::GeneCombination

Inherits:
Object
  • Object
show all
Defined in:
lib/evolvable/gene_combination.rb

Overview

Custom crossover objects must implement the #call method which accepts the population as the first object. Enables gene types to define combination behaviors.

Each gene class can implement a unique behavior for combination by overriding the following default implementation which mirrors the behavior of Evolvable::UniformCrossover

Instance Method Summary collapse

Instance Method Details

#call(population) ⇒ Object



22
23
24
25
# File 'lib/evolvable/gene_combination.rb', line 22

def call(population)
  new_evolvables(population, population.size)
  population
end

#new_evolvables(population, count) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/evolvable/gene_combination.rb', line 27

def new_evolvables(population, count)
  parent_genome_cycle = population.new_parent_genome_cycle
  Array.new(count) do
    genome = build_genome(parent_genome_cycle.next)
    population.new_evolvable(genome: genome)
  end
end