Subscribe
AI
7 min read

What Is Simulated Annealing? The 1953 Dice Roll That Still Beats Smarter Optimizers

A search rule invented at Los Alamos to sample hot gases lets optimizers accept bad moves on purpose and cool into better answers. How the algorithm works, where it came from, and why a 1980s heuristic still beats frontier RL on chip placement.

What Is Simulated Annealing? The 1953 Dice Roll That Still Beats Smarter Optimizers

Some problems have no shortcut. Find the best order to visit 500 cities, pack a warehouse, or place 100 million logic gates on a chip, and the search space grows faster than any computer can enumerate it. Greedy optimizers crawl downhill into the nearest good-enough answer and get stuck there. The oldest reliable way out of that trap is 70 years old, was named after a casino, and still beats several modern alternatives to this day.

The idea in one paragraph

Annealing is how metallurgists remove defects from a crystal. Heat a solid until its atoms are mobile, then cool it slowly. Near the melting point, atoms can still rearrange themselves out of bad configurations; if you quench the material instead, you freeze the disorder in. Simulated annealing ported that recipe to optimization: treat a candidate solution as a physical state, treat its cost as energy, and run a stochastic search whose "temperature" starts high and falls. Early on, the algorithm accepts bad moves almost as freely as good ones, which lets it walk out of local optima. Late in the run, it accepts almost nothing that makes the cost worse, and settles.

The rule, mechanically

Start at a solution, pick a random nearby modification, and compute the change in cost, delta E. If the move improves the cost, always take it. If it makes the cost worse, take it anyway with probability exp(-delta E / T), where T is the current temperature. Then cool T according to a schedule, typically multiplying it by a factor like 0.95 every few hundred iterations. At high temperature, an uphill step of almost any size is accepted, and the search wanders. As T falls toward zero, acceptance of worse moves dies out and the process becomes plain hill-climbing, hopefully parked in a basin it could only have reached by wandering first. That single exponential is the whole trick, and it is not an invention of the optimization era: it is the acceptance rule from the 1953 paper that created the method (Metropolis, Rosenbluth, Rosenbluth, Teller and Teller, "Equation of State Calculations by Fast Computing Machines," Journal of Chemical Physics 21, 1087-1092). If you have ever used a softmax "temperature" in a language model, you are looking at the same exponential: it converts costs or logits into acceptance probabilities, and higher values make the choice more random.

From a solitaire question to a code name (1946-1953)

Stanislaw Ulam conceived the method in 1946 while recovering from a brain operation. Playing solitaire at his bedside, he asked a question with no good combinatorial answer, the probability that a deal of 52 cards comes out winnable (the number of possible layouts is around 8 x 10^67, Los Alamos National Laboratory's history). Instead of counting, he reasoned, just deal the game a hundred times and count the successes. He brought the idea to John von Neumann, who saw that a fast electronic computer could run the sampling. Von Neumann wrote the first formulation for an electronic computer in a 1947 letter, and the group ran the first Monte Carlo neutron-diffusion calculations on the ENIAC in April and May of 1948.

The name came from Nicholas Metropolis, and it was a joke about Ulam's Polish uncle, a compulsive gambler who would borrow money from relatives because he had to go to Monte Carlo. The 1953 paper that made the method famous came from a team of five: Metropolis, Arianna W. Rosenbluth, Marshall N. Rosenbluth, Augusta H. Teller, and Edward Teller (Wikipedia's summary of the paper). Their goal was never optimization. They wanted to compute equations of state for gases and liquids by sampling molecular configurations, accepting a proposed move up in energy with probability exp(-delta E / kT) rather than rejecting every worse state. The insight that made it work is that you do not need to explore the whole configuration space; a random walk that obeys the acceptance rule spends exactly the right fraction of time in each state.

A ball hops across a jagged cost landscape from left to right, jumping ridges early in the run and settling into a deep basin as the ground cools in color from hot orange to blue

From sampler to optimizer (1970-1983)

