G5Baim Artificial Intelligence Methods: Graham Kendall
G5Baim Artificial Intelligence Methods: Graham Kendall
G5Baim Artificial Intelligence Methods: Graham Kendall
Simulated Annealing
Motivated by the physical annealing
process
Simulated Annealing
Compared to hill climbing the main
difference is that SA allows downwards
steps
Simulated Annealing
Kirkpatrick (1982) applied SA to
optimisation problems
Possible solutions
Change in Change in
Evaluation Temperature Evaluation Temperature
• Example
Function of System exp(-C/T) Function of System exp(-C/T)
10 100 0.904837418 10 10 0.367879441
20 100 0.818730753 20 10 0.135335283
30 100 0.740818221 30 10 0.049787068
40 100 0.670320046 40 10 0.018315639
50 100 0.60653066 50 10 0.006737947
60 100 0.548811636 60 10 0.002478752
70 100 0.496585304 70 10 0.000911882
80 100 0.449328964 80 10 0.000335463
90 100 0.40656966 90 10 0.00012341
100 100 0.367879441 100 10 4.53999E-05
110 100 0.332871084 110 10 1.67017E-05
120 100 0.301194212 120 10 6.14421E-06
130 100 0.272531793 130 10 2.26033E-06
140 100 0.246596964 140 10 8.31529E-07
150 100 0.22313016 150 10 3.05902E-07
160 100 0.201896518 160 10 1.12535E-07
170 100 0.182683524 170 10 4.13994E-08
180 100 0.165298888 180 10 1.523E-08
190 100 0.149568619 190 10 5.6028E-09
200 100 0.135335283 200 10 2.06115E-09
1
Probability of Acceptance
0.8
0.2
0
11
13
15
19
1
17
Change in Evaluation
G5BAIM Simulated Annealing
SA Algorithm
The most common way of implementing
an SA algorithm is to implement hill
climbing with an accept function and
modify it for SA
SA Algorithm
• Function SIMULATED-ANNEALING(Problem,
Schedule) returns a solution state
• Current = MAKE-NODE(INITIAL-STATE[Problem])
G5BAIM Simulated Annealing
SA Algorithm
For t = 1 to do
T = Schedule[t]
If T = 0 then return Current
Next = a randomly selected successor of Current
E = VALUE[Next] – VALUE[Current]
if E > 0 then Current = Next
else Current = Next only with probability exp(-
E/T)
G5BAIM Simulated Annealing
SA Algorithm - Observations
• The cooling schedule is hidden in this
algorithm - but it is important (more
later)
SA Cooling Schedule
• Starting Temperature
• Final Temperature
• Temperature Decrement
– We need to compromise
– We can either do this by doing a large
number of iterations at a few
temperatures, a small number of
iterations at many temperatures or a
balance between the two
G5BAIM Simulated Annealing
Change in Change in
Evaluation Temperature Evaluation Temperature
Function of System exp(-C/T) Function of System exp(-C/T)
10 100 0.904837418 10 10 0.367879441
20 100 0.818730753 20 10 0.135335283
30 100 0.740818221 30 10 0.049787068
40 100 0.670320046 40 10 0.018315639
50 100 0.60653066 50 10 0.006737947
60 100 0.548811636 60 10 0.002478752
70 100 0.496585304 70 10 0.000911882
80 100 0.449328964 80 10 0.000335463
90 100 0.40656966 90 10 0.00012341
100 100 0.367879441 100 10 4.53999E-05
110 100 0.332871084 110 10 1.67017E-05
120 100 0.301194212 120 10 6.14421E-06
130 100 0.272531793 130 10 2.26033E-06
140 100 0.246596964 140 10 8.31529E-07
150 100 0.22313016 150 10 3.05902E-07
160 100 0.201896518 160 10 1.12535E-07
170 100 0.182683524 170 10 4.13994E-08
180 100 0.165298888 180 10 1.523E-08
190 100 0.149568619 190 10 5.6028E-09
200 100 0.135335283 200 10 2.06115E-09
Probability of Acceptance
0.8
0.2
11
13
15
17
19
Change in Evaluation
G5BAIM Simulated Annealing
– Bin Packing
G5BAIM Simulated Annealing
– or memetic algorithms
P(δ) = 1 – δ/t
SA Modifications - Cooling
• If you plot a typical cooling schedule you
are likely to find that at high temperatures
many solutions are accepted
SA Modifications - Cooling
SA Modifications - Cooling
• Taking this one stage further, we can say
that simulated annealing does most of its
work during the middle stages of the
cooling schedule
SA Modifications - Cooling
• But what temperature?
SA Modifications - Cooling
• One solution to this problem is to spend
some time searching for the optimum
temperature and than stay at that
temperature for the remainder of the
algorithm
• The final temperature is chosen as the
temperature that returns the best cost
function during the search phase
G5BAIM Simulated Annealing
SA Modifications - Neighbourhood
• The neighbourhood of any move is
normally the same throughout the
algorithm but…
• The neighbourhood could be changed as
the algorithm progresses
• For example, a cost function based on
penalty values can be used to restrict
the neighbourhood if the weights
associated with the penalties are
adjusted as the algorithm progresses
G5BAIM Simulated Annealing