Class: EvoSynth::Selections::FitnessProportionalSelection

Inherits:
Object
  • Object
show all
Defined in:
lib/evosynth/operators/selections/fitness_proportional_selection.rb

Overview

FITNESSPROPORTIONALE-SELETION (Weicker Page 71)

Direct Known Subclasses

RouletteWheelSelection

Instance Method Summary collapse

Instance Method Details

#select(population, select_count = 1) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/evosynth/operators/selections/fitness_proportional_selection.rb', line 33

def select(population, select_count = 1)
	selected_population = EvoSynth::Population.new
	fitness_hash = generate_fitness_hash(population)

	select_count.to_i.times do
		limit = EvoSynth.rand(fitness_hash.values.max).floor
		next_individual = select_next_individual(population, limit, fitness_hash)
		selected_population.add(next_individual)
	end

	selected_population
end

#to_sObject



46
47
48
# File 'lib/evosynth/operators/selections/fitness_proportional_selection.rb', line 46

def to_s
	"fitness proportional selection"
end