Class: Wallace::Operators::ThreeParentCrossoverOperator

Inherits:
Wallace::Operator show all
Defined in:
lib/operators/three_parent_crossover_operation.rb

Overview

Three parent crossover takes three individuals as parents, A, B and C, and combines them to form a single child D. At each point in the chromosome, the values of A and B are compared; if they are the same then that value is used, otherwise the value at C is used.

Instance Method Summary collapse

Methods inherited from Wallace::Operator

#initialize, #produce

Constructor Details

This class inherits a constructor from Wallace::Operator

Instance Method Details

#operate(rng, inputs) ⇒ Object



9
10
11
12
13
14
# File 'lib/operators/three_parent_crossover_operation.rb', line 9

def operate(rng, inputs)
  (0...inputs[0].length).each do |i|
    inputs[0][i] = inputs[2][i] if inputs[0][i] != inputs[1][i]
  end
  return [inputs[0]]
end