Simulated Annealing and Tabu Search
The last two chapters sent a whole population out to search at once. The two methods here do the opposite: a single solution walks the space alone, one step at a time. A lone walker doing greedy descent gets trapped in the first valley it finds — so the entire art of single-solution search is giving the walker a disciplined way to climb out of a good-but-not-best valley. Simulated annealing borrows the trick from physics: accept an uphill step on the roll of a die whose bias cools over time. Tabu search borrows it from bookkeeping: always take the best available step, even uphill, but keep a memory of where you have been so you never wander back. One escapes by chance; the other escapes by remembering.
- The difference between trajectory and population methods, and why a lone greedy walker gets trapped in local optima.
- The physics behind simulated annealing — the Boltzmann factor and why slow cooling reaches a global minimum.
- The Metropolis acceptance rule: always take improvements, take worsenings with probability \(e^{-\Delta E/T}\).
- Cooling schedules — geometric, linear and logarithmic — and the convergence guarantee nobody can afford.
- Tabu search: moving to the best admissible neighbour, the tabu list, tabu tenure, and the aspiration criterion.
- Short- and long-term memory, intensification and diversification, and when to choose SA, TS, a GA, PSO or ACO.
One Walker & the Local-Optimum Trap
Chapters 24 and 25 were population methods: a crowd of candidate solutions searched in parallel, and progress came from how members shared information. The two methods in this chapter are single-solution methods — also called trajectory methods, because the algorithm maintains exactly one current solution and traces a path through the search space, replacing that solution with a neighbour at each step. There is no crowd, no crossover, no swarm. There is one point, moving.
The natural way to move one point is local search: look at the neighbours of the current solution, step to the best one, and repeat. This is hill climbing (or, for a minimisation, steepest descent by trial). It is fast, simple, and greedy — and greed is exactly its downfall. The instant every neighbour is worse than where you stand, local search halts. It has found a local optimum, and it has no way to tell whether that is the best point in the whole space or merely the bottom of the nearest ditch.
Every escape mechanism must thread a needle. Accept uphill moves too freely and the walker never settles — the search is a random walk that finds nothing. Accept them too rarely and it re-freezes into the first local optimum, exactly as plain descent did. The two methods manage this trade-off by opposite means. Simulated annealing makes the decision stochastic and lets a temperature parameter slide it from generous to strict. Tabu search makes the decision deterministic — always take the best neighbour available — and uses memory to stop the walker from immediately undoing an uphill step and cycling forever.
The Physics of Annealing
Simulated annealing, introduced by Kirkpatrick, Gelatt and Vecchi in 1983, is a near-literal transcription of a metallurgical process. To anneal a metal, you heat it until its atoms are jostling freely, then cool it slowly. Given time at each temperature, the atoms drift into the low-energy, highly ordered arrangement of a crystal — the global minimum of the material's energy. Cool too fast — quench it — and the atoms freeze wherever they happen to be, locked into a brittle, high-energy amorphous solid. That is a local minimum, reached by moving too greedily toward the nearest low-energy state.
The bridge to optimization is a dictionary. The objective function \(f\) plays the role of energy \(E\); a candidate solution is a configuration of the system; and a fictitious temperature \(T\) becomes the algorithm's single control knob. Minimising \(f\) is then just annealing the system to its ground state.
| Physical annealing | Optimization |
|---|---|
| Atomic configuration | Candidate solution \(\mathbf{x}\) |
| Energy \(E\) of a configuration | Objective value \(f(\mathbf{x})\) |
| Temperature \(T\) | Control parameter (a schedule, not a real temperature) |
| Slow cooling to the crystal | Convergence to the global minimum |
| Fast quench to a defective solid | Getting stuck in a local minimum |
Physics also hands us the acceptance rule. At thermal equilibrium a system occupies a state of energy \(E\) with probability proportional to the Boltzmann factor \(e^{-E/kT}\). The consequence that matters is the relative likelihood of two states differing in energy by \(\Delta E\):
Read what this says physically. When \(T\) is large, the exponent is near zero and the ratio is near one: a higher-energy state is almost as likely as a lower one, so the system roams freely across energy barriers. As \(T\) falls, the ratio collapses toward zero: high-energy states become vanishingly unlikely, and the system is confined to the lowest energies it can find. That single knob slides the system from free exploration to strict exploitation — and it is the whole idea we are about to borrow. Metropolis and colleagues had already, in 1953, turned this factor into a rule for sampling such a system; annealing simply cools that rule.
The Simulated Annealing Algorithm
Drop the Boltzmann constant \(k\) — it only sets units — and the rule for whether to accept a proposed move becomes the heart of the method. From the current solution generate a neighbour, and let \(\Delta E = f(\mathbf{x}_{\text{new}}) - f(\mathbf{x}_{\text{current}})\) be the change in objective. For a minimisation:
A downhill (improving) move is always accepted. An uphill (worsening) move is accepted with a probability that shrinks as the move gets worse and as the temperature cools. In practice: draw \(r \sim U(0,1)\) and accept the uphill move if \(r < e^{-\Delta E/T}\).
Two limits reveal the whole character of the method. At high \(T\), \(e^{-\Delta E/T} \to 1\): nearly every move is accepted and the walker performs an almost unbiased random walk — pure exploration, oblivious to the landscape. At low \(T\), \(e^{-\Delta E/T} \to 0\) for any \(\Delta E > 0\): only improving moves survive, and simulated annealing degenerates into plain greedy descent — pure exploitation. The art is the transition between them, governed by the cooling schedule of the next section.
The complete procedure is short enough to state in full:
- Choose an initial solution \(\mathbf{x}\) and an initial temperature \(T = T_0\), high enough that most moves are accepted at the start.
- Generate a neighbour \(\mathbf{x}'\) by a random perturbation, and compute \(\Delta E = f(\mathbf{x}') - f(\mathbf{x})\).
- If \(\Delta E \le 0\), accept: \(\mathbf{x} \leftarrow \mathbf{x}'\). Otherwise accept with probability \(e^{-\Delta E/T}\) (draw \(r\), accept if \(r < e^{-\Delta E/T}\)).
- Repeat steps 2–3 for a number of moves at the current temperature (the "equilibration" at \(T\)).
- Lower the temperature by the cooling schedule, and keep a separate record of the best solution ever seen.
- Stop when \(T\) is negligibly small or no improvement has occurred for many temperatures. Report the best solution recorded, not the final one.
Cooling Schedules & Convergence
The cooling schedule — how \(T\) is lowered — is to simulated annealing what the inertia schedule is to PSO and the evaporation rate is to ACO: the single dial that trades speed of convergence against quality of solution. Cool too fast and you quench into a local optimum; cool too slowly and you waste an enormous evaluation budget on a search that is barely making progress. Three schedules dominate.
| Schedule | Rule | Character |
|---|---|---|
| Geometric (exponential) | \(T_{k+1} = \alpha\,T_k\), with \(\alpha \in [0.8,\,0.99]\) | The practical default; \(T\) decays by a constant fraction each step, fast then flattening |
| Linear | \(T_k = T_0 - \beta k\) | Simple, but spends too little time at low temperatures where fine tuning happens |
| Logarithmic | \(T_k = \dfrac{c}{\ln(k+1)}\) | The only schedule with a proven convergence guarantee — and far too slow to use |
The geometric rule is what almost everyone actually runs. A typical setup takes \(\alpha = 0.95\), holds a fixed number of moves at each temperature, and starts \(T_0\) high enough that around 80% of moves are accepted initially. It is cheap, robust, and has one free parameter with an intuitive meaning: \(\alpha\) closer to 1 means slower cooling, more thorough search, and more evaluations.
The logarithmic schedule is the one the theory loves. Geman and Geman proved that if the temperature is lowered no faster than \(T_k \ge c/\ln(k+1)\) for a large enough constant \(c\), simulated annealing converges to the global optimum with probability one. This is a genuine and remarkable guarantee — no other metaheuristic in this book has one so clean.
The catch is in the arithmetic. Because \(T\) falls like \(1/\ln k\), reaching a temperature requires an iteration count that grows exponentially as \(T\) drops. Halving the temperature roughly squares the number of iterations needed. The guaranteed schedule is therefore astronomically slower than exhaustive search would be — it exists to prove SA can find the optimum, not to be run.
Tabu Search: Memory Against Cycling
Tabu search, developed by Fred Glover in 1986, escapes local optima by a completely different philosophy. Where annealing is stochastic and memoryless — the next move depends only on the current state, never on the path taken — tabu search is deterministic and built entirely around memory. Its guiding metaphor is not physics but a determined explorer with a notebook.
The core rule is bold: at every step, move to the best solution in the neighbourhood — even if it is worse than where you stand. Plain local search stops when all neighbours are worse; tabu search does not stop, it simply takes the least-bad neighbour and keeps walking. That single change lets the walker climb out of any local optimum on the very next step.
But it creates an obvious disaster. If you are at a local minimum and forced to step to the least-bad neighbour, the best move from that neighbour is usually to step straight back down into the minimum you just left. The walker oscillates between the two forever. The fix is the idea that names the method: forbid it. A tabu list records recently visited solutions (or, more commonly, the moves that produced them) and marks them tabu — off-limits — for a while, so the walker cannot immediately reverse itself and is driven onward into new territory.
Then record the reverse of the move just made onto the tabu list, so the walker cannot undo it for the next few iterations. The willingness to worsen provides the escape; the tabu list stops the escape from collapsing into a cycle.
The full loop mirrors local search with two additions — a memory, and the forced best-admissible move:
- Start from an initial solution; set it as the current solution and as the best-so-far. Begin with an empty tabu list.
- Generate the neighbourhood of the current solution and evaluate every candidate.
- Select the best admissible neighbour: the best-valued one whose move is not tabu — or one that is tabu but passes the aspiration test of Section 26-6.
- Move to it, even if it worsens the objective. Add the reverse move to the tabu list; drop entries whose tenure has expired.
- If the new solution beats the best-so-far, update the best-so-far.
- Repeat from step 2 until the iteration budget is spent or no admissible move improves the best-so-far for many steps. Report the best-so-far.
Tenure, Aspiration & Long-Term Memory
Three refinements turn the bare idea into a working algorithm, and each is a lesson in how memory should be used.
The first is tabu tenure: how many iterations a move stays forbidden. It is the direct analogue of temperature — the knob that balances exploration against exploitation. Too short a tenure and the search cycles, because a reversed move becomes legal again before the walker has left the neighbourhood. Too long a tenure and too many good moves are locked out, driving the search away from promising regions and stalling it. Typical tenures are small — often a handful of iterations, sometimes scaled to the problem size, sometimes drawn randomly from a range to avoid pathological cycles.
The second refinement fixes an obvious flaw in blind forbidding. Because the tabu list stores move attributes, not whole solutions, it sometimes forbids a move that would lead somewhere excellent — better than anything seen so far — merely because that move's attribute is currently tabu. Overriding the tabu status in that case is the aspiration criterion.
Tabu status is a heuristic guard against cycling, not a law. If a forbidden move demonstrably leads to new record territory, there is no risk of cycling into an old trap — so the guard is lifted. This is the most common aspiration rule; others aspire by objective, by region, or by search direction.
The first two refinements use short-term memory — the recency-based tabu list, concerned only with the last few iterations. Powerful implementations add long-term memory that records the whole history of the search and drives two strategic behaviours:
| Strategy | Memory used | What it does |
|---|---|---|
| Intensification | Recency / elite solutions | Steer the search back toward regions that have historically contained good solutions — search harder where the gold was found |
| Diversification | Frequency of moves | Penalise moves and features used often, pushing the search into regions it has neglected — look where you have not yet looked |
SA vs TS & Method Comparison
Simulated annealing and tabu search solve the same problem — how a single walker escapes a local optimum — and it is worth seeing them side by side before folding them into the larger picture of Part 6.
| Simulated annealing | Tabu search | |
|---|---|---|
| Escape mechanism | Accept uphill moves at random, with probability \(e^{-\Delta E/T}\) | Always take the best neighbour, even uphill; memory prevents return |
| Nature | Stochastic; memoryless (a Markov chain) | Deterministic; memory-driven |
| Neighbourhood use | Samples one random neighbour per step | Examines the whole neighbourhood each step |
| Controlling knob | Temperature \(T\) and its cooling schedule | Tabu tenure (plus aspiration, long-term memory) |
| Cost per step | Cheap — one evaluation | Expensive — a full neighbourhood scan |
| Fails by | Cooling too fast (quenching into a local optimum) | Tenure mis-set: too short cycles, too long stalls |
Now widen the lens to all five metaheuristics of Part 6. The deepest division is not physical or biological inspiration — it is how many solutions the algorithm carries at once.
| Method | Class | Search state | Escapes local optima by | Natural home |
|---|---|---|---|---|
| Genetic algorithm (Ch. 24) | Population | A gene pool | Mutation + recombining diverse parents | Awkward or mixed encodings |
| Particle swarm (Ch. 25) | Population | Positions + \(\mathbf{p}_i,\ \mathbf{g}\) | Inertia carrying particles past attractors | Continuous tuning |
| Ant colony (Ch. 25) | Population | Pheromone matrix | Evaporation erasing premature consensus | Routing, scheduling |
| Simulated annealing | Trajectory | One current solution | Random uphill moves under a cooling \(T\) | General-purpose, easy to implement |
| Tabu search | Trajectory | One solution + memory | Forced best move + tabu memory | Structured combinatorial problems |
The through-line of Part 6 now closes. Every method here — population or trajectory — lives or dies by one thing: its willingness to move away from what currently looks best. A population resists its own consensus through mutation, inertia or evaporation. A single walker resists its own greed through a random uphill die-roll or a memory that forbids retreat. Different vocabulary, one principle: an optimizer must be built to do the locally wrong thing, on purpose, so it can find the globally right one.
Worked Examples
Problem. We are minimising. The current solution has \(f = 50\); a proposed neighbour has \(f = 53\). Should the move be accepted at \(T = 10\)? At \(T = 1\)? Take the random draw as \(r = 0.62\) in both cases.
Solution. The move worsens the objective, \(\Delta E = 53 - 50 = 3 > 0\), so it is not automatic — we use the Boltzmann rule. At \(T = 10\): \(P = e^{-3/10} = e^{-0.3} = 0.741\). Since \(r = 0.62 < 0.741\), the uphill move is accepted; the walker climbs to \(f = 53\). At \(T = 1\): \(P = e^{-3/1} = e^{-3} = 0.0498\). Now \(r = 0.62 > 0.0498\), so the identical move is rejected and the walker stays at \(f = 50\). Same move, same random number, opposite outcome — the only thing that changed is temperature. Early in the run the walker escapes; late in the run it refuses to leave a good valley. That is the entire mechanism in one calculation.
Problem. Fix a single uphill move of size \(\Delta E = 10\). Tabulate its acceptance probability as the temperature falls through \(T = 100,\ 10,\ 1\), and describe what phase of search each represents.
Solution. Apply \(P = e^{-10/T}\). At \(T = 100\): \(e^{-0.1} = 0.905\) — a 90% chance of accepting even this sizeable worsening; the search roams almost freely (exploration). At \(T = 10\): \(e^{-1} = 0.368\) — accepted about a third of the time; the search is selective but still crosses modest barriers (transition). At \(T = 1\): \(e^{-10} = 4.5\times10^{-5}\) — essentially never; only downhill moves survive and SA has become greedy descent (exploitation). The same move goes from routine to nearly impossible across two decades of temperature. This is why \(T_0\) must be set high relative to typical \(\Delta E\) — so that the search begins genuinely hot — and why the end of the schedule must be near zero — so it finishes by fine-tuning.
Problem. With geometric cooling \(T_{k+1} = \alpha T_k\) from \(T_0 = 100\), how many temperature steps are needed to reach \(T = 1\) for \(\alpha = 0.90\)? Compare \(\alpha = 0.95\) and \(\alpha = 0.99\).
Solution. After \(k\) steps \(T_k = 100\,\alpha^{k}\), so \(T_k = 1\) requires \(\alpha^{k} = 0.01\), i.e. \(k = \ln(0.01)/\ln\alpha = -4.605/\ln\alpha\). For \(\alpha = 0.90\): \(k = -4.605/-0.1054 = 43.7\), so about \(44\) steps. For \(\alpha = 0.95\): \(k = -4.605/-0.0513 = 89.8 \approx 90\) steps — roughly double. For \(\alpha = 0.99\): \(k = -4.605/-0.01005 = 458 \approx 459\) steps — more than ten times the first. And each "step" here holds many moves, so the total evaluation budget scales with \(k\). This is the cooling trade-off made concrete: pushing \(\alpha\) toward 1 buys a more thorough anneal at a proportional cost in run time, and the engineer chooses the point on that curve the budget allows.
Problem. We are minimising; the current solution has value \(20\), and the best-so-far is \(19\). Four moves lead to neighbours with values \(m_1\!\to\!22\), \(m_2\!\to\!15\), \(m_3\!\to\!24\), \(m_4\!\to\!18\). The tabu list currently forbids \(m_2\) and \(m_4\). Ignoring aspiration for now, which move is taken?
Solution. Scan the neighbourhood and strike out the tabu moves \(m_2\) and \(m_4\). The admissible candidates are \(m_1\!\to\!22\) and \(m_3\!\to\!24\). The best admissible one is \(m_1\), value \(22\) — so the walker moves to \(22\), which is worse than the current \(20\). That is tabu search behaving exactly as designed: it does not stop at a local optimum, it takes the least-bad legal step and keeps going. The reverse of \(m_1\) is now pushed onto the tabu list. Notice that the genuinely best neighbour, \(m_2\!\to\!15\), was passed over solely because it was tabu — a limitation the next example repairs.
Problem. Same neighbourhood as Example 4 — moves to \(22,\ 15,\ 24,\ 18\), with \(m_2\) and \(m_4\) tabu — and the same best-so-far of \(19\). Now apply the standard aspiration criterion. Which move is taken?
Solution. Before discarding the tabu moves, test them against the aspiration rule: a tabu move is allowed if it would beat the best-so-far. Move \(m_2\) leads to \(15\), and \(15 < 19\) — it would set a new record. Aspiration therefore lifts its tabu status, and \(m_2\) becomes admissible after all. It is now the best admissible neighbour by far, so the walker takes \(m_2\) and drops to \(15\), a new incumbent. Move \(m_4\!\to\!18\) also happens to aspire, since \(18 < 19\) likewise beats the best-so-far — but between the two aspiring moves the better one, \(m_2\), still wins. The lesson: the tabu list is a guard against cycling, not a cage. When a forbidden move demonstrably leads to unseen-quality territory, there is no old trap to cycle into, and the guard rightly stands aside.
Problem. A walker sits at a local minimum \(S\) with value \(30\); every neighbour is worse, the cheapest being \(S'\) at \(33\). From \(S'\), the best neighbour is \(S\) itself at \(30\); the second-best is \(S''\) at \(35\). Show what happens with tabu tenure \(0\) versus tenure \(1\).
Solution. With tenure 0 nothing is ever forbidden. Forced to take the best neighbour, the walker goes \(S\!\to\!S'\) (the only escape, uphill to \(33\)). At \(S'\) the best neighbour is \(S\) at \(30\), so it returns: \(S'\!\to\!S\). Back at \(S\), the best escape is again \(S'\)… the walker oscillates \(S \leftrightarrow S'\) forever and never sees \(S''\). With tenure 1, the step \(S\!\to\!S'\) records the reverse move \(S'\!\to\!S\) as tabu for one iteration. So at \(S'\) the move back to \(S\) is illegal, and the best admissible neighbour is \(S''\) at \(35\) — the walker is forced onward into new territory, exactly what was needed. This is the smallest possible cure for the smallest possible cycle. Longer cycles need proportionally longer tenure to break, which is precisely why tenure is tabu search's exploration–exploitation dial: it is the number of past moves the search is compelled to leave undone.
Chapter Summary
One current solution walks the space. Plain greedy descent halts at the first local optimum; escaping it means accepting a worse neighbour on purpose.
Accept improving moves always; accept a worsening move with probability \(e^{-\Delta E/T}\). High \(T\) explores; low \(T\) exploits.
Geometric \(T_{k+1}=\alpha T_k\) is the practical default. Logarithmic \(c/\ln(k{+}1)\) is provably convergent but far too slow to run.
Always take the best admissible neighbour, even uphill; a tabu list forbids the reverse move so the walker cannot cycle back.
Tenure is the escape dial — too short cycles, too long stalls. Aspiration lifts a tabu move that would beat the best-so-far.
SA for a quick, general, stochastic search; TS for structured combinatorial problems where a full neighbourhood scan pays off. Both escape by doing the locally wrong thing.
Problems
For the annealing problems, remember that only a positive \(\Delta E\) (a worsening move) needs the exponential — improving moves are automatic. For the tabu problems, always list the admissible neighbours first, then test any tabu move against aspiration. Difficulty rises down the list.
- Distinguish trajectory methods from population methods, and explain in one sentence why plain local search cannot escape a local optimum.
- State the Metropolis acceptance criterion for a minimisation, and interpret its two limiting cases \(T \to \infty\) and \(T \to 0\).
- A minimising SA is at \(f = 40\). It proposes a neighbour at \(f = 46\). Compute the acceptance probability at \(T = 20\), \(T = 6\), and \(T = 2\), and state whether the move is accepted if the draw is \(r = 0.30\) each time.
- Explain the physical annealing analogy term by term: what plays the role of energy, temperature, slow cooling, and a defective quench?
- Why should a simulated-annealing run report the best solution ever recorded rather than its final current solution? Give a concrete situation where the two differ.
- Using geometric cooling from \(T_0 = 200\) with \(\alpha = 0.92\), find the temperature after \(0, 5, 10\) steps, and the number of steps to fall below \(T = 2\).
- The logarithmic schedule \(T_k = c/\ln(k+1)\) with \(c = 12\): find \(T\) at \(k = 1, 9, 99, 999\), and use the values to explain why the provably convergent schedule is unusable in practice.
- We minimise. The current value is \(30\); best-so-far is \(28\). Moves give neighbours \(32,\ 27,\ 35,\ 25\); the tabu list forbids the moves to \(27\) and \(25\). Find the move taken (a) without aspiration and (b) with the standard aspiration criterion.
- Define tabu tenure and explain its effect at both extremes. If a search keeps returning to the same two solutions, is the tenure too long or too short, and why?
- Distinguish short-term from long-term memory in tabu search, and contrast intensification with diversification, naming the kind of memory each uses.
- A walker is at a local minimum \(S\) (value \(50\)); its cheapest neighbour is \(S'\) at \(54\), whose own best neighbour is \(S\) at \(50\) and second-best is \(S''\) at \(57\). Trace the trajectory for tenure \(0\) and tenure \(1\), and identify where each ends up after three moves.
- Compare simulated annealing and tabu search on three axes — stochastic vs deterministic, memoryless vs memory-based, and cost per step — then place both within the five-method landscape of Part 6 by stating what each is "built to resist."