Functional Minimization using Simulated Annealing
Just Looking: An example code
- Notes about Simulated Annealing Techniques are accessible through
our Calendar.
- View or download a straightforward simulated annealing code
(i.e. anneal.f) written in FORTRAN 90.
- Function may be altered, but no guarentees from us.
Currently, it is a periodic function (i.e. cos(x)) multiplied by a parabolic
function giving rise to multiple minima but only one global minima.
To Get Started and Explore
- Download the simulated annealing code
anneal.tar.gz
,
-
gunzip anneal.tar.gz
, and
- un-tar with
tar xvf anneal.tar
.
The following files are in the distribution:
anneal.f
- The source code.
Top lines of code give compiler options for most workstations.
x_1d.gnu
- Gnuplot script for ploting
the trajectory of during the annealing process, for 1-d
annealing, using the data in the en.out
file.
Also shown are the energy function f(x) and the location of the
best energy encountered, x_min.
Run using gnuplot x_1d.gnu
.
cv.gnu
- Gnuplot script for ploting the specfic
heat using data from the en.out
file.
Run using gnuplot cv.gnu
.
Some Questions to Help You Understand the Technique
- Flowchart
Look at the source anneal.f
and write a flowchart
describing the code. You don't need a lot of detail, just indicate
the main loops and decision processes (the flowchart should fit on one page).
- Annealing rate
Try different annealing factors (0.8, 0.9, 0.95) with different random
seeds. How slowly do you have to anneal to settle down in the global
minimum over 90% of the time? Just estimate the quantity, but provide
some explanation and data to support your answer.
- Sqrt(T) scaling
Notice that the step size used in the code for the metropolis
algorithm (in SUBROUTINE step) is scaled by SQRT(temperature).
What is the reason for this choice? Hint, look at the acceptance
ratios, and think about diffusion and thermal distributions in
parabolic wells (i.e. related to the type of FUNCTION).
- "Specific Heat" Type Quantity
Do a long run with slow annealing, and look at the specific
heat Cv (you can use gnuplot cv.gnu
).
Since Cv has a large variance, you will need
to set the number of steps per block fairly high (at least 10000).
Identify the main feature in this curve, and relate the energy to
an energy scale in the energy curve. By comparing to some of the
graphs produced by gnuplot x_1d.gnu
, explain how Cv
can indicate where simulated annealing may fail.