Class: EvoSynth::Recombinations::UniformCrossover

Inherits:
Object
  • Object
show all
Defined in:
lib/evosynth/operators/recombinations/uniform_crossover.rb

Overview

UNIFORMER-CROSSOVER (Weicker Page 80)

Instance Method Summary collapse

Instance Method Details

#recombine(individual_one, individual_two) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evosynth/operators/recombinations/uniform_crossover.rb', line 32

def recombine(individual_one, individual_two)
	child_one = individual_one.deep_clone
	child_two = individual_two.deep_clone
	shorter = EvoSynth::Recombinations.individual_with_shorter_genome(individual_one, individual_two)

	shorter.genome.each_index do |index|
		if EvoSynth.rand_bool
			child_one.genome[index] = individual_two.genome[index]
			child_two.genome[index] = individual_one.genome[index]
		end
	end

	[child_one, child_two]
end

#to_sObject



47
48
49
# File 'lib/evosynth/operators/recombinations/uniform_crossover.rb', line 47

def to_s
	"uniform crossover"
end