LearnViz CompSci
Home / Learn / Algorithms / Simulated Annealing

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

  1. Start with a random solution and a high temperature.
  2. Try a random neighbor, accept it if it is better.
  3. If it is worse, accept it with probability e to the power of minus delta over T, so the search can escape local minima.
  4. Gradually lower the temperature, fewer bad moves are accepted.
  5. 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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Algorithms quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Simulated Annealing?
Probabilistic optimization inspired by metallurgical cooling. It belongs to Algorithms and is an advanced-level topic.
Where do people use Simulated Annealing?
Traveling salesman and routing problems, VLSI chip placement, timetabling, scheduling, protein folding and parameter tuning for machine learning use simulated annealing.
What is the most common mistake with Simulated Annealing?
Results depend heavily on the cooling schedule, neighborhood definition and initial temperature, which need tuning.
What should I learn before this topic?
Start with Fast Fourier Transform, the topic just before it in Algorithms.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Algorithms quiz.
Is Simulated Annealing hard to learn?
It is an Advanced topic. Expect to read the explanation more than once and to connect it with earlier topics. Working through a small example by hand helps most.
How long does it take to learn Simulated Annealing?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Simulated Annealing?
Fast Fourier Transform, Convex Hull, Amortized Analysis are closely connected. The full list is in the related topics section of this page.
What should I study after Simulated Annealing?
You have reached the last topic in Algorithms. Pick another area on the Learn page, or revisit this topic with the quiz.

Related topics