Stochastic Hill Climbing and Simulated Annealing

Accept bad moves on purpose — the sigmoid rule, the temperature dial, and the metallurgy metaphor that escapes local optima

The Simplest Explanation

Hill climbing is pure exploitation; a random walk is pure exploration. Simulated annealing sits between them with one dial:

Pick a random neighbor. If better, usually move. If worse, move anyway with probability P=11+e−ΔE/TP = \dfrac{1}{1 + e^{-\Delta E / T}} — high when the temperature T is hot, near zero when cold.

Then cool T slowly. Early = wander widely; late = greedy descent. Like metallurgy: heat metal so atoms roam, cool slowly so they settle into a low-energy crystal.

Remember This

ΔE > 0 (better) → P above 0.5. ΔE < 0 → P below 0.5. High T flattens everything toward 0.5 (random walk); low T sharpens into hill climbing.

The Algorithm

Mechanics of accepting: draw a random number in [0,1]; move if it falls below P.

The Temperature Dial

Vary ΔE, fix T = 10 (current value 107):

NeighborΔEP(accept)
150+430.99
120+130.79
10700.50
100−70.33
80−270.06

Better neighbors accepted almost surely; terrible ones almost never.

Vary T, fix ΔE = +13:

Te^(−13/T)P
1≈0≈1.00
50.0740.93
100.270.79
500.770.56
1000.880.53

Hot T compresses every probability toward 0.5 — even good moves are coin flips.

Why It Escapes Local Optima

Two local maxima A and B with valley M between:

Descending from A to M costs a small ΔE drop → decent acceptance probability. Descending from B would need a huge drop → rarely accepted. So SA hops out of shallow local optima easily and deep ones rarely — exactly the right bias.

Properties

PropertyValue
SpaceO(1) — current node only
Complete?Not guaranteed in finite time; converges to global optimum as T→0 slowly enough (theoretical result)
vs Iterated HCIHC randomizes starts; SA randomizes every move within one run
QuizAs T approaches infinity, simulated annealing behaves like...
QuizA WORSE neighbor (ΔE < 0) is accepted when...