38
Evolutionary Algorithms Dr Iman Ardekani

Genetic Agorithm

Embed Size (px)

Citation preview

  1. 1. Evolutionary Algorithms Dr Iman Ardekani
  2. 2. Nature, science and engineering Optimization problem Evolutionary algorithms Genetic algorithms An example Content By Iman Ardekani
  3. 3. In the procedure of exploring the natural laws in science for fabricating useful products in engineering, we often face two problems: 1. Learning Problem 2. Optimization Problem Nature, Science and Engineering By Iman Ardekani
  4. 4. Learning Problem Processing and classification of data in order to create information and knowledge. Nature, Science and Engineering Data Information Knowledge Learning Problem By Iman Ardekani
  5. 5. Optimization Problem Using data in order to find an optimal solution, e.g. the best decision or parameters of an optimal controller. Nature, Science and Engineering Knowledge Best Solution Optimization Problem By Iman Ardekani
  6. 6. Optimization problem has a long history. When Euclid founded Geometry (as a knowledge), he tried to solve the first optimization problems. Examples are: 1. What is the shortest path between two points? 2. How to break a stick to make a rectangle with maximum area? Optimization Problem By Iman Ardekani
  7. 7. Optimization Problem By Iman Ardekani
  8. 8. An example for optimization problem (combinatorial): How to place 8 queens on a chess board so that no queens attack each other. How to differentiate with respect to a Queen ? Optimization Problem By Iman Ardekani
  9. 9. An example for optimization problem (multi-objective): How to minimize costs and maximize benefits. There is no answer here. Optimization Problem By Iman Ardekani
  10. 10. Optimization Problem By Iman Ardekani
  11. 11. There are many different EA algorithms, the basic of which can be explained through Genetic Algorithms. They are all random-based solution space searching meta-heuristic algorithms. Evolutionary Algorithms By Iman Ardekani
  12. 12. Mendel (1822-1884) Philosopher and scientist cultivated and tested about 29,000 plants between 1856 and 1863 to verify his laws of heritance. Mendel's work was rejected at first, and was not widely accepted until after he died. Darwin (1809-1882) Scientist developed his evolution theory, stating that evolution is the change in the inherited characteristics of biological populations over successive generations. Evolutionary Algorithms Evolutionary algorithms are based on the basic principles of Mendels foundation of genetics and Darwins theory of evolution . By Iman Ardekani
  13. 13. John Holland Professor of psychology and Professor of electrical engineering at the University of Michigan The main idea of genetic algorithm is that every individual of a species can be characterized by its abilities that help it to cope with its environment in terms of survival and reproduction. Genetic Algorithm By Iman Ardekani
  14. 14. A genetic algorithm is a search heuristic algorithm that mimics the process of natural evolution. It has 5 phases: Genetic Algorithm 1. Population Generation 2. Fitness Evaluation 4. Crossover 5. Mutation 3. Selection By Iman Ardekani
  15. 15. Phase 1: Population Generation Individuals 1. Individuals = a sample from the solution space (each individual is a solution) 2. Generation = a group of individuals Genetic Algorithm individual 1 individual 2 . individual N Population | Popsize = N By Iman Ardekani
  16. 16. Phase 1: Population Generation Population Generation Rules 1. The first generation is produced randomly. 2. Next generations are produced through breeding. Genetic Algorithm Generation 1 Generation 2 Generation 3 By Iman Ardekani
  17. 17. Phase 1: Population Generation Chromosomes and Fitness Each individual has two properties: a) Its location (chromosome composed of genes) b) Its quality (fitness value) Genetic Algorithm individual n Chromosome Fitness By Iman Ardekani
  18. 18. Phase 2: Fitness Evaluation Fitness value of an individual is usually the value of the cost- function (to be optimized) with respect to the locations (genes) of the individual. Genetic Algorithm X1: Gene 1 ... X2: Gene 2 XL: Gene 2 chromosome F(x1,x2,,xL) Fitness value By Iman Ardekani
  19. 19. Phase 3: Selection After evaluating the fitness of all individuals, we use a selection process to generate a mating pool. Each individual may be selected several times. Even low quality individuals have chance to be selected. Individuals in the mating pool are called parents. Genetic Algorithm By Iman Ardekani
  20. 20. Phase 3: Selection Selection Rule: 1. Higher quality = more chance of being selected into the mating pool Example: Genetic Algorithm Individual Fitness Relative 1 90 45% 2 60 30% 3 20 10% 4 30 15% Mating pool individual 1 individual 4 individual 1 individual 2 By Iman Ardekani
  21. 21. Phase 4: Crossover Two parents might be selected randomly from the mating pool to generate two offspring. Genetic Algorithm Mating pool individual 1 individual 4 individual 1 individual 2 Random selection individual 1 individual 4 Offspring 1 Offspring 2 Crossover By Iman Ardekani
  22. 22. Phase 4: Crossover Crossover Rule: 1. Genes of each offspring is a certain combination of the genes of its parents. Genetic Algorithm X1: Gene 1 X2: Gene 2 X4: Gene 4 Parent 1 chromosome X3: Gene 3 Y1: Gene 1 Y2: Gene 2 Parent 2 chromosome Y4: Gene 4 Y3: Gene 3 Offspring 1 chromosome X1: Gene 1 X2: Gene 2 Y4: Gene 4 Y3: Gene 3 By Iman Ardekani
  23. 23. Phase 5: Mutation There is a very low chance for (small) changes in the genes of the offspring; however, it should be considered. Mutation = Small changes in the genes of an offspring Genetic Algorithm X1: Gene 1 X2: Gene 2 Y4: Gene 4 Offspring 1 chromosome Y3: Gene 3 X1: Gene 1 X2: Gene 2 Z : Gene 3 By Iman Ardekani
  24. 24. Phase 5: Mutation After considering the chance for mutation, the next generation will be formed of new offspring. Genetic Algorithm Current Generation Next Generation Fitness evaluation Selection Crossover Mutation By Iman Ardekani
  25. 25. Evolution of a walking creature: Genetic Algorithm By Iman Ardekani
  26. 26. The problem is finding the maximal point of f(x): f(x)=2+xsin(2x) where the solution space is given by -1x 2 Example -1 -0.5 0 0.5 1 1.5 2 0 1 2 3 4 By Iman Ardekani
  27. 27. Defining chromosomes and genes 1 2 1. We can divide the solution space into 212 sections. 2. In this case, each solution value can be represented by a 12-bit binary number. 3. This 12-bit representation can be considered as Chromosome 4. Each bit can be considered as a gene. By Iman Ardekani
  28. 28. Defining chromosomes and genes = 1 = 2 = =0 11 2 212 + Example: 0.9534 can be represented by 1 0 1 0 0 1 1 0 1 0 1 1 By Iman Ardekani
  29. 29. Initial population generation Example By Iman Ardekani
  30. 30. Steps to follow: 1. 10 random value for x (individuals) leads to 10 chromosomes. 2. The fitness value of each individual can be found as y=f(x). 3. The relative fitness can be then obtained accordingly. 4. Based on the relative fitness values, a selection wheel can be created. 5. A mating pool can be created by using the selection wheel. 6. Two individual can be selected from the mating pool as parents. Example By Iman Ardekani
  31. 31. Steps to follow: 7. A random number is generated. If the random number is higher than a certain level (crossover probability), the crossover will happen. 8. Otherwise, two other parents will be selected and step 7 will be repeated. Example 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 Parent 1 Parent 2 By Iman Ardekani
  32. 32. Steps to follow: 7. A random number is generated. If the random number is higher than a certain level (crossover probability), the crossover will happen. 8. Otherwise, two other parents will be selected and step 7 will be repeated. Example 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 Parent 1 Parent 2 By Iman Ardekani
  33. 33. Steps to follow: 9. Crossover process Example 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 Parent 1 Parent 2 1 0 1 0 0 1 1 0 1 0 1 10 0 1 0 0 1 0 0 1 0 0 1Child 1 Child 2 By Iman Ardekani
  34. 34. Steps to follow: 10. For each gene of each child, a random number will be generated. If the number is higher than a certain value (mutation probability very low) then the value of the gene will be changed. Otherwise, the gene remains untouched. Example 1 0 1 0 0 1 0 0 1 0 0 1Child 1 1 0 1 0 0 0 0 0 1 0 0 1Child 1 mutation By Iman Ardekani
  35. 35. Steps to follow: 11. The two children (after considering the mutation probability) will be add to the next generation. 12. Step 7 will be repeated until the size of the new generation becomes equal to the Popsize. 13. Step 2 will be repeated for the new generation. Example By Iman Ardekani
  36. 36. 10th generation Example By Iman Ardekani
  37. 37. 50th generation Example By Iman Ardekani
  38. 38. Questions? End By Iman Ardekani