Class: EvoSynth::Evolvers::LocalSearch::SimulatedAnnealingAcceptance
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::LocalSearch::SimulatedAnnealingAcceptance
- Defined in:
- lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb
Overview
AKZEPTANZ-SA (Weicker Page 156)
Constant Summary collapse
- DEFAULT_START_TEMP =
Float::MAX
- DEFAULT_ALPHA =
0.9
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
Instance Method Summary collapse
- #accepts(parent, child, generation) ⇒ Object
-
#initialize(start_temp = DEFAULT_START_TEMP, alpha = DEFAULT_ALPHA) ⇒ SimulatedAnnealingAcceptance
constructor
A new instance of SimulatedAnnealingAcceptance.
- #to_s ⇒ Object
Constructor Details
#initialize(start_temp = DEFAULT_START_TEMP, alpha = DEFAULT_ALPHA) ⇒ SimulatedAnnealingAcceptance
38 39 40 41 |
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 38 def initialize(start_temp = DEFAULT_START_TEMP, alpha = DEFAULT_ALPHA) @temperature = start_temp @alpha = alpha end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
33 34 35 |
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 33 def alpha @alpha end |
#temperature ⇒ Object
Returns the value of attribute temperature.
33 34 35 |
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 33 def temperature @temperature end |
Instance Method Details
#accepts(parent, child, generation) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 43 def accepts(parent, child, generation) threshold = Math.exp( -1 * Math.sqrt( (child.fitness - parent.fitness)**2 ) / @temperature) @temperature *= @alpha child > parent || EvoSynth.rand <= threshold end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 50 def to_s "Simulated Annealing Acceptance" end |