🌡️ Simulated Annealing & Tabu Search
622 words
3 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# 🌡️ Simulated Annealing & Tabu Search ## 1. 🎯 Learning Objectives - Explain the analogy between annealing in metallurgy and search - Trace Simulated Annealing with a cooling schedule - Implement Tabu Search with tabu list management - Compare metaheuristics: when each is appropriate - Explain how SA escapes local...

🌡️ Simulated Annealing & Tabu Search
1. 🎯 Learning Objectives
- Explain the analogy between annealing in metallurgy and search
- Trace Simulated Annealing with a cooling schedule
- Implement Tabu Search with tabu list management
- Compare metaheuristics: when each is appropriate
- Explain how SA escapes local optima
2. 📖 Core Content
3.1 Simulated Annealing: Intuition
In metallurgy, annealing heats metal to high temperature then slowly cools it. High temperature allows atoms to move freely (explore state space), while cooling locks them into low-energy configurations (exploit best region).
Simulated Annealing (SA) applies this to search:
- Start with high temperature: accept bad moves with high probability (explore)
- Gradually cool down: accept fewer bad moves (exploit)
- At T=0: only accept improving moves (like Hill Climbing)
3.2 SA Algorithm
textSimulatedAnnealing(initial_state, move_gen, cost, schedule): current = initial_state T = initial_temperature for iteration = 1 to max_iterations: if T == 0: return current neighbor = random_neighbor(current, move_gen) delta_E = cost(neighbor) - cost(current) if delta_E < 0: // Better neighbor current = neighbor else: // Worse neighbor — accept with probability if random(0,1) < exp(-delta_E / T): current = neighbor T = schedule(T, iteration) return current
3.3 Acceptance Probability
The probability of accepting a worse move:
- ΔE>0: how much worse the move is
- T: current temperature Analysis:
- High T: e−ΔE/T≈1 — almost all moves accepted
- Low T: e−ΔE/T≈0 — only improving moves accepted
- Large ΔE: lower acceptance probability (proportional to how bad)
3.4 Cooling Schedules
| Schedule | Formula | Characteristics |
|---|---|---|
| Linear | Tk=T0−kβ | Simple, fast cooling |
| Exponential | Tk=T0⋅αk | Common, α ≈ 0.95 |
| Logarithmic | Tk=T0/log(k+1) | Theoretical guarantee |
| Adaptive | Based on performance | Complex but effective |
3.5 Tabu Search: Intuition
Tabu Search maintains a tabu list of recently visited states (or moves) and forbids returning to them. This prevents cycles and forces exploration of new regions.
3.6 Tabu Search Algorithm
textTabuSearch(initial_state, move_gen, cost, tabu_size): current = initial_state best = initial_state tabu_list = FIFO_queue(tabu_size) while not stopping_condition: // Generate neighbors not in tabu list candidates = [n for n in move_gen(current) if n not in tabu_list] if candidates is empty: break // Pick best neighbor (even if worse than current) current = argmin(cost(n) for n in candidates) // Update tabu list tabu_list.add(current) if len(tabu_list) > tabu_size: tabu_list.pop_oldest() // Update global best if cost(current) < cost(best): best = current return best
3.7 Key Concepts
Tabu List: Stores forbidden states/moves. Prevents short-term cycles. Tabu Tenure: How long a move stays tabu (list size). Aspiration Criterion: If a tabu move leads to a state better than the best found so far, it can still be accepted.
3.8 Comparison of Metaheuristics
| Algorithm | Escapes Local Optima? | Memory | Key Parameter | Best For |
|---|---|---|---|---|
| Hill Climbing | No | O(1) | — | Simple landscapes |
| Random Restart HC | Partially | O(1) | Num restarts | Moderate landscapes |
| Simulated Annealing | Yes | O(1) | Cooling schedule | Continuous optimization |
| Tabu Search | Yes | O(tabu size) | Tabu tenure | Combinatorial problems |
4. 📝 Practice Questions
Q1: At T=100, what is the probability of accepting a move with ΔE=10?Answer: P = exp(-10/100) = exp(-0.1) ≈ 0.905. High probability because temperature is high. Q2: At T=1, what is the probability of accepting ΔE=5?Answer: P = exp(-5/1) = exp(-5) ≈ 0.0067. Very low probability — at low temperature, SA mostly accepts only improving moves. Q3: What is the aspiration criterion in Tabu Search?Answer: If a move is tabu but leads to a state better than the global best found so far, it is still allowed. This prevents the algorithm from permanently rejecting the best possible solution just because it was recently visited. Join Discord PreviousSAT / CNFNextBeam Search & VND