Method: EvoSynth::Mutations::SelfAdaptiveGaussMutation#mutate

Defined in:
lib/evosynth/operators/mutations/self_adaptive_gauss_mutation.rb

#mutate(individual) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/evosynth/operators/mutations/self_adaptive_gauss_mutation.rb', line 45

def mutate(individual)
	mutated = individual.deep_clone
	add_sigma(mutated) unless defined? mutated.sigma

	mutated.sigma *= Math.exp( (1 / Math.sqrt(mutated.genome.size)) * EvoSynth.nrand)

	mutated.genome.map! do |gene|
		gene += EvoSynth.nrand(0.0, mutated.sigma)
		gene = @lower_bound if gene < @lower_bound
		gene = @upper_bound if gene > @upper_bound
		gene
	end

	mutated
end