Optimization1983intermediate10 min read
Optimization by Simulated Annealing
الأمثَلة بالتلدين المحاكى
Kirkpatrick, S. · Gelatt, C. D. · Vecchi, M. P. — Science
The problem
Many real-world problems — circuit layout, scheduling, routing — have rugged cost landscapes with countless local minima. Greedy algorithms that only accept improving moves get trapped in the nearest , which may be far from the global optimum. Exact methods are computationally intractable for large instances because combinatorial problems grow factorially. By 1983, no general-purpose heuristic could reliably escape local minima across diverse problem domains.
The contribution
A direct analogy between statistical mechanics and . In metallurgy, slowly cooling a molten metal lets atoms find their lowest-energy crystal arrangement. Kirkpatrick et al. mapped this to optimization: the is the energy, a candidate solution is an atomic configuration, and a control parameter called "" governs how readily the accepts uphill (worsening) moves via the Metropolis criterion. At high temperature, the algorithm explores freely; as temperature decreases on a "," it becomes increasingly greedy and converges toward the global optimum. Experiments on graph partitioning and the demonstrated competitive results on NP-hard problems.
The impact
One of the most cited papers in optimization history (46,000+ citations). became a standard tool in VLSI design, operations research, protein folding, and machine learning. It spawned an entire family of physics-inspired metaheuristics — genetic algorithms, particle swarm optimization, and quantum annealing. Its core insight — that controlled randomness can escape local minima — remains foundational to modern stochastic optimization and even influenced the design of MCMC sampling methods in Bayesian inference.
Imagine a blindfolded hiker dropped onto a mountain range at night, searching for the lowest valley. A greedy hiker only walks downhill — she reaches the bottom of the nearest dip and stops, never knowing a deeper valley lies two ridges away.
Simulated annealing gives the hiker a flashlight that dims over time. While the light is bright (high temperature), she deliberately climbs uphill to explore new territory. As the light fades, she becomes more cautious, refusing to climb unless the uphill path is short. By dawn (zero temperature), she walks only downhill — but by then she has surveyed enough terrain that the valley she settles into is almost certainly the deepest one.
The problem: greedy search gets trapped
Many optimization problems are like navigating a rugged landscape in the dark. The cost function defines the height at every point, and the goal is to find the lowest valley — the . The simplest approach, iterative improvement (hill climbing in reverse), repeatedly moves to a neighboring solution with lower cost. It always converges, but it converges to the nearest local minimum, which may be arbitrarily far from the best solution.
For small or smooth problems this is fine. But real-world combinatorial optimization problems — laying out millions of transistors on a chip, routing a delivery truck through hundreds of cities, scheduling thousands of tasks — have cost surfaces riddled with local minima. A greedy optimizer applied to a random starting point almost never reaches the global optimum.
The inspiration: how metals crystallize
When a blacksmith heats metal until it melts, atoms vibrate wildly and explore many configurations. If the metal is cooled slowly (annealed), atoms gradually settle into a regular crystal lattice — the arrangement with the lowest energy. But if cooled too fast (quenched), atoms freeze in a disordered arrangement with higher energy — they got trapped in a local energy minimum.
Kirkpatrick, Gelatt, and Vecchi noticed a deep analogy: the cost function of an optimization problem is like the energy of a physical system, and a candidate solution is like an atomic configuration. The , invented in 1953 to simulate thermal equilibrium, already provided a recipe for sampling configurations at a given temperature. The key insight was to decrease the temperature over time — importing the annealing schedule from metallurgy into the optimization world.
The engine: the Metropolis criterion
The Metropolis algorithm is the engine inside simulated annealing. At each step it proposes a small random change to the current solution, computes the change in cost , and decides whether to accept or reject. The decision rule is elegantly simple:
- If the new solution is better (): always accept.
- If the new solution is worse (): accept with .
At high temperature , even large uphill moves have a reasonable chance of acceptance — the algorithm explores freely. As decreases, the probability of accepting a worsening move shrinks exponentially, and the algorithm becomes increasingly greedy. This is the controlled transition from to .
Think of it like a coin toss with a biased coin. The bias depends on two things: how bad the proposed move is (), and how hot the system is (). A barely-worse move at high temperature is almost certainly accepted. A much-worse move at low temperature is almost certainly rejected. The genius is that this simple mechanism is enough to guarantee to the global optimum — given a sufficiently slow cooling schedule.
The cooling schedule: from chaos to order
The cooling schedule controls how temperature decreases over time. It is the bridge between the physical analogy and practical optimization. Too fast and the algorithm quenches into a poor local minimum — too slow and it wastes computation exploring territory it has already mapped.
The original paper used a geometric schedule: with typically between 0.9 and 0.99. At each temperature the algorithm runs enough iterations to reach quasi-equilibrium before cooling further. Other schedules include linear decay and logarithmic decay (), which has a theoretical guarantee of convergence but is impractically slow.
In practice, tuning the schedule is part art, part experiment: start hot enough that ~95% of moves are accepted, cool slowly through the temperature range where the acceptance ratio drops from 90% to 10% (this is where structure forms), then quench at the end.
The algorithm: step by step
Putting it all together, simulated annealing works in four stages:
- Initialize. Pick a random starting solution and a high initial temperature .
- Propose. Generate a random neighbor of the current solution.
- Decide. Compute . If , accept . Otherwise, accept with probability .
- Cool. After enough iterations at the current temperature, reduce according to the cooling schedule. Repeat until is near zero or the solution has stabilized.
The key design choices are: how to define the neighborhood (what counts as a "small change"), how to set the initial temperature, and which cooling schedule to use. These are problem-specific — there is no universal best setting, which is both the method's flexibility and its limitation.
The theory: why it works
The theoretical backbone of simulated annealing comes from the in statistical mechanics. At thermal equilibrium, a physical system at temperature occupies with probability proportional to . This means lower-energy states are exponentially more likely, but higher-energy states are not impossible — they occur with a frequency that depends on temperature.
The Metropolis algorithm generates a whose stationary is exactly the Boltzmann distribution at the current temperature. When is high, the distribution is nearly uniform — all states are explored. When is low, probability mass concentrates on the lowest-energy (lowest-cost) states. As , the distribution converges to a point mass on the global minimum.
The convergence theorem states: if the temperature decreases slowly enough ( for a constant related to the energy landscape), then the algorithm converges to the global optimum with probability 1. This is a powerful guarantee — but the required cooling rate is too slow for practice, so real implementations use faster schedules and accept near-optimal solutions.
Applications: TSP and circuit design
The original paper demonstrated simulated annealing on two NP-hard problems:
The Traveling Salesman Problem (TSP) — find the shortest route visiting every city exactly once. The neighborhood move is a 2-opt swap: reverse a segment of the tour. Kirkpatrick et al. tested on instances with hundreds to thousands of cities and found results competitive with the best-known heuristics of the time.
Graph partitioning for VLSI — divide a circuit's components into two groups so that the number of wires crossing the partition (the "cut") is minimized. This directly impacts chip manufacturing cost. The neighborhood move swaps a component between groups. Simulated annealing found partitions that significantly beat rapid quenching (greedy optimization from a random start), demonstrating that the controlled acceptance of uphill moves is essential.
The same idea in code
Simplified to show the idea — not the real implementation.
import math, random
def simulated_annealing(cost_fn, neighbor_fn, s0, T0=100, alpha=0.995, n_iter=1000):
"""
cost_fn(s) — returns the cost of solution s
neighbor_fn(s) — returns a random neighbor of s
s0 — initial solution
T0, alpha — initial temperature and geometric decay rate
"""
s = s0
best = s
T = T0
for _ in range(n_iter):
s_new = neighbor_fn(s) # propose a neighbor
delta = cost_fn(s_new) - cost_fn(s) # cost difference
if delta <= 0 or random.random() < math.exp(-delta / T):
s = s_new # accept: better or lucky
if cost_fn(s) < cost_fn(best):
best = s # track the best ever seen
T *= alpha # cool down
return best
# That's it. The entire algorithm fits in 12 lines.
# The magic is in cost_fn, neighbor_fn, and the cooling schedule.Why it mattered
1953
Metropolis Algorithm
Metropolis, Rosenbluth et al. invent the algorithm for sampling states of a physical system at thermal equilibrium — the engine that simulated annealing would later repurpose.
1983
Simulated Annealing (this paper)
Kirkpatrick, Gelatt, and Vecchi bridge statistical mechanics and combinatorial optimization. The paper appears in Science and ignites a wave of physics-inspired metaheuristics.
1985
Černý's independent proposal
Vojtěch Černý independently proposes a similar thermodynamic approach for the traveling salesman problem, confirming the power of the idea.
1989
Convergence proofs
Hajek proves that logarithmic cooling guarantees convergence to the global optimum, providing the theoretical foundation for the method.
1994
Genetic Algorithms gain traction
Holland's genetic algorithms — inspired by evolution rather than physics — become another pillar of metaheuristic optimization, directly influenced by SA's success.
1998
Quantum Annealing
Kadowaki and Nishimori propose quantum annealing, replacing thermal fluctuations with quantum tunneling to escape local minima even faster — a direct descendant of the SA idea.
2011
D-Wave quantum annealer
D-Wave Systems builds the first commercial quantum annealing processor, demonstrating that Kirkpatrick's analogy extends all the way to hardware.
Simulated annealing showed that borrowing ideas across fields — physics to computer science — could yield powerful algorithms with both theoretical guarantees and practical utility. Today it remains a go-to baseline for any new combinatorial optimization problem, and its descendants power everything from drug discovery to chip design.
CitationKirkpatrick, Gelatt, Vecchi. Optimization by Simulated Annealing. Science, 1983.
Terms in this paper
- Simulated Annealingالمحاكاة بالتلدين
- Metaheuristicما فوق الاستدلالية
- Metropolis Algorithmخوارزمية متروبولس
- Cooling Scheduleجدول التبريد
- Local Minimumالنهاية الصغرى المحلية
- Global Minimumالنقطة الدنيا القصوى
- Combinatorial Optimizationالأمثَلة التوافقية
- Traveling Salesman Problemمسألة البائع المتجول
- Boltzmann Distributionتوزيع بولتزمان
- Acceptance Probabilityاحتمال القبول