Simulated Annealing
Hill climbing that sometimes accepts worse moves, with the chance shrinking as it "cools".
The idea
Inspired by slowly cooling metal. At high temperature the search happily accepts bad moves, which lets it escape local peaks. As the temperature falls it becomes pickier, settling into a good solution. A worse move of size Δ is accepted with probability e^(−Δ/T).
P(accept worse) = exp(−Δ / T)
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- brighter = better
- accepted
- rejected
Start hot: bad moves are accepted often, so the search can leave small peaks.
- T:
- 1
- best:
- 0.13
Dark spots on the map are poor settings; bright spots are good. One of the peaks is the tallest.
Step by step
- 1Start with a solution and a high temperature T.
- 2Propose a random neighbour.
- 3Accept it if better; if worse, accept with probability e^(−Δ/T).
- 4Lower T a little and repeat until T is very small.
Where it is used
Circuit layout, timetabling, travelling-salesman style problems.
Watch out for
The cooling schedule matters a lot: cool too fast and it behaves like hill climbing.