Simulated Annealing
Simulated annealing searches a rugged landscape by sometimes accepting worse moves. The temperature starts high and cools, trading exploration for exploitation.
The cyan dot is the current state and the rose circle is the best state found. Early on, high temperature accepts many uphill moves; as it cools, the search settles into a valley. The function has several local minima, so pure hill climbing can get trapped.
What you are seeing
Propose a nearby move and compare its objective value with the current state.
Better moves are always accepted; worse moves are accepted with probability exp(−Δ/T).
As temperature T decreases, the algorithm accepts fewer bad moves and settles into a low valley.
Why it matters
Simulated annealing is used for circuit design, scheduling, image reconstruction, and combinatorial optimization where gradients are unavailable.
Complexity & details
Each iteration costs O(1) for a 1D landscape. Total cost is O(iterations).
Frequently asked questions
Why accept worse moves?+
A purely greedy search can get stuck in a local minimum. Accepting some worse moves lets the search cross barriers and reach a better basin.
Why cool slowly?+
Fast cooling freezes the system in a poor state. Slow cooling gives the search more time to explore before it commits.