Class: EvoSynth::Evolvers::LocalSearch::ThresholdAcceptance

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

Instance Method Summary collapse

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

#alphaObject

Returns the value of attribute alpha.



33
34
35
# File 'lib/evosynth/evolvers/local_search/acceptance_threshold.rb', line 33

def alpha
  @alpha
end

#temperatureObject

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_sObject



51
52
53
# File 'lib/evosynth/evolvers/local_search/acceptance_threshold.rb', line 51

def to_s
	"Threshold Acceptance"
end