Anneal

class Anneal : public minim::NewMinimiser<Anneal>

Simulated annealing minimisation.

Randomly perturbs the state each iteration, accepting or rejecting moves by the Metropolis criterion at the current temperature. The temperature decreases over the minimisation, by a cooling rate or a custom schedule, so that increasingly only downhill moves are taken.

Useful for finding global minma unlike other minimiser which typically look for local minima.

Public Functions

inline Anneal(double tempInit, double displacement)

Construct with an initial temperature and displacement.

Anneal &setDisplacement(double displacement)

Set the displacement used for random moves.

Anneal &setTempInit(double tempInit)

Set the initial temperature.

Anneal &setCoolingRate(double coolingRate)

Set the factor by which the temperature decreases each iteration.

Anneal &setCoolingSchedule(std::function<double(int)> coolingSchedule)

Set a custom cooling schedule as a function of the iteration number.

virtual Anneal &setMaxIter(int maxIter)

Set the maximum number of iterations.

Anneal &setMaxRejections(int maxRejections)

Set the maximum number of consecutive rejected moves before terminating.

virtual void init(State &state)

Initialise the minimiser before the first iteration.

virtual void iteration(State &state)

Perform a single minimisation iteration.

virtual bool checkConvergence(const State &state) override

Check whether the minimisation is converged.

Public Members

double displacement

The displacement used for random moves.

double tempInit

The initial temperature.

double coolingRate = 1

The factor by which the temperature decreases each iteration.

std::function<double(int)> coolingSchedule = nullptr

A custom cooling schedule, as a function of the iteration number.

int maxRejections = 0

Maximum number of consecutive rejected moves before terminating (0: disabled).