Advanced Topic 51 of 51 Algorithms
Simulated Annealing
Probabilistic optimization inspired by metallurgical cooling.
How it works
Simulated annealing is a randomized optimization method inspired by cooling metal. It starts with a candidate solution and a high temperature, proposes small random changes and always accepts improvements but accepts worse moves with probability exp(minus delta over T). As the temperature is gradually lowered, the search shifts from exploration to refinement, helping it escape local optima.
Step-by-step walkthrough
- Start with a random solution and a high temperature.
- Try a random neighbor, accept it if it is better.
- If it is worse, accept it with probability e to the power of minus delta over T, so the search can escape local minima.
- Gradually lower the temperature, fewer bad moves are accepted.
- When cold, it behaves like pure hill climbing and settles in a good solution.
Where it is used
Traveling salesman and routing problems, VLSI chip placement, timetabling, scheduling, protein folding and parameter tuning for machine learning use simulated annealing.
Common pitfall
Results depend heavily on the cooling schedule, neighborhood definition and initial temperature, which need tuning. Cooling too fast traps it in poor local optima, and too slowly wastes time. It gives no optimality guarantee, so run several times, keep the best solution seen and fix seeds for reproducibility.
Where it fits in the course
Simulated Annealing is topic 51 of 51 in Algorithms, rated Advanced. It follows Fast Fourier Transform. It is the last topic in this area.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Algorithms quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Algorithms quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Simulated Annealing?
Where do people use Simulated Annealing?
What is the most common mistake with Simulated Annealing?
What should I learn before this topic?
How can I practice it?
Is Simulated Annealing hard to learn?
How long does it take to learn Simulated Annealing?
Which topics are related to Simulated Annealing?
What should I study after Simulated Annealing?
Related topics
- Fast Fourier Transform (Algorithms)
- Convex Hull (Algorithms)
- Amortized Analysis (Algorithms)
- Approximation Algorithms (Algorithms)