Decay Schedules#

Classes for defining decay schedules for simulated annealing.

Geometric Decay#

Schedule for geometrically decaying the simulated annealing temperature parameter T according to the formula:

Formula#

\[ T(t) = \max(T_0 \times r^t, T_{min}) \]

where
- \( T_0 \) is the initial temperature (at time \( t = 0 \));
- \( r \) is the rate of geometric decay; and
- \( T_{min} \) is the minimum temperature value.

Class declaration#

class GeomDecay(init_temp=1.0, decay=0.99, min_temp=0.001)

Parameters [source]

  • init_temp (float, default: 1.0) – Initial value of temperature parameter T. Must be greater than 0.
  • decay (float, default: 0.99) – Temperature decay parameter, r. Must be between 0 and 1.
  • min_temp (float, default: 0.001) – Minimum value of temperature parameter. Must be greater than 0.

Class method#

Evaluate the temperature parameter at time t.

evaluate(t)

Parameters: t (int) – Time at which the temperature parameter T is evaluated.

Returns: temp (float) – Temperature parameter at time t.

Example#

>>> import mlrose_ky
>>> schedule = mlrose_ky.GeomDecay(init_temp=10, decay=0.95, min_temp=1)
>>> schedule.evaluate(5)
7.73780...

Arithmetic Decay#

Schedule for arithmetically decaying the simulated annealing temperature parameter T according to the formula:

Formula#

\[ T(t) = \max(T_{0} - rt, T_{min}) \]

where
* \( T_{0} \) is the initial temperature (at time t = 0);
* \( r \) is the rate of arithmetic decay; and
* \( T_{min} \) is the minimum temperature value.

Class declaration#

class ArithDecay(init_temp=1.0, decay= 0.0001, min_temp=0.001)

Parameters [source]

  • init_temp (float, default: 1.0) – Initial value of temperature parameter T. Must be greater than 0.
  • decay (float, default: 0.0001) – Temperature decay parameter, r. Must be greater than 0.
  • min_temp (float, default: 0.001) – Minimum value of temperature parameter. Must be greater than 0.

Class method#

Evaluate the temperature parameter at time t.

evaluate(t)

Parameters: t (int) – Time at which the temperature paramter T is evaluated.

Returns: temp (float) – Temperature parameter at time t.

Example#

>>> import mlrose_ky
>>> schedule = mlrose_ky.ArithDecay(init_temp\=10, decay=0.95, min_temp\=1)
>>> schedule.evaluate(5)
5.25

Exponential Decay#

Schedule for exponentially decaying the simulated annealing temperature parameter T according to the formula.

Formula#

\[ T(t) = \max(T_{0} e^{-rt}, T_{min}) \]

where:
* \( T_{0} \) is the initial temperature (at time t = 0);
* \( r \) is the rate of arithmetic decay; and
* \( T_{min} \) is the minimum temperature value.

Class declaration#

class ExpDecay(init_temp=1.0, exp_const=0.005, min_temp=0.001)

Parameters [source]
* init_temp (float, default: 1.0) – Initial value of temperature parameter T. Must be greater than 0.
* exp_const (float, default: 0.005) – Exponential constant parameter, r. Must be greater than 0.
* min_temp (float, default: 0.001) – Minimum value of temperature parameter. Must be greater than 0.

Class method#

Evaluate the temperature parameter at time t.

evaluate(t)

Parameters: t (int) – Time at which the temperature paramter T is evaluated.

Returns: temp (float) – Temperature parameter at time t.

Example#

>>> import mlrose_ky
>>> schedule = mlrose_ky.ExpDecay(init_temp=10, exp_const=0.05, min_temp=1)
>>> schedule.evaluate(5)
7.78800...

Write your own custom schedule#

Class for generating your own temperature schedule.

class CustomSchedule(schedule, **kwargs)

Parameters [source]
* schedule (callable) – Function for calculating the temperature at time t with the signature schedule(t, **kwargs).
* kwargs (additional arguments) – Additional parameters to be passed to schedule.

Example#

>>> import mlrose_ky
>>> def custom(t, c): return t + c
>>> kwargs \= {'c': 10}
>>> schedule \= mlrose_ky.CustomSchedule(custom, \*\*kwargs)
>>> schedule.evaluate(5)
15

Class method#

Evaluate the temperature parameter at time t.

evaluate(t)

Parameters: t (int) – Time at which the temperature paramter T is evaluated.

Returns: temp (float) – Temperature parameter at time t.