AI in Motion

Artificial IntelligenceIntermediate1:38 video6 chapters

Hill Climbing and Simulated Annealing — lecture notes

Local search climbs towards better solutions — but gets stuck on local peaks. Simulated annealing adds controlled randomness to escape.

▶ Watch the animated lecture

0:001. Introduction

Introduction — Hill Climbing and Simulated Annealing

Some problems have too many possible solutions to search them all. Local search starts somewhere and keeps improving. Let us see how, and where it goes wrong.

0:122. Hill climbing

Hill climbing — Hill Climbing and Simulated Annealing

Imagine every possible solution as a point on a landscape, where height means quality. Hill climbing looks at its neighbours and steps to whichever is higher. It climbs quickly, but here it gets stuck on a small local peak, even though a much higher peak exists.

0:313. The problem

The problem — Hill Climbing and Simulated Annealing

Hill climbing fails in three classic ways. Local maxima, where every neighbour is worse even though a better peak exists. Plateaus with no slope to follow. And ridges, where you must first step sideways.

0:464. Simulated annealing

Simulated annealing — Hill Climbing and Simulated Annealing

Simulated annealing borrows an idea from metalworking. At first the temperature is high, and it often accepts worse moves, jumping around the landscape. As it cools, it becomes pickier. Here it escaped the local peak and settled on the global maximum. Because it uses randomness, it usually escapes, though not on every run.

1:095. The acceptance rule

The acceptance rule — Hill Climbing and Simulated Annealing

The rule is simple. Better moves are always accepted. A worse move is accepted with probability e to the power delta over T. When the temperature is high, bad moves are often accepted. As it cools, they become rare.

1:266. Recap

Recap — Hill Climbing and Simulated Annealing

To recap. Hill climbing always steps uphill, but gets trapped. Simulated annealing accepts some worse moves while hot, which helps it escape local peaks before settling down.

Key takeaways

  • Hill climbing moves to the best neighbour and can get stuck on local maxima.
  • Simulated annealing accepts worse moves with probability e^(Δ/T).
  • A high temperature encourages exploration; cooling focuses the search.
  • Randomness means annealing usually — but not always — finds the global best.

Check yourself

  1. Why did hill climbing stop on the smaller peak?
    Show answer

    Every neighbour there was lower — At a local maximum every nearby move is worse, so hill climbing stops.

  2. What happens to simulated annealing as the temperature falls?
    Show answer

    It accepts worse moves less often — Lower temperature makes e^(Δ/T) smaller for bad moves.

  3. A move that improves the solution is accepted…
    Show answer

    Always — Improvements are always accepted; only worse moves are probabilistic.

Go deeper

© 2026 Janin A Apurba, CSE, AUST · Advanced ICT Officer, CNRS-UNHCR. All rights reserved. Notes for the animated lecture at https://ai-in-motion.vercel.app/watch/hill-climbing-and-simulated-annealing.html