Module: Annealing::Configuration::Coolers
- Defined in:
- lib/annealing/configuration/coolers.rb
Overview
Built-in cool down functions
Class Method Summary collapse
-
.exponential ⇒ Object
Reduce temperature exponentially on each step by the cooling rate.
-
.geometric(ratio = 2) ⇒ Object
Reduce temperature geometrically at a given ratio by the cooling rate.
-
.linear ⇒ Object
Reduce temperature linearly by the cooling rate.
Class Method Details
.exponential ⇒ Object
Reduce temperature exponentially on each step by the cooling rate
17 18 19 20 21 |
# File 'lib/annealing/configuration/coolers.rb', line 17 def exponential lambda { |_energy, temperature, cooling_rate, steps| temperature - (Math.exp(steps - 1) * cooling_rate) } end |
.geometric(ratio = 2) ⇒ Object
Reduce temperature geometrically at a given ratio by the cooling rate
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/annealing/configuration/coolers.rb', line 24 def geometric(ratio = 2) unless ratio.positive? raise(Annealing::Configuration::ConfigurationError, "geometric ratio must be positive") end lambda { |_energy, temperature, cooling_rate, steps| temperature - (cooling_rate * (ratio**(steps - 1))) } end |
.linear ⇒ Object
Reduce temperature linearly by the cooling rate
10 11 12 13 14 |
# File 'lib/annealing/configuration/coolers.rb', line 10 def linear lambda { |_energy, temperature, cooling_rate, _steps| temperature - cooling_rate } end |