alhambra.anneal#

Module Contents#

Classes#

Annealer

Performs simulated annealing by calling functions to calculate

Functions#

round_figures(x, n)

Returns x rounded to n significant figures.

time_string(seconds)

Returns time in seconds as a string formatted HHHH:MM:SS.

alhambra.anneal.round_figures(x, n)[source]#

Returns x rounded to n significant figures.

alhambra.anneal.time_string(seconds)[source]#

Returns time in seconds as a string formatted HHHH:MM:SS.

class alhambra.anneal.Annealer(energy, move)[source]#

Performs simulated annealing by calling functions to calculate energy and make moves on a state. The temperature schedule for annealing may be provided manually or estimated automatically.

anneal(state, Tmax, Tmin, steps, updates=0)[source]#

Minimizes the energy of a system by simulated annealing.

Keyword arguments: state – an initial arrangement of the system Tmax – maximum temperature (in units of energy) Tmin – minimum temperature (must be greater than zero) steps – the number of steps requested updates – the number of updates to print during annealing

Returns the best state and energy found.

auto(state, minutes, steps=2000)[source]#

Minimizes the energy of a system by simulated annealing with automatic selection of the temperature schedule.

Keyword arguments: state – an initial arrangement of the system minutes – time to spend annealing (after exploring temperatures) steps – number of steps to spend on each stage of exploration

Returns the best state and energy found.