altbacken.external.temperature

Classes

AdaptiveCooling(initial_temperature[, ...])

Represents a cooling schedule with adaptive adjustments based on the state of the annealing process.

CosineCooling(initial_temperature, ...)

CosineCooling implements a cosine annealing schedule for temperature adjustment.

ExponentialCooling(initial_temperature[, ...])

Handles exponential cooling calculations.

LinearCooling(initial_temperature, step)

LogarithmicCooling(initial_temperature[, shift])

Implements a logarithmic cooling schedule generator.

PredefinedTemperature(temperature)

Represents a predefined sequence of temperature values.

class altbacken.external.temperature.PredefinedTemperature(temperature: Iterable[float])[source]

Bases: object

Represents a predefined sequence of temperature values.

This class allows storing a predefined series of temperatures and provides functionality to iterate over these temperatures in a generator-like fashion. It ensures the sequence is not empty upon instantiation.

temperature

Immutable sequence of predefined temperature values.

Type:

Sequence[float]

__init__(temperature: Iterable[float])[source]
__call__(state: AnnealingState[Any]) float[source]

Call self as a function.

class altbacken.external.temperature.ExponentialCooling(initial_temperature: float, cooling_rate: float = 0.9)[source]

Bases: object

Handles exponential cooling calculations.

This class provides functionality for simulating exponential cooling. It calculates decreasing temperature values based on an initial temperature and a specified cooling rate. The ExponentialCooling class can be used in optimization problems such as simulated annealing.

initial_temperature

The starting temperature for the cooling process.

Type:

float

cooling_rate

The rate at which the temperature decreases in each step. It must be a value in the range (0, 1).

Type:

float

__init__(initial_temperature: float, cooling_rate: float = 0.9)[source]
__call__(state: AnnealingState[Any]) float[source]

Call self as a function.

class altbacken.external.temperature.LogarithmicCooling(initial_temperature: float, shift: float = 1.1)[source]

Bases: object

Implements a logarithmic cooling schedule generator.

The class provides a cooling schedule based on a logarithmic function. It is used commonly in simulated annealing or other optimization algorithms to introduce a gradually decreasing parameter (like temperature). The logarithmic cooling ensures a steady and slow decrease in the temperature value over iterations, making it suitable for problems requiring fine-tuning during optimization.

initial_temperature

The starting temperature value for the cooling schedule.

Type:

float

shift

A shift factor added to the logarithm denominator to avoid division errors and regulate the cooling rate.

Type:

float

__init__(initial_temperature: float, shift: float = 1.1)[source]
__call__(state: AnnealingState[Any]) float[source]

Call self as a function.

class altbacken.external.temperature.LinearCooling(initial_temperature: float, step: float)[source]

Bases: object

__init__(initial_temperature: float, step: float)[source]
__call__(state: AnnealingState[Any]) float[source]

Call self as a function.

class altbacken.external.temperature.AdaptiveCooling(initial_temperature: float, cooling: float = 0.9, heating: float = 1.1)[source]

Bases: object

Represents a cooling schedule with adaptive adjustments based on the state of the annealing process.

This class implements a cooling mechanism for simulated annealing, where the temperature adapts based on the progress and quality of the current state. The temperature either decreases or slightly increases, aiming to balance exploration and exploitation during the optimization process.

initial_temperature

Initial temperature to start the annealing process.

Type:

float

cooling

Factor to decrement the temperature when the current value is not optimal.

Type:

float

heating

Factor to increment the temperature slightly to allow further exploration when the current value matches the best value.

Type:

float

__init__(initial_temperature: float, cooling: float = 0.9, heating: float = 1.1)[source]
__call__(state: AnnealingState[Any]) float[source]

Call self as a function.

class altbacken.external.temperature.CosineCooling(initial_temperature: float, max_iterations: int)[source]

Bases: object

CosineCooling implements a cosine annealing schedule for temperature adjustment.

This class is used to compute a temperature value based on the current iteration of an annealing process. The temperature adjusts according to a cosine curve and decreases gradually with iterations, reaching zero upon exceeding a specified maximum number of iterations.

initial_temperature

The starting temperature value used for the annealing process.

Type:

float

max_iterations

The maximum allowable iterations for the annealing process, beyond which the temperature is set to zero.

Type:

int

__init__(initial_temperature: float, max_iterations: int)[source]

Initializes the parameters for a simulated annealing process.

Parameters:
  • initial_temperature – Initial temperature for the annealing process, must be a positive floating point value.

  • max_iterations – Maximum number of iterations for the annealing process, must be a positive integer.

Raises:
  • ValueError – If initial_temperature is not a positive value.

  • ValueError – If max_iterations is not a positive value.

__call__(state: AnnealingState[Any]) float[source]

Calculates the temperature for the given state based on the annealing schedule.

This method computes the temperature using a cosine annealing schedule. The temperature decreases as the number of iterations increases, eventually reaching zero beyond the maximum number of iterations.

Parameters:

state (AnnealingState[Any]) – The current state of the annealing process. Contains iteration information.

Returns:

The temperature corresponding to the given state.

Return type:

float