Title: Simulated Annealing
1Simulated Annealing
http//www.math.iastate.edu/wu/math597.html
http//www.math.iastate.edu/wu/Math597HW0000/index
.htm
- Math/BCB/ComS597
- Zhijun Wu
- Department of Mathematics
2Simulated Annealing
Algorithm input initial x0 y0 f (x0) set x
x0 y y0 for T T0, T1, , Tm
(decreasing) for k 1, , n x1
perturb (x0) y1 f (x1)
dy y1 y0 e exp (- dy / T)
if (rand y1 end update x, y
end end
3Annealing Strategies
- Cooling Schedule
- Cooling Steps at Each Temperature
- Step Sizes
- Starting State at Each Temperature
- Local Minimization
4Simple Version
annealing2simple.m function x, y
annealing2simple (f, x0) y0 feval (f, x0) x
x0 y y0 alpha 0.9 T 2 s 2 for k 1
20 T alpha T accept 0 for l
1 100 x1 x0 (0.5 rand (size (x0)))
s y1 feval (f, x1) dy y1
y0 if rand x1 y0 y1 accept accept 1 if y0
accept 75, s
2 s end disp ( accept steps ,
num2str(accept)) disp (current energy ,
num2str(y)) end
5function f, g ljfun (x) n max (size (x)) /
3 f 0 g zeros(3n, 1) for i 1 n for
j i1 n i1 3(i-1) 1 i2 i1 1
i3 i2 1 j1 3(j-1) 1 j2 j1 1
j3 j2 1 r1 x(i1)-x(j1) r2
x(i2)-x(j2) r3 x(i3)-x(j3) rr r1 r1
r2 r2 r3 r3 r sqrt (rr)
r6 1 / rr / rr / rr f f (r6 - 2)
r6 dr - 12 (r6 - 1) r6 / r
g(i1) g(i1) dr r1 / r g(i2) g(i2)
dr r2 / r g(i3) g(i3) dr r3 /
r g(j1) g(j1) - dr r1 / r g(j2)
g(j2) - dr r2 / r g(j3) g(j3) - dr
r3 / r end end
Lennard-Jones Function
6Minimizing LJ Potential
singlerun.m rand (state, 0) x0 rand
(36, 1) x1, y1 annealing2simple (ljfun,
x0) x1 y1
7Decreasing the Step Size
annealing2simple.m function x, y
annealing2simple (f, x0) y0 feval (f, x0) x
x0 y y0 alpha 0.9 T 2 s 0.2 for k
1 20 T alpha T accept 0 for l
1 100 x1 x0 (0.5 rand (size
(x0))) s y1 feval (f, x1) dy
y1 y0 if rand x0 x1 y0 y1 accept accept 1
if y0 if accept
75, s 2 s end disp ( accept steps ,
num2str(accept)) disp (current energy ,
num2str(y)) end
8Reset Starting States
annealing2simple.m function x, y
annealing2simple (f, x0) y0 feval (f, x0) x
x0 y y0 alpha 0.9 T 2 s 0.2 for k
1 20 T alpha T accept 0 for l
1 100 x1 x0 (0.5 rand (size
(x0))) s y1 feval (f, x1) dy
y1 y0 if rand x0 x1 y0 y1 accept accept 1
if y0 if accept
75, s 2 s end disp ( accept steps ,
num2str(accept)) disp (current energy ,
num2str(y)) x0 x y0 y end
9Increasing Cooling Steps
annealing2simple.m function x, y
annealing2simple (f, x0) y0 feval (f, x0) x
x0 y y0 alpha 0.9 T 2 s 0.2 for k
1 20 T alpha T for j 1 10
accept 0 for l 1 100 x1 x0
(0.5 rand (size (x0))) s y1 feval
(f, x1) dy y1 y0 if rand (- dy / T) x0 x1 y0 y1 accept
accept 1 if y0 end end end if accept 2 end if accept 75, s 2 s end disp
( of accepted steps , num2str(accept))
disp (current energy level , num2str(y))
x0 x y0 y end end
10Multiple Runs
multiruns.m rand (state, 0) for i 1
5 x0 rand (36, 1) x1, y1
annealing2simple (ljfun, x0) options
optimset (GradObj, on) x2, y2 fminunc
(ljfun, x1, options) x2 y2 end
11 Computer Project 3 General Policy
- Make your programs and related running results
accessible from your homework page. The programs
should be written in a relatively formal fashion,
be easy to read, and contain minimal comments for
major computing steps. - The programs should run correctly on test data.
If not before turned in, please explain a little
bit what you have done and the problem you have
not resolved. - Discussion with classmates is encouraged but you
are required to finish and turn in your own
project separately.
12 Computer Project 3 Due 6pm, Monday, December 12th
- Develop a global optimization code for the
minimization of the Lennard-Jones potential using
multistart, simulated annealing, or a method of
your choice. - Use your code to find the minimum energy
configurations of the Lennard-Jones clusters with
five to twenty-four atoms. Record your solutions
and display them with RasMol. - If you cannot find the minimum configuration of a
specific cluster, you may change your code
specifically to obtain the solution for the
cluster. However, you need to describe the
specific procedure. - There are twenty clusters. You need to find the
minimum energy configurations of all the clusters
to earn the total twenty points for the project.
Only global energy minima are counted.
13RasMol Input Format
COMPNDARG12 REMARK ATOM 1 O 1
0.186 -0.322 0.674 TER ATOM 2 O
1 -0.136 0.150 1.505 TER ATOM
3 O 1 0.896 0.251
0.244 TER ATOM 4 O 1 0.375
1.016 1.589 TER ATOM 5 O 1
1.160 -0.559 0.782 TER ATOM 6 O
1 0.570 -0.623 1.581 TER ATOM 7
O 1 1.012 1.079
0.810 TER ATOM 8 O 1 0.790
0.220 1.211 TER ATOM 9 O 1
0.627 0.225 2.161 TER ATOM 10 O
1 0.102 0.676 0.686 TER ATOM 11
O 1 1.683 0.329
0.869 TER ATOM 12 O 1 1.354
0.813 1.720 TER
14Global Energy Minima of LJ-Cluster 4 to 24
Cluster Size Global Energy
Minimum 3
-3.0000e00 4
-6.0000e00 5
-9.1040e00 6
-1.2712e01 7
-1.6505e01 8
-1.9822e01 9
-2.4113e01 10
-2.8420e01 11
-3.2765e01 12
-3.7967e01 13
-4.4327e01 14
-4.7845e01 15
-5.2323e01 16
-5.6816e01 17
-6.1318e01 18
-6.6531e01 19
-7.2660e01 20
-7.7117e01 21
-8.1685e01 22
-8.6810e01 23
-9.2844e01 24
-9.7349e01