Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE 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 d31 d23 d14 4 3 d34 TSP: State Representation Position (α) City (i) 1 1 1 2 0 3 0 4 0 `i’ varies over cities `α’ varies over positions 2 0 0 1 0 3 0 1 0 0 4 0 0 0 1 Objective Functions 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) Minimize F = F1 + F2 2 Metropolis Algorithm 1) 2) 3) 4) 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 e (‘T’ is the “temperature” and KB, the Boltzmann constant) 5) E ( state) K BT 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 e E ( state) K BT =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? E ( state) K BT The significance of p (= e ) 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,p) (0,1) 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,p) (0,1) Compare with Roulette Wheel Algorithm for Selection Chromosome 1 2 3 4 5 Total Fitness 6.82 1.11 8.48 2.57 3.08 22.0 % of total 31 5 38 12 14 100 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); while sum < r do i = i + 1; i.e. next chromosome sum = sum + P(xi); end return 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 e 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 E ( state) K BT 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