Class: EvoSynth::Evolvers::LocalSearch::ThresholdAcceptance
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::LocalSearch::ThresholdAcceptance
- Defined in:
- lib/evosynth/evolvers/local_search/acceptance_threshold.rb
Overview
AKZEPTANZ-TA (Weicker Page 157)
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) ⇒ ThresholdAcceptance
constructor
A new instance of ThresholdAcceptance.
- #to_s ⇒ Object
Constructor Details
#initialize(start_temp = DEFAULT_START_TEMP, alpha = DEFAULT_ALPHA) ⇒ ThresholdAcceptance
Returns a new instance of ThresholdAcceptance.
38 39 40 41 |
# File 'lib/evosynth/evolvers/local_search/acceptance_threshold.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_threshold.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_threshold.rb', line 33 def temperature @temperature end |
Instance Method Details
#accepts(parent, child, generation) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/evosynth/evolvers/local_search/acceptance_threshold.rb', line 43 def accepts(parent, child, generation) threshold = Math.sqrt( (child.fitness - parent.fitness)**2 ) accepted = child > parent || threshold <= @temperature @temperature *= @alpha accepted end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/evosynth/evolvers/local_search/acceptance_threshold.rb', line 51 def to_s "Threshold Acceptance" end |