Class: EvoSynth::GlobalRecombinations::GlobalArithmeticCrossover
- Inherits:
-
Object
- Object
- EvoSynth::GlobalRecombinations::GlobalArithmeticCrossover
- Defined in:
- lib/evosynth/operators/global_recombinations/global_arithmetic_crossover.rb
Overview
GLOBALER-ARITHMETISCHER-CROSSOVER (Weicker Page 138)
Instance Method Summary collapse
Instance Method Details
#recombine(population) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/evosynth/operators/global_recombinations/global_arithmetic_crossover.rb', line 32 def recombine(population) child = population[EvoSynth.rand(population.size)].deep_clone child.genome.each_index do |index| sum = population.inject(0.0) { |sum, individual| sum += individual.genome[index] } child.genome[index] = (1.0 / population.size) * sum end child end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/evosynth/operators/global_recombinations/global_arithmetic_crossover.rb', line 43 def to_s "global arithmetic crossover" end |