Вы находитесь на странице: 1из 44

Simulated Annealing

a metaheuristic approach

Presented by;
Nitesh Bansal (2k15/the/09)
Nirmal Pratap Singh
(2k15/the/08)
1

Outline
Introduction
Basic

philosophy
Procedure : Simulated Annealing
Example : Travelling Salesman Problem
Hill Climbing
Stimulated Annealing vs. Hill Climbing
Features
Drawback
Applications
References

Introduction

Studied to obtain an optimal solution for OR models


including
Linear Programming
Non-Linear Programming

These algorithm are invaluable, but doesnt


always work.

Still it is important to find a good feasible solution


3

Basic Philosophy

Motivated by physical annealing process

Annealing

Process

Raising the temperature up to a very high level


(melting temperature, for example), the atoms have a
higher energy state and a high possibility to rearrange the crystalline structure.
Cooling down slowly, the atoms have a lower and
lower energy state and a smaller and smaller
possibility to re-arrange the crystalline structure.
cool it down according to a specific Temperature
schedule.
Ground state is a minimum energy state of the solid
4

Analogy : Simulated Annealing

Metal Problem
Energy State Cost Function
Temperature Control Parameter
A completely ordered crystalline structure
the optimal solution for the problem
System state feasible solution
Global optimal solution can be achieved as long
as the cooling process is slow enough
6

Other Names : Simulated Annealing


Monte

Carlo Annealing
Statistical Cooling
Probabilistic Hill Climbing
Stochastic Relaxation
Probabilistic Exchange Algorithm

Iterative Improvement in SA
Procedure
Step1. Start with initial configuration
Step2. Repeatedly search neighborhood and select a
neighbor as candidate (by Sub-Tour Reversal)
Step3. Evaluate some cost function (or fitness function)
and accept candidate if "better"; if not, select
another neighbor (by Move Selection Rule)
Step4. Stop if quality is sufficiently high, if no improvement
can be found or after some fixed time.
8

Sub-Tour Reversal
Adjusts

the sequence of cities visited in the


current trial solution by selecting a
subsequence of the cities and simply
reversing the order in which that
subsequence of cities is visited.
example: 1-2-3-4-5-6-7-1
distance=69
If we select the subsequence 3-4 and reverse
1-2-4-3-5-6-7-1
distance=65
9

Temperature Schedule
Suppose five iterations are performed at
each of five values of T {T1,T2,T3,T4,T5}
Where,
T1=0.2ZC T2=0.5T1 T3=0.5T2
T4=0.5T3 T5=0.5T4
This

particular temperature schedule is


only illustrative.

10

Example of Simulated Annealing

Traveling Salesman Problem (TSP)

Given 7 cities and the traveling cost/distance


between any two cities
A salesman need to start from city 1 and travel
all other cities then back to city 1
Minimize the total traveling cost/distance

Travelling salesman problem


with seven cities

12

Step 1. Initial trial solution


may enter any feasible solution
(sequence of the cities on the tour)
lets take 1-2-3-4-5-6-7-1
Zc = 12+8+11+11+6+9+12 = 69
Step 2. Neighborhood Structure
immediate neighbour of the current trial
solution is one that is reached by making a
sub-tour reversal
13ini

Step 2.
Selecting

a sub-tour to be reversed requires


selecting the slot in the current sequence of cities
where the sub-tour currently begins and ends. (1-23-4-5-6-7-1)
The beginning slot can be anywhere except the first
and the last slot(reserved for the home city) and next
to last slot
The ending slot must be somewhere after beginning
slot, excluding the last slot
Random no. are used to give equal probabilities to
select any of the eligible beginning slots and ending
slots
14

How the random selection of an immediate


neighbour is made

15

Step 3. Evaluation of cost function and


Acceptance of a candidate
Move selection rule : To Accept or not to Accept

Objective is Minimization
ZN = obj. function value for the current trial solution
ZC = obj. function value for the current candidate to be

the next trial solution


If ZN ZC always accept this candidate

If ZN ZC accept the candidate with the following probability


