Class: EvoSynth::Evolvers::LocalSearch::RecordToRecordTravelAcceptance
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::LocalSearch::RecordToRecordTravelAcceptance
- Defined in:
- lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb
Overview
AKZEPTANZ-RR (Weicker Page 158)
Constant Summary collapse
- DEFAULT_START_DELTA =
Float::MAX
- DEFAULT_ALPHA =
0.9
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#delta ⇒ Object
Returns the value of attribute delta.
Instance Method Summary collapse
- #accepts(parent, child, generation) ⇒ Object
-
#initialize(start_delta = DEFAULT_START_DELTA, alpha = DEFAULT_ALPHA) ⇒ RecordToRecordTravelAcceptance
constructor
A new instance of RecordToRecordTravelAcceptance.
- #to_s ⇒ Object
Constructor Details
#initialize(start_delta = DEFAULT_START_DELTA, alpha = DEFAULT_ALPHA) ⇒ RecordToRecordTravelAcceptance
Returns a new instance of RecordToRecordTravelAcceptance.
38 39 40 41 42 |
# File 'lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb', line 38 def initialize(start_delta = DEFAULT_START_DELTA, alpha = DEFAULT_ALPHA) @delta = start_delta @alpha = alpha @best = nil end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
33 34 35 |
# File 'lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb', line 33 def alpha @alpha end |
#delta ⇒ Object
Returns the value of attribute delta.
33 34 35 |
# File 'lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb', line 33 def delta @delta end |
Instance Method Details
#accepts(parent, child, generation) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb', line 44 def accepts(parent, child, generation) @best = parent if @best.nil? accepted = false if child > @best @best = child accepted = true else threshold = Math.sqrt( (child.fitness - @best.fitness)**2 ) accepted = threshold < @delta end @delta *= @alpha accepted end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb', line 60 def to_s "Record-to-Record-Travel Acceptance" end |