Skip to content
StackDecode
AI & ML Atlas
Artificial IntelligencealgorithmInteractive simulation

Hill Climbing

Repeatedly moves to a better neighbouring solution until none is better.

The idea

Start somewhere, look at nearby solutions and step to the best one that improves the score. It stops at the top of the nearest hill. That is fast and simple, but the hill may be a small local peak rather than the global best.

x ← argmax f(neighbour) if it beats f(x)

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

  • brighter = better

Restart 1: start at a random spot (score 0.13).

best:
0.13
restart:
1
1/22

Dark spots on the map are poor settings; bright spots are good. One of the peaks is the tallest.

Step by step

  1. 1Pick a random starting solution.
  2. 2Evaluate all neighbouring solutions.
  3. 3Move to the best neighbour if it is better than the current one.
  4. 4Stop when no neighbour improves the score.

Where it is used

Quick tuning, scheduling and layout problems.

Watch out for

Gets stuck on local maxima, ridges and plateaus. Random restarts are the usual fix.

Related