Class: EvoSynth::Selections::RouletteWheelSelection
- Inherits:
-
FitnessProportionalSelection
- Object
- FitnessProportionalSelection
- EvoSynth::Selections::RouletteWheelSelection
- Defined in:
- lib/evosynth/operators/selections/roulette_wheel_selection.rb
Overview
STOCHASTISCHES-UNIVERSELLES-SAMPLING (Weicker Page 75)
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 45 46 |
# File 'lib/evosynth/operators/selections/roulette_wheel_selection.rb', line 33 def select(population, select_count = 1) selected_population = EvoSynth::Population.new fitness_hash = generate_fitness_hash(population) limit = EvoSynth.rand(fitness_hash[population.size - 1] / select_count) select_count.to_i.times do next_individual = select_next_individual(population, limit, fitness_hash) selected_population.add(next_individual) limit += fitness_hash[population.size - 1] / select_count end selected_population end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/evosynth/operators/selections/roulette_wheel_selection.rb', line 48 def to_s "roulette wheel selection" end |