Class: CombinedNewGenerationStrategy
- Inherits:
-
NewGenerationStrategy
- Object
- NewGenerationStrategy
- CombinedNewGenerationStrategy
- Defined in:
- lib/gimuby/genetic/solution/new_generation_strategy/combined_new_generation_strategy.rb
Overview
This class pick randomly between strategies to implement more mitigated new generation strategy
Instance Method Summary collapse
-
#add_strategy(strategy) ⇒ Object
Add a strategy in the handled strategy of the system.
-
#initialize ⇒ CombinedNewGenerationStrategy
constructor
A new instance of CombinedNewGenerationStrategy.
- #reproduce(solution1, solution2) ⇒ Object
Constructor Details
#initialize ⇒ CombinedNewGenerationStrategy
Returns a new instance of CombinedNewGenerationStrategy.
7 8 9 |
# File 'lib/gimuby/genetic/solution/new_generation_strategy/combined_new_generation_strategy.rb', line 7 def initialize @strategies = [] end |
Instance Method Details
#add_strategy(strategy) ⇒ Object
Add a strategy in the handled strategy of the system
18 19 20 |
# File 'lib/gimuby/genetic/solution/new_generation_strategy/combined_new_generation_strategy.rb', line 18 def add_strategy(strategy) @strategies.push(strategy) end |
#reproduce(solution1, solution2) ⇒ Object
11 12 13 14 |
# File 'lib/gimuby/genetic/solution/new_generation_strategy/combined_new_generation_strategy.rb', line 11 def reproduce(solution1, solution2) strategy = get_concrete_strategy strategy.reproduce(solution1, solution2) end |