Class: Evolvable::GeneCombination
- Inherits:
-
Object
- Object
- Evolvable::GeneCombination
- Defined in:
- lib/evolvable/gene_combination.rb
Overview
Combination generates new evolvable instances by combining the genes of selected instances. You can think of it as a mixing of parent genes from one generation to produce the next generation.
You may choose from a selection of combination objects or implement your own.
The default combination object is Evolvable::GeneCombination
.
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 |