Successfully reported this slideshow.

Genetic Algorithms

11,749 views

Published on

Genetic Algorithms

  1. 1. Genetic Algorithms By Anas Amjad Obeidat Advanced Algorithms 02 Semester 2 - 2008/2009 March 18 - 2009
  2. 2. Overview <ul><li>Introduction To Genetic Algorithms (GAs) </li></ul><ul><li>GA Operators and Parameters </li></ul><ul><li>Genetic Algorithms To Solve The Traveling Salesman Problem (TSP) </li></ul><ul><li>8-queens Problem </li></ul><ul><li>Summary </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  3. 3. Introduction To Genetic Algorithms (GAs) Semester 2 - 2008/2009 March 18 - 2009
  4. 4. History Of Genetic Algorithms <ul><li>“ Evolutionary Computing” was introduced in the 1960s by I. Rechenberg . </li></ul><ul><li>John Holland wrote the first book on Genetic Algorithms ‘ Adaptation in Natural and Artificial Systems ’ in 1975. </li></ul><ul><li>In 1992 John Koza used genetic algorithm to evolve programs to perform certain tasks. He called his method “ Genetic Programming ”. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  5. 5. What Are GAs? <ul><li>Genetic Algorithms are search and optimization techniques based on Darwin’s Principle of Natural Selection . </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  6. 6. Principle Of Natural Selection <ul><li>“ Select The Best, Discard The Rest” [1] </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  7. 7. GAs Vs other search methods <ul><li>“ Search ” for what? </li></ul><ul><li>Data - Efficiently retrieve a piece of information, (Data mining)  Not AI </li></ul><ul><li>Paths to solutions - Sequence of actions/steps from an initial state to a given goal, (AI-tree/graph search) </li></ul><ul><li>Solutions - Find a good solution to a problem in a large space (search space) of candidate solutions </li></ul><ul><ul><li>Aggressive methods (e.g. Simulated Annealing, Hill Climbing) </li></ul></ul><ul><ul><li>Non-aggressive methods (e.g. GAs) </li></ul></ul>Semester 2 - 2008/2009 March 18 - 2009
  8. 8. Applications of GAs <ul><li>Numerical and Combinatorial Optimization </li></ul><ul><ul><li>Job-Shop Scheduling, Traveling salesman </li></ul></ul><ul><li>Automatic Programming </li></ul><ul><ul><li>Genetic Programming </li></ul></ul><ul><li>Machine Learning </li></ul><ul><ul><li>Classification, NNet training, Prediction </li></ul></ul><ul><li>Economic </li></ul><ul><ul><li>Biding strategies, stock trends </li></ul></ul><ul><li>Ecology </li></ul><ul><ul><li>host-parasite coevolution, resource flow, biological arm races </li></ul></ul><ul><li>Population Genetics </li></ul><ul><ul><li>Viability of gene propagation </li></ul></ul><ul><li>Social systems </li></ul><ul><ul><li>Evolution of social behavior in insect colonies </li></ul></ul>Semester 2 - 2008/2009 March 18 - 2009
  9. 9. <ul><li>Genetic Algorithms Implementation </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  10. 10. Computational Model <ul><li>Main GA algorithm </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  11. 11. Working Mechanism Of GAs Begin Initialize population Optimum Solution? T=T+1 Selection Crossover Mutation N Evaluate Solutions Y Stop T =0 Semester 2 - 2008/2009 March 18 - 2009
  12. 12. Simple Genetic Algorithm <ul><li>function GENETIC-ALGORITHM( population , FITNESS-FN, crossover-rate, mutation-rate ) returns an individual </li></ul><ul><li>inputs : population , a set of individuals </li></ul><ul><li> FITNESS-FN (the fitness function) </li></ul><ul><li>repeat </li></ul><ul><li>new_population  empty set </li></ul><ul><li>calulate the fitness value of each individual </li></ul><ul><li>loop for i from 1 to SIZE( population) do </li></ul><ul><li>x  RANDOM-SELECTION( population , FITNESS-FN) </li></ul><ul><li>add x to new population </li></ul><ul><li>loop for i from 1 to SIZE( population) * crossover-rate do </li></ul><ul><li>x  RANDOM-SELECTION( new_population ) </li></ul><ul><li>y  RANDOM-SELECTION( new_population ) </li></ul><ul><li>x , y  REPRODUCE( x , y ) </li></ul><ul><li>loop for i from 1 to SIZE( population) * mutation-rate do </li></ul><ul><li>x  RANDOM-SELECTION( new_population ) </li></ul><ul><li>x  MUTATE( x ) </li></ul><ul><li>population  new_population </li></ul><ul><li>until the average fitness values are stable, or enough time has elapsed </li></ul><ul><li>return the best individual found in any population </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  13. 13. Nature to Computer Mapping Semester 2 - 2008/2009 March 18 - 2009 Nature Computer Population Individual Fitness Chromosome Gene Reproduction Set of solutions. Solution to a problem. Quality of a solution. Encoding for a Solution. Part of the encoding of a solution. Crossover
  14. 14. GA Operators and Parameters Semester 2 - 2008/2009 March 18 - 2009
  15. 15. Encoding <ul><li>The process of representing the solution in the form of a string that conveys the necessary information. </li></ul><ul><li>Binary Encoding – Most common method of encoding. Chromosomes are strings of 1s and 0s and each position in the chromosome represents a particular characteristic of the problem. Permutation Encoding – Useful in ordering problems such as the Traveling Salesman Problem (TSP). Example. In TSP, every chromosome is a string of numbers, each of which represents a city to be visited. </li></ul><ul><li>Value Encoding – Used in problems where complicated values, such as real numbers, are used and where binary encoding would not suffice. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  16. 16. Fitness Function <ul><li>A fitness function quantifies the optimality of a solution (chromosome) so that that particular solution may be ranked against all the other solutions. </li></ul><ul><li>A fitness value is assigned to each solution depending on how close it actually is to solving the problem. </li></ul><ul><li>Ideal fitness function correlates closely to goal + quickly computable. </li></ul><ul><li>Example. In TSP, f(x) is sum of distances between the cities in solution. The lesser the value, the fitter the solution is. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  17. 17. Recombination <ul><li>The process that determines which solutions are to be preserved and allowed to reproduce and which ones deserve to die out. </li></ul><ul><li>The primary objective of the recombination operator is to emphasize the good solutions and eliminate the bad solutions in a population, while keeping the population size constant. </li></ul><ul><li>“ Selects The Best, Discards The Rest”. </li></ul><ul><li>“ Recombination” is different from “Reproduction”. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  18. 18. Recombination(Cont.) <ul><li>Identify the good solutions in a population. </li></ul><ul><li>Make multiple copies of the good solutions. </li></ul><ul><li>Eliminate bad solutions from the population so that multiple copies of good solutions can be placed in the population. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  19. 19. Roulette Wheel Selection <ul><li>Each current string in the population has a slot assigned to it which is in proportion to it’s fitness . </li></ul><ul><li>We spin the weighted roulette wheel thus defined n times (where n is the total number of solutions). </li></ul><ul><li>Each time Roulette Wheel stops, the string corresponding to that slot is created. </li></ul><ul><li>Strings that are fitter are assigned a larger slot and hence have a better chance of appearing in the new population . </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  20. 20. Example Of Roulette Wheel Selection Semester 2 - 2008/2009 March 18 - 2009 No. String Fitness % Of Total 1 01101 169 14.4 2 11000 576 49.2 3 01000 64 5.5 4 10011 361 30.9 Total 1170 100.0
  21. 21. Roulette Wheel For Example Semester 2 - 2008/2009 March 18 - 2009
  22. 22. Crossover <ul><li>It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics. </li></ul><ul><li>Two strings are picked from the mating pool at random to cross over. </li></ul><ul><li>The method chosen depends on the Encoding Method. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  23. 23. Crossover Methods <ul><li>Single Point Crossover- A random point is chosen on the individual chromosomes (strings) and the genetic material is exchanged at this point. </li></ul>Semester 2 - 2008/2009 March 18 - 2009 Chromosome1 11011 | 00100110110 Chromosome 2 11011 | 11000011110 Offspring 1 11011 | 11000011110 Offspring 2 11011 | 00100110110
  24. 24. Crossover Methods (contd.) <ul><li>Two-Point Crossover- Two random points are chosen on the individual chromosomes (strings) and the genetic material is exchanged at these points. </li></ul>NOTE: These chromosomes are different from the last example. Semester 2 - 2008/2009 March 18 - 2009 Chromosome1 11011 | 00100 | 110110 Chromosome 2 10101 | 11000 | 011110 Offspring 1 10101 | 00100 | 011110 Offspring 2 11011 | 11000 | 110110
  25. 25. Crossover Methods (contd.) <ul><li>Uniform Crossover- Each gene (bit) is selected randomly from one of the corresponding genes of the parent chromosomes. </li></ul>NOTE: Uniform Crossover yields ONLY 1 offspring. Semester 2 - 2008/2009 March 18 - 2009 Chromosome1 11011 | 00100 | 110110 Chromosome 2 10101 | 11000 | 011110 Offspring 101 11 | 00 00 0 | 110 110
  26. 26. Crossover (contd.) <ul><li>Crossover between 2 good solutions MAY NOT ALWAYS yield a better or as good a solution. </li></ul><ul><li>Since parents are good, probability of the child being good is high. </li></ul><ul><li>If offspring is not good (poor solution), it will be removed in the next iteration during “Selection”. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  27. 27. Elitism <ul><li>Elitism is a method which copies the best chromosome to the new offspring population before crossover and mutation. </li></ul><ul><li>When creating a new population by crossover or mutation the best chromosome might be lost. </li></ul><ul><li>Forces GAs to retain some number of the best individuals at each generation. </li></ul><ul><li>Has been found that elitism significantly improves performance. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  28. 28. Mutation <ul><li>It is the process by which a string is deliberately changed so as to maintain diversity in the population set. </li></ul><ul><li>We saw in the giraffes’ example, that mutations could be beneficial. </li></ul><ul><li>Mutation Probability- determines how often the parts of a chromosome will be mutated. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  29. 29. Example Of Mutation <ul><li>For chromosomes using Binary Encoding, randomly selected bits are inverted. </li></ul>NOTE: The number of bits to be inverted depends on the Mutation Probability. Semester 2 - 2008/2009 March 18 - 2009 Offspring 1101 1 00100 1 1 0110 Mutated Offspring 1101 0 00100 1 0 0110
  30. 30. Advantages Of GAs <ul><li>Global Search Methods : GAs search for the function optimum starting from a population of points of the function domain, not a single one. This characteristic suggests that GAs are global search methods. They can, in fact, climb many peaks in parallel, reducing the probability of finding local minima, which is one of the drawbacks of traditional optimization methods. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  31. 31. Advantages of GAs (contd.) <ul><li>Blind Search Methods: GAs only use the information about the objective function . They do not require knowledge of the first derivative or any other auxiliary information, allowing a number of problems to be solved without the need to formulate restrictive assumptions. For this reason, GAs are often called blind search methods. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  32. 32. Advantages of GAs (contd.) <ul><li>GAs use probabilistic transition rules during iterations, unlike the traditional methods that use fixed transition rules. </li></ul><ul><li>This makes them more robust and applicable to a large range of problems. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  33. 33. Advantages of GAs (contd.) <ul><li>GAs can be easily used in parallel machines- Since in real-world design optimization problems, most computational time is spent in evaluating a solution, with multiple processors all solutions in a population can be evaluated in a distributed manner. This reduces the overall computational time substantially. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  34. 34. Genetic Algorithms To Solve The Traveling Salesman Problem (TSP) Semester 2 - 2008/2009 March 18 - 2009
  35. 35. The Problem <ul><li>The Traveling Salesman Problem is defined as: </li></ul><ul><li>‘ We are given a set of cities and a symmetric distance matrix that indicates the cost of travel from each city to every other city. </li></ul><ul><li>The goal is to find the shortest circular tour , visiting every city exactly once, so as to minimize the total travel cost , which includes the cost of traveling from the last city back to the first city’. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  36. 36. Encoding <ul><li>We represent every city with an integer . </li></ul><ul><li>Consider 6 Jordanian cities – </li></ul><ul><li>Amman , Irbid , Al-Mafraq , Al-Salt , Aqabah and Al-Karak and assign a number to each. </li></ul><ul><li>Amman 1 </li></ul><ul><li>Irbid 2 </li></ul><ul><li>Al-Mafraq 3 </li></ul><ul><li>Al-Salt 4 </li></ul><ul><li>Aqabah 5 </li></ul><ul><li>Al-Karak 6 </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  37. 37. Encoding (contd.) <ul><li>Thus a path would be represented as a sequence of integers from 1 to 6. </li></ul><ul><li>The path [1 2 3 4 5 6 ] represents a path from Amman to Irbid , Irbid to Al-Mafraq, Al-Mafraq to Al-Salt , Al-Salt to Aqabah , Aqabah to Al-Karak . Finally Al-Karak to Amman </li></ul><ul><li>This is an example of Permutation Encoding as the position of the elements determines the fitness of the solution. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  38. 38. Fitness Function <ul><li>The fitness function will be the total cost of the tour represented by each chromosome. </li></ul><ul><li>This can be calculated as the sum of the distances traversed in each travel segment. </li></ul><ul><li>The Lesser The Sum, The Fitter The Solution Represented By That Chromosome. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  39. 39. Distance/Cost Matrix For TSP Cost matrix for six city example. Distances in Kilometers Semester 2 - 2008/2009 March 18 - 2009 Amman 1 Irbid 2 Al-Mafraq 3 Al-Salt 4 Al-Aqabah 5 Al-Karak 6 Amman [1] 0 90 100 35 300 200 Irbid [2] 90 0 60 120 400 290 Al-Mafraq [3] 100 60 0 70 480 225 Al-Salt [4] 35 120 70 0 320 150 Aqabah [5] 300 400 480 320 0 290 Al-Karak [6] 200 290 225 150 290 0
  40. 40. Fitness Function (contd.) <ul><li>So, for a chromosome [4 1 3 2 5 6], the total cost of travel or fitness will be calculated as shown below </li></ul><ul><li>Fitness = 35+ 100+ 60+ 400+ 290 + 150 </li></ul><ul><li> = 1035 kms. </li></ul><ul><li>Since our objective is to Minimize the distance, the lesser the total distance, the fitter the solution. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  41. 41. Selection Operator <ul><li>Tournament Selection. </li></ul><ul><li>As the name suggests tournaments are played between two solutions and the better solution is chosen and placed in the mating pool . </li></ul><ul><li>Two other solutions are picked again and another slot in the mating pool is filled up with the better solution. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  42. 42. Why we can’t use single-point <ul><li>Single point crossover method randomly selects a crossover point in the string and swaps the substrings . </li></ul><ul><li>This may produce some invalid offsprings as shown below. </li></ul>Semester 2 - 2008/2009 March 18 - 2009 4 1 3 2 5 6 4 3 2 1 5 6 4 1 3 1 5 6 4 3 2 2 5 6
  43. 43. Order 1 crossover <ul><li>Idea is to preserve relative order that elements occur </li></ul><ul><li>Informal procedure: </li></ul><ul><ul><li>1. Choose an arbitrary part from the first parent </li></ul></ul><ul><ul><li>2. Copy this part to the first child </li></ul></ul><ul><ul><li>3. Copy the numbers that are not in the first part, to the first child: </li></ul></ul><ul><ul><ul><li>starting right from cut point of the copied part, </li></ul></ul></ul><ul><ul><ul><li>using the order of the second parent </li></ul></ul></ul><ul><ul><ul><li>and wrapping around at the end </li></ul></ul></ul><ul><ul><li>4. Analogous for the second child, with parent roles reversed </li></ul></ul>Semester 2 - 2008/2009 March 18 - 2009
  44. 44. Order 1 crossover example <ul><li>Copy randomly selected set from first parent </li></ul><ul><li>Copy rest from second parent in order 1,9,3,8,2 </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  45. 45. Mutation Operator <ul><li>The mutation operator induces a change in the solution, so as to maintain diversity in the population and prevent Premature Convergence . </li></ul><ul><li>In our project, we mutate the string by randomly selecting any two cities and interchanging their positions in the solution, thus giving rise to a new tour. </li></ul>Semester 2 - 2008/2009 March 18 - 2009 4 1 3 2 5 6 4 5 3 2 1 6
  46. 46. TSP Example: details (1) <ul><li>Initial Population: P1 : {2,1,3,4,5,6} P2 : {1,2,3,5,4,6} P3: {1,4,3,2,6,5} P4: {5,3,2,1,4,6} </li></ul><ul><li>Generation 1: 1- Fitness Function (P1) (2,1) + (1,3) + (3,4) + (4,5) + (5, 6) + (6,2) = 90 + 100 + 70 + 320 + 290 +290 = 1060 km 2- Fitness Function (P2) (1,2)+(2,3)+(3,5) + (5,4) + (4,6) + (6,1) = 90 + 60 +480 + 320 + 150 + 200 = 1300 km 3- Fitness Function (P3) (1,4) + (4,3)+(3,2)+(2,6)+ (6,5)+(5,1) = 35 + 70 + 60 + 290 + 290 + 300 = 1045 km 4- Fitness Function (P4) (5,3)+(3,2)+(2,1)+(1,4)+(4,6)+(6,5) = 480 + 60 + 90 + 35 + 150 + 290 = 1105 km </li></ul>Fitness Function: Minimum Distance between Cites Semester 2 - 2008/2009 Termination Condition: Generation 3 March 18 - 2009
  47. 47. TSP Example: details (2) <ul><li>Tournament Selection P1: 1060 km P2: 1300 km P3: 1045 km P4: 1105 km </li></ul><ul><li>Crossover (Two Points): Order (1) </li></ul>Semester 2 - 2008/2009 The Winners P1 & P3 Table 1 March 18 - 2009 Nodes Solution Notes P1 2 1 | 3 4 5 | 6 P3 1 4 | 3 2 6 | 5 S1 2 6 | 3 4 5 | 1 5 1 4 3 2 6 (Order 1) S2 4 5 | 3 2 6 | 1 6 2 1 3 4 5 (Order 1)
  48. 48. TSP Example: details (3) <ul><li>Generation 2 P1 : {2,1,3, 4,5,6} = 1060 km P2 : {1,4,3,2,6,5} = 1045 km P3: {2,6,3,4,5,1} = 1295 km P4: {4,5,3,2,6,1} = 1385 km </li></ul><ul><li>Tournament Selection P1: 1060 km P2: 1045 km P3: 1295 km P4: 1385 km </li></ul><ul><li>Crossover (Two Points): Order (1) </li></ul>The Winners P1 & P2 Table 2 Semester 2 - 2008/2009 March 18 - 2009 Nodes Solution Notes P1 2 1 | 3 4 5 | 6 P3 1 4 | 3 2 6 | 5 S1 2 6 | 3 4 5 | 1 1 2 6 (Order 1) S2 4 5 | 3 2 6 | 1 1 4 5 (Order 1)
  49. 49. TSP Example: details (4) <ul><li>Generation 3 P1 : {2,1,3, 4,5,6} = 1060 km P2 : {1,4,3,2,6,5} = 1045 km P3: {2,6,3,4,5,1} = 1295 km P4: {4,5,3,2,6,1} = 1385 km </li></ul><ul><li>Tournament Selection P1: 1060 km P2: 1045 km P3: 1295 km P4: 1385 km </li></ul><ul><li>Crossover (Two Points): Order (1) The crossover result will be as previous table (2) </li></ul><ul><li>Mutation ^P1 2 6 3 4 5 1 Fitness = 1290 km </li></ul><ul><li>We used the mutation to solve the local minimum problem </li></ul>The Winners P1 & P2 We Find that Optimal solution is a P2 Depends on Generation #3 Semester 2 - 2008/2009 March 18 - 2009
  50. 50. 8-queens Problem Semester 2 - 2008/2009 March 18 - 2009
  51. 51. 8-queens <ul><li>How to represent the 8-queens problem in GA? </li></ul><ul><li>Remember an individual is a potential solution. </li></ul><ul><li>In the 8-queens problem, it will be a state with 8-queens on the board. </li></ul><ul><li>One way is to specify the position of the 8 queens, each in a column of 8 squares. </li></ul><ul><li>For example, the setting on the right will be specified by this chromosome: (86427531) </li></ul><ul><li>This can be represented by bits or digits. </li></ul><ul><li>Note: this is not an optimization problem. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  52. 52. 8-queens: (a) Initialization <ul><li>Assume we have the following initial populations with 4 individuals: </li></ul><ul><li>v 1 = (24748552) </li></ul><ul><li>v 2 = (32752411) </li></ul><ul><li>v 3 = (24415124) </li></ul><ul><li>v 4 = (32543213) </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  53. 53. 8-queens: (b) Fitness Evaluation <ul><li>Fitness function: the less conflicts (attacking queens) the better </li></ul><ul><li>We can use the number of non-attacking pairs of queens. The highest possible value of the fitness function is 8 C 2 = 28. Every solution will have a fitness value of 28. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  54. 54. 8-queens: (b) Fitness Evaluation <ul><li>We calculate the fitness value of each chromosome. </li></ul><ul><li>For example, fitness of the chromosome v 1 (24748552) is 28 – 4 = 24 </li></ul><ul><li>That is because only 4 pairs of queens attack each other: </li></ul><ul><ul><li>The queens on 1 st and 8 th column </li></ul></ul><ul><ul><li>The queens on 2 nd and 4 th column </li></ul></ul><ul><ul><li>The queens on 6 th and 7 th column </li></ul></ul><ul><ul><li>The queens on 3 rd and 8 th column </li></ul></ul>Semester 2 - 2008/2009 March 18 - 2009
  55. 55. 8-queens: (b) Fitness Evaluation <ul><li>The fitness values for the chromosomes are calculated as follows: </li></ul><ul><li>eval ( v 1 ) = 24 </li></ul><ul><li>eval ( v 2 ) = 23 </li></ul><ul><li>eval ( v 3 ) = 20 </li></ul><ul><li>eval ( v 4 ) = 11 </li></ul><ul><li>None of the chromosomes is the solution to the problem. If a solution is found, the algorithm stops and returns the solution. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  56. 56. 8-queens: (c) Selection <ul><li>The total sum of fitness values = 24 + 23 + 20 + 11 = 78 </li></ul><ul><li>So, the probability of each chromosome to be selected into the next generation is as follows: </li></ul><ul><li>prob ( v 1 ) = 24/78 = 31% </li></ul><ul><li>prob ( v 2 ) = 23/78 = 29% </li></ul><ul><li>prob ( v 3 ) = 20/78 = 26% </li></ul><ul><li>prob ( v 4 ) = 11/78 = 14% </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  57. 57. 8-queens: (c) Selection <ul><li>Next, we arrange these probabilities into different ranges from 0 to 1 to facilitate the roulette wheel process: </li></ul><ul><li>v 1 : 0.00 to 0.31 </li></ul><ul><li>v 2 : 0.31 to 0.60 </li></ul><ul><li>v 3 : 0.60 to 0.84 </li></ul><ul><li>v 4 : 0.84 to 1.00 </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  58. 58. 8-queens: (c) Selection <ul><li>Four random numbers are then drawn for the next generation. Suppose we have the following random numbers: </li></ul><ul><li>0.4012 </li></ul><ul><li>0.1486 </li></ul><ul><li>0.5973 </li></ul><ul><li>0.8129 </li></ul><ul><li>The following individuals will be chosen: </li></ul><ul><li>0.4012  v 2 (32752411)  v 1 ' </li></ul><ul><li>0.1486  v 1 (24748552)  v 2 ' </li></ul><ul><li>0.5973  v 2 (32752411)  v 3 ' </li></ul><ul><li>0.8129  v 3 (24415124)  v 4 ' </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  59. 59. 8-queens: (d) Crossover <ul><li>Next, some of these four chromosomes will perform crossover. Suppose the crossover probability is 0.80. All 4 chromosomes are selected for crossover (the number is rounded up to an even number). </li></ul><ul><li>The selected chromosomes are paired up randomly. </li></ul><ul><li>A crossover point is randomly chosen for each crossover. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  60. 60. 8-queens: (d) Crossover <ul><li>Suppose the 3 rd digit in the first pair is chosen as the crossover point. </li></ul><ul><li> v 1 ' = (327 | 52411) </li></ul><ul><li> v 2 ' = (247 | 48552) </li></ul><ul><li>After crossover, we will have: </li></ul><ul><li> v 1 '' = (327 | 48522) </li></ul><ul><li> v 2 '' = (247 | 52411) </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  61. 61. v 1 ' v 2 ' v 1 '' v 2 '' Semester 2 - 2008/2009 March 18 - 2009
  62. 62. 8-queens: (e) Mutation <ul><li>For each gene (digit), there is a small chance that it will be mutated. </li></ul><ul><li>In the 8-queens problem, it means choosing a queen at random and moving it to a random square in its column. </li></ul><ul><li>Suppose the mutation probability is 0.05 </li></ul><ul><li>32 random numbers are generated in total. </li></ul><ul><li>Suppose the 6 th , 19 th , and 32 nd random numbers are smaller than 0.05. </li></ul><ul><li>The three corresponding digits will be mutated: </li></ul><ul><ul><li>6 th digit in v 1 '' </li></ul></ul><ul><ul><li>3 rd digit in v 3 '' </li></ul></ul><ul><ul><li>8 th digit in v 4 '' </li></ul></ul>Semester 2 - 2008/2009 March 18 - 2009
  63. 63. 8-queens: (e) Mutation <ul><li>For each digit to be mutated, another random number will be generated to determine where the queen should be moved to. </li></ul><ul><li>For example, </li></ul><ul><li> v 1 '' = (32748 5 22) </li></ul><ul><li>If a random number determines that the digit should be mutated to 1, the new chromosome will become: </li></ul><ul><li>v 1 ''' = (32748 1 22) </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  64. 64. 8-queens: (e) Mutation <ul><li>The same process is applied to every gene to be mutated. </li></ul><ul><li>The final chromosomes for the new generation are thus as follows: </li></ul><ul><li>v 1 ''' = (32748122) </li></ul><ul><li>v 2 ''' = (24752411) </li></ul><ul><li>v 3 ''' = (32252124) </li></ul><ul><li>v 4 ''' = (24415417) </li></ul><ul><li>The process is then repeated from step (b) until a solution is found. </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  65. 65. 8-queens: A Summary Semester 2 - 2008/2009 March 18 - 2009
  66. 66. Summary Semester 2 - 2008/2009 March 18 - 2009
  67. 67. <ul><li>Genetic Algorithms (GAs) implement optimization strategies based on simulation of the natural law of evolution of a species by natural selection </li></ul><ul><li>The basic GA Operators are: </li></ul><ul><li>Encoding </li></ul><ul><li>Recombination </li></ul><ul><li>Crossover </li></ul><ul><li>Mutation </li></ul><ul><li>GAs have been applied to a variety of function optimization problems, and have been shown to be highly effective in searching a large, poorly defined search space even in the presence of difficulties such as high-dimensionality, multi-modality, discontinuity and noise. </li></ul>Semester 2 - 2008/2009 Summary March 18 - 2009
  68. 68. References <ul><li>D. E. Goldberg, ‘Genetic Algorithm In Search, Optimization And Machine Learning’, New York: Addison – Wesley (1989) </li></ul><ul><li>John H. Holland ‘Genetic Algorithms’, Scientific American Journal, July 1992. </li></ul><ul><li>Kalyanmoy Deb, ‘An Introduction To Genetic Algorithms’, Sadhana, Vol. 24 Parts 4 And 5. </li></ul><ul><li>T. Starkweather, et al, ‘A Comparison Of Genetic Sequencing Operators’, International Conference On Gas (1991) </li></ul><ul><li>D. Whitley, et al , ‘Traveling Salesman And Sequence Scheduling: Quality Solutions Using Genetic Edge Recombination’, Handbook Of Genetic Algorithms, New York </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  69. 69. References (contd.) <ul><li>WEBSITES </li></ul><ul><li>www.iitk.ac.in/kangal </li></ul><ul><li>www.math.princeton.edu </li></ul><ul><li>www.genetic-programming.com </li></ul><ul><li>www.garage.cse.msu.edu </li></ul><ul><li>www.aic.nre.navy.mie/galist </li></ul>Semester 2 - 2008/2009 March 18 - 2009
  70. 70. Questions ? Semester 2 - 2008/2009 March 18 - 2009

×