The following pseudo-code describes the Simulated Annealing algorithm.
SIMULATED-ANNEALING(problem, schedule)
curr ← Randomly generated node
for t = 1, 2, 3,...
T = schedule(t)
// System has reached final configuration
if T == 0
return curr
end
next ← randomly generated successor of curr
ΔE ← next.value - curr.value
// Always accept a better successor
if ΔE > 0
curr ← next
else
// ΔE is less than 0
prob ← e^{ΔE / T}
if rand_double() <= prob
curr ← next
end
end
end
end
Below is a graph of the exponential function with a negative argument: