Class: BestsPickStrategy
- Inherits:
-
PickStrategy
- Object
- PickStrategy
- BestsPickStrategy
- Defined in:
- lib/gimuby/genetic/population/pick_strategy/bests_pick_strategy.rb
Instance Attribute Summary
Attributes inherited from PickStrategy
Instance Method Summary collapse
Methods inherited from PickStrategy
Constructor Details
This class inherits a constructor from PickStrategy
Instance Method Details
#pick(population) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gimuby/genetic/population/pick_strategy/bests_pick_strategy.rb', line 5 def pick(population) solutions = population.solutions number = get_number_to_pick(population) candidates = solutions.clone candidates.sort! do |x, y| (population.get_fitness x) <=> (population.get_fitness y) end candidates.slice(0, number) end |