P(acceptance) = ex where x= (ZC ZN) / T
(If objective is maximization instead, reverse Z N and ZC
in the above formula)

16

To Accept
The new candidate for feasible solution is
1-2-4-3-5-6-7-1 and ZN = 65
Since ZN = 65 < ZC
This candidate is better than the current trial solution, so
the candidate is automatically accepted to be the next trial
solution.

17

Not to Accept

Now considering a case where the current solution is


worse than the current trial solution.
Suppose second iteration results in reversing 3-5-6 i.e 12-4-6-5-3-7-1 ; Zc = 64

Then suppose the third iteration result in reversing 3-7 i.e


1-2-4-6-5-7-3-1 ; Zn = 66

Since objective here is minimization, the probability of


accepting 1-2-4-6-5-7-3-1 as the next trial solution isP(acceptance) = ex ,
where x= (ZC ZN) / T1 and T1 = 13.8
P = 0.865
If the next random number generated is more than 0.865
this candidate solution will be rejected.
18

To accept or not to accept :


some facts

The probability of accepting a worse state is a


function of both the temperature of the system and
the change in the cost function

As the temperature decreases, the probability of


accepting worse moves decreases

If t=0, no worse moves are accepted (i.e. hill


climbing)

19

Iterations

20

Travelling Salesman : Literally?


There

are number of applications of travelling


salesman problems that have nothing to do
with the salesman.

Example:

When a truck leaves a distribution


center to deliver goods to a number of
locations the problem of determining the
shortest route for doing this is a travelling
salesman problem.
21

Hill climbing :
A local improvement procedure

Candidate is always and


only accepted if cost is
lower (or fitness is
higher) than current
configuration
Stop when no neighbour
with lower cost (higher
fitness) can be found
Disadvantages:
Procedure converges to
one Local optimum and
then stop

22

How SA has ability to escape from


local optimum? (Minimization)
AT INIT_TEMP

Unconditional Acceptance

COST FUNCTION, C

HILL CLIMBING

Move accepted with


probability
= e-(^C/temp)
HILL CLIMBING

HILL CLIMBING

AT FINAL_TEMP

NUMBER OF ITERATIONS

23

Simulated Annealing
(Minimization)

Move from A to A accepted


if cost(A) cost(A)
or with probability
P(A,A) = e (cost(A) cost(A))/T

Flow Chart

25

Simulated Annealing
Random

function
value

Starting Point

T = Very
High

Simulated Annealing
Random

function
value

Step

T = Very
High

Simulated Annealing
Even

though E is lower, accept

function
value

T = Very
High

Simulated Annealing
Next

Step; accept since higher E

function
value

T = Very
High

Simulated Annealing
Next

Step; accept since higher E

function
value

T = Very
High

Simulated Annealing
Next

T = High

Step; accept even though lower

function
value

Simulated Annealing
Next

T = High

Step; accept even though lower

function
value

Simulated Annealing
Next

Step; accept since higher

function
value

T = Medium

Simulated Annealing
Next

T = Medium

Step; lower, but reject (T is falling)

function
value

Simulated Annealing
Next

T = Medium

Step; Accept since E is higher

function
value

Simulated Annealing
Next

T = Low

Step; Accept since E change small

function
value

Simulated Annealing
Next

Step; Accept since E larget

function
value

T = Low

Simulated Annealing
Next

T = Low

Step; Reject since E lower and T low

function
value

Simulated Annealing
Eventually

function
value

T = Low

converge to Maximum

Applications
Travelling

salesman problem
Locomotive scheduling
Optimal placement of > 106 transistors on a
chip
DNA Mapping
Financial Analysis
Banking Industry
40

Features
Ability

to escape from a local optima.

Deals

with problems that are too large and


complicated to be solved by exact algorithms.

41

Drawback
No

guarantee that the best solution found will


be an optimal solution or even a nearly
optimal solution.

Another

drawback is time consumption.

42

References

Introductions to Operation Research : concepts


and cases(TMH Publications)
- Frederick S.Hiller, Gerald J.Lieberman

Progress in Operations Research


edited by-Russell L.Ackoff

43

Thank You!

44

Вам также может понравиться