160 likes | 250 Views
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.
E N D
CS621: Artificial Intelligence Pushpak BhattacharyyaCSE Dept., IIT Bombay Lecture 7: Traveling Salesman Problem as search; Simulated Annealing; Comparison with GA
4-city TSP dij not necessarily Equal to dji 2 1 d12 d23 d23 d31 d14 4 3 d34
TSP: State Representation 1 2 3 4 1 1 0 0 0 2 0 0 1 0 3 0 1 0 0 4 0 0 0 1 Position (α) 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 1(a) 1(b) F2 = k3 ∑i ∑j ∑α dij (xiα xi,α+1 + xiα xi,α-1) 2
Travelling Salesperson problem through Simulated Annealing, State representation Position City 1 3 4 2 State
State/Node expansion 1 Parent State 3 4 2 3 2 4 2 1 1 Children States 4 3 2 2 4 3
Metropolis Algorithm • Initialize: Start with a random state matrix S. Compute the objective function value at S. Call this the energy of the state E(S). • The states are transformed by the application of an operator (for TSP, inversion of adjacent cities) • Compute change the energy ΔE=Enew-Eold • if ΔE <=0, accept the new state Snew • Else, accept Snew with probability (‘T’ is the “temperature” and KB,the Boltzmann constant)
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
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) (1,1) Uniform distribution Of [0,1] (0,0) (0,1) (0,p)
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) (1,1) Uniform distribution Of [0,1] (0,0) (0,1) (0,p)
Compare with Roulette Wheel Algorithm for Selection Acknowledgement: http://www.edc.ncl.ac.uk/highlight/rhjanuary2007g02.php/
Roulette Wheel Selection Let i = 1, where i denotes chromosome index; Calculate P(xi) using proportional selection; sum = P(xi); choose r ~ U(0,1); whilesum < rdo i = i + 1; i.e. next chromosome sum = sum + P(xi); end returnxias one of the selected parent; repeatuntil 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
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