Two steps turned physics sampling into a general problem solver. First, W. K. Hastings generalized the 1953 rule in 1970 to handle proposals that are not symmetric, adding the correction factor that keeps the Markov chain sampling the right distribution. The Metropolis-Hastings algorithm (Biometrika 57:97-109) is the ancestor of almost all Markov chain Monte Carlo used in statistics and machine learning since.

Second, in 1983, Scott Kirkpatrick, C. Daniel Gelatt and Mario Vecchi, all then at IBM's Thomas J. Watson Research Center, asked a different question: what if T is not a physical temperature at all, but a dial you control, lowered on purpose? Their Science paper "Optimization by Simulated Annealing" ran the Metropolis acceptance rule at a sequence of decreasing temperatures and tested it on traveling-salesman tours and the partitioning and placement problems of computer design. They also coined the name. The paper explicitly credits the annealing-in-solids analogy for the framework. A physicist in Prague, V. Cerny, published an equivalent procedure for the traveling salesman problem independently in 1985 (Physica D 11, 41-51).

The honest catch: no guarantee

Simulated annealing has a convergence theorem, and it is useless in practice. Geman and Geman (IEEE Transactions on Pattern Analysis and Machine Intelligence, 1984) proved that if the temperature falls no faster than a constant divided by the log of the iteration count, the algorithm eventually finds the global optimum with probability approaching one - provided the constant exceeds the highest energy barrier in the problem. The authors themselves called following that schedule a practical weakness of the theory; the cooling would take e-to-the-power-of-astronomical numbers of steps. Every annealing run that ships in the real world uses a faster schedule - usually geometric cooling - which means it is a heuristic with a good track record, not an algorithm with a receipt. That trade-off is exactly the no-free-lunch shape: excellent average behavior across many landscapes, no promise on any single one.

Two cooling curves on plain ground, one descending steeply and flattening into a shallow dip, the other descending slowly and stepping past the dip into a deeper basin further down

Why it still matters in the LLM era

It underwrites Bayesian machine learning. Metropolis-Hastings and its descendants are the machinery behind sampling-based inference when closed-form posteriors do not exist, and annealed sequences of distributions remain a serious technique for estimating normalizing constants that cannot be computed directly: Radford Neal's annealed importance sampling (Statistics and Computing 11:125-139, 2001; preprint) shows how to convert an annealing sequence of Markov chain steps into an unbiased importance sampler, and it is still cited and extended today. The Boltzmann machine, the 1980s stochastic network that prefigures today's generative models, was trained with exactly this kind of annealed temperature schedule (Ackley, Hinton and Sejnowski, Cognitive Science 9, 147-169, 1985).

It is the baseline that embarrassed frontier RL. In 2021 Google published a Nature paper, "A graph placement methodology for fast chip design", claiming its reinforcement-learning agent designed TPU floorplans faster than human experts. The paper's own appendix compared against simulated annealing using 2,880 CPU-hours. In 2023 a detailed re-evaluation, "The False Dawn", argued that a straightforward parallel simulated annealing pipeline beats the published RL results on wirelength and timing at comparable or lower compute, and CACM published a further re-evaluation arguing the same point. The dispute is unresolved in parts, but the documented outcome is blunt: under matched compute, simulated annealing from the 1980s was competitive with, and in the re-evaluations better than, a frontier reinforcement-learning pipeline for chip placement.

It is still a practical tool for ML people. Simulated annealing shows up in feature-subset search (an exploratory study on learning-to-rank feature selection, 2023) and in choosing which edges to keep in partially connected pruned networks (Neural Computation, 2022). When your agent needs to schedule a week of deliveries or reorganize a key-value cache, a few dozen lines of annealing remain the cheapest thing that works.

How to use it, briefly

The knobs that decide success are the neighborhood (what counts as a small modification), the starting temperature (tune so early acceptance sits near 50 percent), the cooling rate, and the number of iterations per temperature. There are no universal settings; the standard practice is to log the acceptance rate, try a geometric schedule with a factor between 0.90 and 0.99, and restart. The algorithm is cheap enough that brute-force tuning beats theory. The right way to read its history is not nostalgia but evidence: a rule invented to sample hot gas in 1953 has survived every generation of optimizers that has come since, including the ones with GPUs.

Sources

AILLMeducational