Module: Annealing::Configuration::Terminators

Defined in:
lib/annealing/configuration/terminators.rb

Overview

Built-in termination condition check functions

Class Method Summary collapse

Class Method Details

.energy_or_temp_is_zero?Boolean

Returns true if a 0-energy state is detected, or when the temperature is at or below zero

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/annealing/configuration/terminators.rb', line 18

def energy_or_temp_is_zero?
  lambda { |state, energy, temperature|
    energy <= 0 || temp_is_zero?.call(state, energy, temperature)
  }
end

.temp_is_zero?Boolean

Returns true when the temperature is at or below zero

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/annealing/configuration/terminators.rb', line 10

def temp_is_zero?
  lambda { |_state, _energy, temperature|
    temperature <= 0
  }
end