Optimization · CMNA Laboratory

Sometimes the algorithm should make a bad move on purpose.

Define a two-dimensional objective in R, then watch simulated annealing accept, reject, wander, cool, and remember the best point it has seen.

Escaping local minima costs something.

At high temperature, uphill moves can survive. As the temperature falls, the algorithm becomes increasingly conservative. The randomness is not noise added after the fact; it is part of the search strategy.

Bring your own landscape

Let R wander before it settles.

Write f(x) and x0 in R, choose temperature, cooling rate, and seed, then play the accepted and rejected moves.

RuntimePreparing R…
RDefine f and two-dimensional x0

ntemperatureproposal faccepted?best f
Book§6.3.3 · Simulated Annealing · p. 187Book details
CMNA packagesa
TeachingInstructor notes and chapter contextOpen teaching material
Numerical ZooWorked problems