View
3
Download
1
Category
Preview:
Citation preview
1
Simulated Annealing
A Basic Introduction
Olivier de Weck, Ph.D.
Massachusetts Institute of Technology
Lecture 10
2
Outline
• Heuristics
• Background in Statistical Mechanics
– Atom Configuration Problem
– Metropolis Algorithm
• Simulated Annealing Algorithm
• Sample Problems and Applications
• Summary
3
Learning Objectives
• Review background in Statistical Mechanics:
configuration, ensemble, entropy, heat capacity
• Understand the basic assumptions and steps in
Simulated Annealing (SA)
• Be able to transform design problems into a
combinatorial optimization problem suitable to
SA
• Understand strengths and weaknesses of SA
4
Heuristics
5
What is a Heuristic?
• A Heuristic is simply a rule of thumb that hopefully will find a good
answer.
• Why use a Heuristic?
– Heuristics are typically used to solve complex (large, nonlinear, non-
convex (i.e. contain local minima)) multivariate combinatorial optimization
problems that are difficult to solve to optimality.
• Unlike gradient-based methods in a convex design space, heuristics
are NOT guaranteed to find the true global optimal solution in a single
objective problem, but should find many good solutions (the
mathematician's answer vs. the engineer’s answer)
• Heuristics are good at dealing with local optima without getting stuck
in them while searching for the global optimum.
6
Types of Heuristics
• Heuristics Often Incorporate Randomization
• Two Special Cases of Heuristics
– Construction Methods
• Must first find a feasible solution and then improve it.
– Improvement Methods
• Start with a feasible solution and just try to improve it.
• 3 Most Common Heuristic Techniques
– Simulated Annealing
– Genetic Algorithms
– Tabu Search
– New Methods: Particle Swarm Optimization, etc…
7
Origin of Simulated Annealing (SA)
• Definition: A heuristic technique that mathematically mirrors the
cooling of a set of atoms to a state of minimum energy.
• Origin: Applying the field of Statistical Mechanics to the field of
Combinatorial Optimization (1983)
• Draws an analogy between the cooling of a material (search for
minimum energy state) and the solving of an optimization problem.
• Original Paper Introducing the Concept
– Kirkpatrick, S., Gelatt, C.D., and Vecchi, M.P., “Optimization by Simulated
Annealing,” Science, Volume 220, Number 4598, 13 May 1983, pp. 671-
680.
8
MATLAB® “peaks” function
• Difficult due to plateau at z=0, local maxima
• SAdemo1
• xo=[-2,-2]
• Optimum at
• x*=[ 0.012, 1.524]
• z*=8.0484
-3 -2 -1 0 1 2 3-3
-2
-1
0
1
2
3
x
Peaks
y
Start Point
Maximum
9
“peaks” convergence• Initially ~ nearly random search
• Later ~ gradient search
0 50 100 150 200 250 300-10
-8
-6
-4
-2
0
2
Iteration Number
Syste
m E
nerg
y
SA convergence history
current configuration
new best configuration
10
Statistical Mechanics
11
The Analogy
• Statistical Mechanics: The behavior of systems with many
degrees of freedom in thermal equilibrium at a finite temperature.
• Combinatorial Optimization: Finding the minimum of a given
function depending on many variables.
• Analogy: If a liquid material cools and anneals too quickly, then the
material will solidify into a sub-optimal configuration. If the liquid
material cools slowly, the crystals within the material will solidify
optimally into a state of minimum energy (i.e. ground state).
– This ground state corresponds to the minimum of the cost function in an
optimization problem.
12
Sample Atom Configuration
-1 0 1 2 3 4 5 6 7-1
0
1
2
3
4
5
6
7
1
2
3
4
Atom Configuration - Sample Problem
E=133.67
-1 0 1 2 3 4 5 6 7-1
0
1
2
3
4
5
6
7
1
23
4
Atom Configuration - Sample Problem
Original Configuration Perturbed Configuration
E=109.04
Perturbing = move a random atom
to a new random (unoccupied) slotEnergy of original (configuration)
13
Configurations
• Mathematically describe a configuration
– Specify coordinates of each “atom”
– Specify a slot for each atom
1 2 3 4
1 3 4 5 with i=1,..,4 , , ,
1 2 4 3ir r r r r
with i=1,..,4 1 12 19 23ir R
14
Energy of a state
• Each state (configuration) has an energy
level associated with it
totH T V E
, , , ,i i
i
H q q t q p L q q t Hamiltonian
Energy of configuration
=
Objective function value of designkinetic potential
Energy
15
Energy sample problem
• Define energy function for “atom” sample
problem1
2 2 2
potentialenergy
kineticenergy
N
i i i j i j
j i
E mgy x x y y
1
N
i i
i
E R E r Absolute and relative position of
each atom contributes to Energy
16
Compute Energy of Config. A
• Energy of initial configuration
1
2
3
4
1 10 1 5 18 20 20.95
1 10 2 5 5 5 26.71
1 10 4 18 5 2 47.89
1 10 3 20 5 2 38.12
E
E
E
E
Total Energy Configuration A: E({rA})= 133.67
-1 0 1 2 3 4 5 6 7-1
0
1
2
3
4
5
6
7
1
2
3
4
Atom Configuration - Sample Problem
17
Boltzmann Probability
!
!R
PN
P N
Number of configurations
What is the likelihood that a particular configuration will
exist in a large ensemble of configurations?
P=# of slots=25
N=# of atoms =4NR=6,375,600
({ }){ } exp
B
E rP r
k T
Boltzmann probability
depends on energy
and temperature
18
Boltzmann Collapse at low T
0 20 40 60 80 100 120 140 160 180 2000
2000
4000
6000
8000
10000
12000
14000
Energy
Occure
nces
T=10 - Eavg
=58.9245
T=10
0 20 40 60 80 100 120 140 160 180 2000
2000
4000
6000
8000
10000
12000
14000
Energy
Occure
nces
T=1 - Eavg
=38.1017
T=1
0 20 40 60 80 100 120 140 160 180 2000
2000
4000
6000
8000
10000
12000
Energy
Occure
nces
T=100 - Eavg
=100.1184
Boltzmann Distribution collapses to the lowest energy
state(s) in the limit of low temperature
Basis of search by Simulated Annealing
T=100
T high T low
19
Partition Function Z
• Ensemble of configurations can be
described statistically
• Partition function, Z, generates the
ensemble average
1
Tr exp expRN
i i
iB B
E EZ
k T k T
Initially (at T>>0) equal to the number of possible configurations
20
Free Energy
ln ( )BF T k T Z E T TS
1
( )RN
avg i
i
E E T E T
1
expln
( )1
RNi
i
i B
avg
B
E TE T
k T d ZE E T
Z d k T
Relates average Energy at T with Entropy S
Average Energy of all
Configurations in an
ensemble
21
Specific Heat and Entropy
• Specific Heat
• Entropy
2222
1
2 2
1( )
( )( )
RN
i
iR
B B
E T E TE T E TNdE T
C TdT k T k T
( ) ( )dS T C T
dT T
1
1
( )( ) ( )
T
T
C TS T S T dT
T
Entropy is ~ equal to ln(# of unique configurations)
22
Low Temperature Statistics
100
102
104
100
105
Temperature
# o
f configura
tions,
NT
100
102
104
0
2
4
6
8
10
Temperature
Specific Heat C and Entropy S
100
102
104
-150
-100
-50
0
50
100
150
Temperature
Fre
e E
nerg
y,
F
100
102
104
-150
-100
-50
0
50
100
150
Temperature
Avera
ge E
nerg
y,
Eavg
Approaches
E* from
below
Approaches
E* from
above
Entropy S
decreases
with lower T
Ht. Capacity# configs
decreases
23
Minimum Energy Configurations
• Sample Atom Placement Problem
-1 0 1 2 3 4 5 6 7-1
0
1
2
3
4
5
6
7
1
23
4
Atom Configuration - Sample Problem
Low gravity g=0.1
E*=14.26
-1 0 1 2 3 4 5 6 7-1
0
1
2
3
4
5
6
7
12 34
Atom Configuration - Sample Problem
E*=60
Strong gravity g=10
Uniqueness?
24
Simulated Annealing
25
Dilemma
• Cannot compute energy of all configurations !
– Design space often too large
– Computation time for a single function evaluation can
be large
• Use Metropolis Algorithm, at successively lower
temperatures to find low energy states
– Metropolis: Simulate behavior of a set of atoms in
thermal equilibrium (1953)
– Probability of a configuration existing at T
Boltzmann Probability P(r,T)=exp(-E(r)/T)
26
The SA Algorithm• Terminology:
– X (or R or ) = Design Vector (i.e. Design, Architecture, Configuration)
– E = System Energy (i.e. Objective Function Value)
– T = System Temperature
– = Difference in System Energy Between Two Design Vectors
• The Simulated Annealing Algorithm
1) Choose a random Xi, select the initial system temperature, and specify the
cooling (i.e. annealing) schedule
2) Evaluate E(Xi) using a simulation model
3) Perturb Xi to obtain a neighboring Design Vector (Xi+1)
4) Evaluate E(Xi+1) using a simulation model
5) If E(Xi+1)< E(Xi), Xi+1 is the new current solution
6) If E(Xi+1)> E(Xi), then accept Xi+1 as the new current solution with a
probability e(- /T) where = E(Xi+1) - E(Xi).
7) Reduce the system temperature according to the cooling schedule.
8) Terminate the algorithm.
27
SA Block Diagram
n
Reached equilbrium at Tj ?
End Tmin
Start To
T<Tmin?
Define initialconfiguration Ro
Evaluate energy E(Ro)
Evaluate energy E(Ri+1)
Accept Ri+1 asnew configuration
Keep Ri as current configuration
Perturb configuration Ri
_> Ri+1
Compute energy difference E = E(Ri+1)-E(Ri)
Reduce temperature Ti+1 =Tj - T E < 0?
Create randomnumber v in [0,1]
exp - E > v?T
Metropolis step
SA Block Diagram
y
y
y
n
n
n
y
Image by MIT OpenCourseWare.
28
MATLAB Function: SA.m
xo
Initial Configuration
Simulated Annealing
Algorithm
evaluation
functionperturbation
function
file_eval.m file_perturb.m
Option Flags
Best Configuration
options
SA.m xbest Ebest
Historyxhist
29
Exponential Cooling
• Typically (T1/To)~0.7-0.91
1
k
k k
o
TT T
T
0 5 10 15 20 25 30 35 40 450
1
2
3
4
5
6
7
8
9
10
Temperature Step
Simulated Annealing Evolution
C-specific heat
S-entropy
T/10-temperature
Can also do linear
or step-wise cooling
…
But exponential cooling
often works best.
30
Key Ingredients for SA
1. A concise description of a configuration (architecture, design,
topology) of the system (Design Vector).
2. A random generator of rearrangements of the elements in a
configuration (Neighborhoods). This generator encapsulates rules
so as to generate only valid configurations. Perturbation function.
3. A quantitative objective function containing the trade-offs that
have to be made (Simulation Model and Output Metric(s)).
Surrogate for system energy.
4. An annealing schedule of the temperatures and/or the length of
times for which the system is to be evolved.
31
Sample Problems
32
Traveling Salesman Problem
• N cities arranged randomly on [-1,1]
• Choose N=15
• SAdemo2.m
• Minimize “cost” of route (length, time,…)
• Visit each city once, return to start city
2 22 2
1 1
1 1 1
visit N cities return home to first city
N
j i j i j j N
i j j
l R x R x R x R x R
33
TSP Problem (cont.)
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Start1
2
3
45 6
7
8
9
10
11
12
13
14
15
Length of TSP Route: 17.4309
Initial (Random) Route
Length: 17.43
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Start
1
2
3
45 6
7
8
9
10
11
12
13
14
15
Length of TSP Route: 8.2384
Shortest Route
Final (Optimized) Route
Length: 8.24
Result with SA
34
Structural Optimization
• Define:
– Design Domain
– Boundary Conditions
– Loads
– Mass constraint
• Subdivide domain
– N x M design “cells”
– Cell density =1 or =0
• Where to put material to minimize compliance?
1
max
1
find 1,...,
min ( )
s.t.
s.t.
i
T
i
N
i i
i
i N
C f u
u K f
V m
35
Structural Topology Optimization (II)
1 2
1211
2 3
1312
3 4
1413
4 5
1514
5 6
1615
6 7
1716
7 8
1817
8 9
1918
9 10
201911 12
2221
12 13
2322
13 14
2423
14 15
2524
15 16
2625
16 17
2726
17 18
2827
18 19
2928
19 20
302921 22
3231
22 23
3332
23 24
3433
24 25
3534
25 26
3635
26 27
3736
27 28
3837
28 29
3938
29 30
403931 32
4241
32 33
4342
33 34
4443
34 35
4544
35 36
4645
36 37
4746
37 38
4847
38 39
4948
39 40
5049
1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18
19 20 21 22 23 24 25 26 27
28 29 30 31 32 33 34 35 36
1 2
1211
2 3
1312
3 4
1413
45
1514
56
1615
67
1716
78
1817
89
1918
910
2019
11 12
2221
12 13
2322
13 14
2423
1415
2524
1516
2625
1617
2726
1718
2827
1819
2928
1920
3029
21 22
3231
22 23
3332
23 24
3433
24 25
3534
2526
3635
2627
3736
2728
3837
2829
3938
2930
4039
31 32
4241
32 33
4342
33 34
4443
3435
4544
3536
4645
3637
4746
3738
4847
3839
4948
3940
5049
Deformation not drawn to scale
“Energy” = strain energy = compliance
Computed via Finite Element Analysis
Cantilever
Boundary
condition
Applied Load
F=-2000
36
Structural Toplogy Optimization
0 2 4 6 8 10-1
0
1
2
3
4
5
6
7
8
9
Initial Structural Configuration: xo
Initial Structural Toplogy “Final” Toplogy
Compliance C=593.0
Compliance C=236.68
“island”Structural Configuration
Not “optimal” – often
need post-processing
37
Structural Optimization –
Convergence Analysis
0 5 10 15 20 25 30 35 400
2
4
6
8
10
12
14
Temperature Step
Simulated Annealing Evolution
C-specific heat
S-entropy
ln(T)-temperature
200 400 600 800 1000 1200 1400 1600 1800 2000 22000
5
10
15
20
25
30
35
40
45
T=3e+002
Energy
Occure
nces
T=2.7e+002T=2.4e+002
T=2.2e+002T=1.9e+002
T=1.8e+002
T=1.6e+002
T=1.4e+002
T=1.3e+002
T=1.1e+002T=1e+002
T=93
T=84
T=75
T=68
T=61
T=55
T=49T=45
T=40
T=36
T=32
T=29
T=26
T=24
T=21
T=19
T=17
T=16
T=14
T=13T=11T=10
T=9.2T=8.2
T=7.4
T=6.7
T=6
Evolution of
- Entropy, Temperature, Specific Heat
Don’t terminate
when C is still
large !
Boltzmann Distributions
38
Premature termination
0 500 1000 1500 2000 2500 3000200
400
600
800
1000
1200
1400
1600
1800
2000
2200
Iteration Number
Syste
m E
nerg
y
SA convergence history
current configuration
new best configuration
Indicator: Best Configuration found only shortly
before Simulated Annealing terminated.
39
Final Example: Telescope Array
Optimization
-200 -100 0 100 200-200
-100
0
100
200Cable Length = 1064.924
-100 -50 0 50 100-100
-50
0
50
100UV Density = 0.67236
• Place N=27 stations in xy within a 200 km radius
• Minimize UV density metric
• Ideally also minimize cable length
Initial
Configuration
40
Optimized Solution
-200 -100 0 100 200-200
-100
0
100
200Cable Length = 1349.609
-100 -50 0 50 100-100
-50
0
50
100UV Density = 0.33333
Simulated AnnealingImproved UV density from 0.67 to 0.33
• Simulated Annealing transforms the array:
– Hub-and-Spoke Circle-with-arms
Cohanim B. E., Hewitt J. N., and de Weck O.L., “The Design of Radio Telescope Array
Configurations using Multiobjective Optimization: Imaging Performance versus Cable
Length”, The Astrophysical Journal, Supplement Series, 154, 705-719, October 2004
41
Summary
42
Summary: Steps of SA
• The Simulated Annealing Algorithm
1) Choose a random Xi, select the initial system temperature, and outline the
cooling (ie. annealing) schedule
2) Evaluate E(Xi) using a simulation model
3) Perturb Xi to obtain a neighboring Design Vector (Xi+1)
4) Evaluate E(Xi+1) using a simulation model
5) If E(Xi+1)< E(Xi), Xi+1 is the new current solution
6) If E(Xi+1)> E(Xi), then accept Xi+1 as the new current solution with a
probability e(- /T) where = E(Xi+1) - E(Xi).
7) Reduce the system temperature according to the cooling schedule.
8) Terminate the algorithm.
43
Recent Research in SA
• Alternative Cooling Schedules and Termination
criteria
• Adaptive Simulated Annealing (ASA) –
determines its own cooling schedule
• Hybridization with other Heuristic Search
Methods (GA, Tabu Search …)
• Multiobjective Optimization with SA
44
References• Cerny, V., "Thermodynamical Approach to the Traveling Salesman Problem: An Efficient
Simulation Algorithm", J. Opt. Theory Appl., 45, 1, 41-51, 1985 .
• de Weck O. “System Optimization with Simulated Annealing (SA), Memorandum SA.pdf
• Cohanim B. E., Hewitt J. N., and de Weck O.L., “The Design of Radio Telescope Array
Configurations using Multiobjective Optimization: Imaging Performance versus Cable
Length”, The Astrophysical Journal, Supplement Series, 154, 705-719, October 2004
• Jilla, C.D., and Miller, D.W., “Assessing the Performance of a Heuristic Simulated
Annealing Algorithm for the Design of Distributed Satellite Systems,” Acta Astronautica,
Vol. 48, No. 5-12, 2001, pp. 529-543.
• Kirkpatrick, S., Gelatt, C.D., and Vecchi, M.P., “Optimization by Simulated
Annealing,” Science, Volume 220, Number 4598, 13 May 1983, pp. 671-680.
• Metropolis,N., A. Rosenbluth, M. Rosenbluth, A. Teller, E. Teller, "Equation of State
Calculations by Fast Computing Machines", J. Chem. Phys.,21, 6, 1087-1092, 1953.
MIT OpenCourseWarehttp://ocw.mit.edu
ESD.77 / 16.888 Multidisciplinary System Design Optimization
Spring 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Recommended