Class: MHL::HyperMutationPlusRechenbergController
- Inherits:
-
Object
- Object
- MHL::HyperMutationPlusRechenbergController
- Defined in:
- lib/mhl/hm_plus_rechenberg_controller.rb
Constant Summary collapse
- DEFAULT_HM_GENERATIONS =
10
Instance Method Summary collapse
- #call(solver, best) ⇒ Object
-
#initialize(params = {}) ⇒ HyperMutationPlusRechenbergController
constructor
A new instance of HyperMutationPlusRechenbergController.
- #reset_mutation_probability(value) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ HyperMutationPlusRechenbergController
Returns a new instance of HyperMutationPlusRechenbergController.
7 8 9 10 11 |
# File 'lib/mhl/hm_plus_rechenberg_controller.rb', line 7 def initialize(params={}) @opts = { keep_for: DEFAULT_HM_GENERATIONS }.merge!(params) @rc = RechenbergController.new @gen = @gens_from_last_reset = 1 end |
Instance Method Details
#call(solver, best) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mhl/hm_plus_rechenberg_controller.rb', line 13 def call(solver, best) if @pending_reset # set mutation_probability to HM value solver.mutation_probability = @pending_reset # reinitialize controller @rc = RechenbergController.new # reinitialize counter of generations from last reset @gens_from_last_reset = 0 # undefine pending_reset # NOTE: not sure if we should we go as far as calling # remove_instance_variable(:@pending_reset) here @pending_reset = nil end # do nothing for the first @opts[:keep_for] generations if @gens_from_last_reset > @opts[:keep_for] @rc.call(solver, best) end # update counters @gen += 1 @gens_from_last_reset += 1 end |
#reset_mutation_probability(value) ⇒ Object
40 41 42 |
# File 'lib/mhl/hm_plus_rechenberg_controller.rb', line 40 def reset_mutation_probability(value) @pending_reset = value end |