Class: EvoSynth::Evolvers::LocalSearch::SimulatedAnnealingAcceptance

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#alphaObject

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

#temperatureObject

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_sObject



50
51
52
# File 'lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb', line 50

def to_s
  "Simulated Annealing Acceptance"
end