CS621: Artificial Intelligence

Preview:

DESCRIPTION

CS621: Artificial Intelligence. Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 7: Traveling Salesman Problem as search; Simulated Annealing; Comparison with GA. 4-city TSP. d ij not necessarily Equal to d ji. 2. 1. d 12. d 23. d 23. d 31. d 14. 4. 3. d 34. - PowerPoint PPT Presentation

Citation preview

CS621: Artificial Intelligence

Pushpak BhattacharyyaCSE Dept., IIT Bombay

Lecture 7: Traveling Salesman Problem as search; Simulated Annealing; Comparison

with GA

4-city TSP

1

34

2

d12

d23

d34

d31

d14

d23

dij not necessarilyEqual to dji

TSP: State Representation

10004

00103

01002

00011

4321Position

(α)City (i) `i’ varies over cities

`α’ varies over positions

Objective Functions

Minimize F = F1 + F2

F1 = k1 ∑i ((∑α xiα) – 1)2 + k2 ∑β ((∑j xjβ) – 1)2

F2 = k3 ∑i ∑j ∑α dij (xiα xi,α+1 + xiα xi,α-1)

1(a) 1(b)

2

Travelling Salesperson problem through Simulated Annealing, State representation

1 2 3 4

1 1 0 0 0

2 0 0 1 0

3 0 0 0 1

4 0 1 0 0

PositionCity

43

1

2

State

1 2 3 4

1 1 0 0 0

2 0 0 1 0

3 0 0 0 1

4 0 1 0 0

1 2 3 4

1 1 0 0 0

2 0 1 0 0

3 0 0 0 1

4 0 0 1 0

1 2 3 4

1 1 0 0 0

2 0 0 0 1

3 0 0 1 0

4 0 1 0 0

State/Node expansion

1

43

2

1

4

3

2

1

23

4

3 2 4 2

Parent State

Children States

State-Energy diagram

Metropolis Algorithm

1) Initialize: Start with a random state matrix S. Compute the objective function value at S. Call this the energy of the state E(S).

2) The states are transformed by the application of an operator (for TSP, inversion of adjacent cities)

3) Compute change the energy ΔE=Enew-Eold

4) if ΔE <=0, accept the new state Snew

5) Else, accept Snew with probability

(‘T’ is the “temperature” and KB, the Boltzmann constant)

TK

stateE

Be)(

Metropolis Algorithm (contd)

6) Continue 2-5 until there is no appreciable change in energy

7) The current state may be one of the local minima

8) Increase the temperature and continue 2-7 until the global minimum is reached

How to probabilistically accept a state? Suppose the probability =p

Generate a random number from a uniform distribution [0,1]

Number generated is in the range [0-p]: Accept the new state, else continue search from the old state itself

TK

stateE

Be)(

Why? The significance of p (= ) is that

if the states are generated infinite number of times then a proportion p of them will be the concerned new state

(0,0) (0,1)

(1,1)(0,0)

Uniform distributionOf [0,1]

(0,p)

TK

stateE

Be)(

Why? (contd) If numbers in the range [0,1] are

generated randomly, p% of them will be in the range [0,p]. Hence this process can simulate the state generation process

(0,0) (0,1)

(1,1)(0,0)

Uniform distributionOf [0,1]

(0,p)

Chromosome Fitness % of total1 6.82 312 1.11 53 8.48 384 2.57 125 3.08 14Total 22.0 100

Acknowledgement: http://www.edc.ncl.ac.uk/highlight/rhjanuary2007g02.php/

Compare with Roulette Wheel Algorithm for Selection

Roulette Wheel SelectionRoulette Wheel SelectionLet i = 1, where i denotes chromosome index;Calculate P(xi) using proportional selection;

sum = P(xi);

choose r ~ U(0,1);

while sum < r doi = i + 1; i.e. next chromosomesum = sum + P(xi);

endreturn xi as one of the selected parent;

repeat until all parents are selected

Significance of “temperature” We have a pseudo temperature T As T increases so does T is a parameter in the algorithm When stuck in the local minima, we

increase the temperature The probability of going to a higher

energy state increases Shaken out of local minima Similar to annealing of metal

TK

stateE

Be)(

Annealing of Metal

The metal should have a stable crystal structure so that it is not brittle

For this it is repeatedly heated and then cooled slowly

Recommended