Quiz 2

🌡️ Simulated Annealing & Tabu Search

622 words
3 min read
Python Week 1: the first filter for runtime behavior
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

text
SimulatedAnnealing(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:
P(accept)=eΔE/TP(\text{accept}) = e^{-\Delta E / T}
  • ΔE>0\Delta E > 0: how much worse the move is
  • TT: current temperature Analysis:
  • High T: eΔE/T1e^{-\Delta E / T} \approx 1 — almost all moves accepted
  • Low T: eΔE/T0e^{-\Delta E / T} \approx 0 — only improving moves accepted
  • Large ΔE\Delta E: lower acceptance probability (proportional to how bad)

3.4 Cooling Schedules

ScheduleFormulaCharacteristics
LinearTk=T0kβT_k = T_0 - k\betaSimple, fast cooling
ExponentialTk=T0αkT_k = T_0 \cdot \alpha^kCommon, α ≈ 0.95
LogarithmicTk=T0/log(k+1)T_k = T_0 / \log(k+1)Theoretical guarantee
AdaptiveBased on performanceComplex 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

text
TabuSearch(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

AlgorithmEscapes Local Optima?MemoryKey ParameterBest For
Hill ClimbingNoO(1)Simple landscapes
Random Restart HCPartiallyO(1)Num restartsModerate landscapes
Simulated AnnealingYesO(1)Cooling scheduleContinuous optimization
Tabu SearchYesO(tabu size)Tabu tenureCombinatorial 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
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.