1 / 52

CS464: Soft Computing Lecture 3 : Genetic Algorithms Introduction

Explore the basic principles and history of Genetic Algorithms (GAs) through an introduction to biological evolution, natural selection, and the workings of GAs. Includes simple GA examples.

rickr
Download Presentation

CS464: Soft Computing Lecture 3 : Genetic Algorithms Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS464: Soft ComputingLecture 3: Genetic AlgorithmsIntroduction Dr. Mohammad Nassef Department of Computer Science Faculty of Computers and Information Cairo University Egypt CS-FCI-CU-EG

  2. Outline • Very basic Biological Background • Motivation • Classes of Search Techniques • History and Definition of GA • Biological Evolution Process (by Example) • Simple GA Examples FCI-CU-EG

  3. Human Body Human Organs Tissues Cells Genome FCI-CU-EG

  4. Cell .. Genome .. Chromosomes .. DNA .. Genes FCI-CU-EG

  5. Genome FCI-CU-EG

  6. Human Chromosomes Under Microscope FCI-CU-EG

  7. Evolution in the real world • Each cell of a living thing contains chromosomes - strings of DNA • Each chromosome contains a set of genes - blocks of DNA • Each gene determines some aspect of the organism (like eye colour) • A collection of genes is sometimes called a genotype • A collection of aspects (like eye colour) is sometimes called a phenotype • Reproduction involves recombination of genes from parents and then small amounts of mutation (errors) in copying • The fitness of an organism is how much it can reproduce before it dies • Evolution based on “survival of the fittest” Davidhales.name

  8. Genetic Algorithms - History “Genetic Algorithms are good at taking large, potentially huge search spaces and navigating them, looking for optimal combinations of things, solutions you might not otherwise find in a lifetime.” - Salvatore Mangano Computer Design, May 1995 Windy Williams – dbai.tuwien.ac.at

  9. Genetic Algorithms - History • John Holland developed Genetic Algorithms: • To understand the adaptive processes of natural systems • To design artificial systems software that retains the robustness of natural systems Windy Williams – dbai.tuwien.ac.at

  10. Biological Evolution Process“Natural Selection” + “Genetic Inheritance” FCI-CU-EG

  11. Basic Idea of Principle of Natural Selection “Select The Best, Discard The Rest” CS.Stonybrook.edu

  12. Evolution Through Natural Selection Initial Population Of Animals Struggle For Existence-Survival Of the Fittest Surviving Individuals Reproduce, Propagate Favorable Characteristics Millions Of Years Evolved Species (Favorable Characteristic Now A Trait Of Species) CS.Stonybrook.edu

  13. http://ib-poland.virtualave.net/ee/genetic1/3geneticalgorithms.htm http://ib-poland.virtualave.net/ee/genetic1/3geneticalgorithms.htm

  14. What Are Genetic Algorithms (GAs)? Genetic Algorithms are search and optimization techniques based on Darwin’s Principle of Natural Selection. Genetic Algorithms implement optimization strategies by simulating evolution of species through natural selection. CS.Stonybrook.edu

  15. Working Mechanism Of GAs Begin Initialize population Evaluate Solutions T =0 Optimum Solution? N Selection Y T=T+1 Stop Crossover Mutation CS.Stonybrook.edu

  16. Simple Genetic Algorithm Simple_Genetic_Algorithm() {Initialize the Population; Calculate Fitness Function; // Evaluate Individuals …While(Fitness Value != Optimal Value) // Continue Evolution …{ Selection; //Natural Selection, Survival Of Fittest … Crossover; //Reproduction, Propagate favorable characteristics … Mutation; //Mutation … Calculate Fitness Function;} } CS.Stonybrook.edu

  17. Nature to Computer Mapping CS.Stonybrook.edu

  18. Components of a GA A problem to solve, and ... • Encoding technique (gene, chromosome) • Initialization procedure (creation) • Evaluation function (environment) • Selection of parents (reproduction) • Genetic operators (recombination, mutation) • Parameter settings (practice and art) Windy Williams – dbai.tuwien.ac.at

  19. Example 1: A Very Simple Example • Generate a bit string for the decimal number 31. • Traditional Technique: • Start by 00000 till reaching 11111 • GA Steps: • Build an initial population of random individuals (chromosomes or initial solutions) • Evaluate fitness of individuals • Select some individuals to • Apply Crossover and Mutation • Build next generation • Go to step 2. FCI-CU-EG

  20. Example 1: GA Step 1 • Build an initial population of random individuals • Build an initial population of random individuals G01 G02 G03 G04 G0 00100 10100 01011 00101 • Generation 0 FCI-CU-EG

  21. Example 1: GA Step 2 • Evaluate fitness of individuals G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 11 5 • Fitness can be calculated as the decimal value of each bit string FCI-CU-EG

  22. Example 1: GA Step 3 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 20 11 11 5 • Individual with good fitness should be selected for crossover and mutation. FCI-CU-EG

  23. Example 1: GA Step 3 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 11 5 • Individual with good fitness should be selected for crossover and mutation. FCI-CU-EG

  24. Example 1: GA Step 3 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 • How to apply crossover between these 2 parents? • Single point? Multiple point? Location? • It depends on your implementation parameters • Crossover may happen or not according to the probability of crossover FCI-CU-EG

  25. Example 1: GA Step 3 – Trial 1 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 G11 G12 10011 01100 • Single point crossover after 2 bits (Genes) FCI-CU-EG

  26. Example 1: GA Step 3 – Trial 1 • Select some individuals to apply crossover and mutation 20 11 G01 G02 G03 G04 G0 00100 10100 01011 00101 G13 G11 G12 G14 G1 00100 10011 01100 00101 4 19 12 5 Fitness? FCI-CU-EG

  27. Example 1: GA Step 3 – Trial 2 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 G11 G12 10111 01000 • Single point crossover after 3 bits FCI-CU-EG

  28. Example 1: GA Step 3 – Trial 2 • Select some individuals to apply crossover and mutation 20 11 G01 G02 G03 G04 G0 00100 10100 01011 00101 G13 G11 G12 G14 00100 10111 01000 00101 4 23 8 5 Fitness? FCI-CU-EG

  29. Example 1: GA Step 3 – Trial 2 • Select some individuals to apply crossover and mutation 20 11 G01 G02 G03 G04 G0 00100 10100 01011 00101 G13 G11 G12 G14 G11 G12 00100 10111 01000 00101 10111 01000 4 23 8 5 23 8 • How to apply a mutation over some individual? • For bit strings, and according to the mutation probability of your implementation, one bit might be flipped! FCI-CU-EG

  30. Example 1: GA Step 3 – Trial 2 • Select some individuals to apply crossover and mutation 20 11 G01 G02 G03 G04 G0 00100 10100 01011 00101 G13 G11 G12 G14 G1 00100 10111 11111 01000 00101 4 23 8 5 31 OUR OBJECTIVE! FCI-CU-EG

  31. Example 1: GA Step 3 – Trial 3 • Select some individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 • Applying multiple point crossover! FCI-CU-EG

  32. G01 G02 G03 G04 G0 00100 10100 01011 00101 FCI-CU-EG

  33. Does it really cost one iteration? • Real world problems are not that easy. • You could have: • Hundreds of individuals (chromosomes) • Huge search space • You might perform thousands of iterations (have thousands of generations) before reaching your objective! FCI-CU-EG

  34. Example 1: GA Step 3 – Trial 4 • Select ALL individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 20 11 11 5 G11 G12 00011 01100 Crossover 3 12 FCI-CU-EG

  35. Example 1: GA Step 3 – Trial 4 • Select ALL individuals to apply crossover and mutation G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 20 11 11 5 G11 G13 G12 G14 00011 10101 01100 00100 Crossover 3 21 12 4 G11 G13 G12 G14 Mutation 00011 11101 01100 00110 3 21→29 12 4→6 FCI-CU-EG

  36. Example 1: GA Step 4 • Build next generation .. Full Replacement or Mix? G01 G02 G03 G04 G0 00100 10100 01011 00101 4 20 20 11 11 5 G11 G13 G12 G14 00011 10101 01100 00100 Crossover 3 21 12 4 G11 G13 G12 G14 Mutation 00011 11101 01100 00110 3 29 12 6 FCI-CU-EG

  37. Example 1: GA Step 4 • Build next generation .. Mixing G02 G03 G13 G11 G1 10100 01011 00011 11101 20 11 3 29 G22 G21 G02 G03 00001 11111 10100 01011 Crossover 1 31 20 11 G22 G21 G02 G03 00000 11111 10100 11011 Mutation 0 31 20 27 OUR OBJECTIVE! FCI-CU-EG

  38. How do you encode a solution? • Obviously this depends on the problem! • GA’s often encode solutions as fixed length “bitstrings” (e.g. 101110, 111111, 000101) • Each bit represents some aspect of the proposed solution to the problem • For GA’s to work, we need to be able to “test” any string and get a “score” indicating how “good” that solution is. (Fitness) • Sometimes, your solutions (chromosomes) will be used in their original format (floating point numbers or alphabetical strings) Davidhales.name

  39. Example 2: f(x) = x² Finding the maximum of a function: f(x) = x² Range [0, 31] Goal/Objective: find max (31² = 961) Binary representation: string length 5  32 numbers (0-31) = f(x) STRI, University of Hertfordshire

  40. binary value fitness String 1 00110 6 36 String 2 00011 3 9 String 3 01010 10 100 String 4 10101 21 441 String 5 00001 1 1 f(x) = x² Initial Random Population STRI, University of Hertfordshire

  41. binary value fitness String 1 00110 6 36 String 2 00011 3 9 String 3 01010 10 100 String 4 10101 21 441 String 5 00001 1 1 f(x) = x² Selection • Worst one can be removed STRI, University of Hertfordshire

  42. binary value fitness String 1 00110 6 36 String 2 00011 3 9 String 3 01010 10 100 String 4 10101 21 441 String 5 00001 1 1 f(x) = x² Selection • Best individual: can be reproduced twice  keep population size constant STRI, University of Hertfordshire

  43. binary value fitness String 1 00110 6 36 String 2 00011 3 9 String 3 01010 10 100 String 4 10101 21 441 String 5 00001 1 1 f(x) = x² Selection • All others are reproduced once STRI, University of Hertfordshire

  44. f(x) = x² Recombination partner x-position String 1 String 2 4 String 3 String 4 2 • Parents and x-position randomly selected (equal recombination) 0 0 1 1 1 0 0 1 1 0 String 1: 0 0 0 1 0 0 0 0 1 1 String 2: STRI, University of Hertfordshire

  45. partner x-position String 1 String 2 4 String 3 String 4 2 f(x) = x² Recombination • Parents and x-position randomly selected (equal recombination) 0 1 1 0 1 0 1 0 1 0 String 3: 1 0 0 1 0 1 0 1 0 1 String 4: STRI, University of Hertfordshire

  46. f(x) = x² Mutation • bit-flip: • Offspring-String 1: 00111 (7) 10111 (23) • String 4: 10101 (21)  10001 (17) STRI, University of Hertfordshire

  47. binary value fitness String 1 00110 6 36 String 2 00011 3 9 String 3 01010 10 100 String 4 10101 21 441 String 5 00001 1 1 f(x) = x² Old Generation STRI, University of Hertfordshire

  48. f(x) = x² New Generation • All individuals in the parent population are replaced by offspring in the new generation • (generations are discrete!) • New population (Offspring): binary value fitness String 1 10111 23 529 String 2 00010 2 4 String 3 01101 13 169 String 4 10000 16 256 10001 17 String 5 289 STRI, University of Hertfordshire

  49. Iterate until termination condition reached, e.g.: Number of generations Best fitness Process time No improvements after a number of generations Result after one generation: Best individual: 10111 (23) – fitness 529 f(x) = x² When to stop? STRI, University of Hertfordshire

  50. Conclusion A genetic algorithm maintains apopulation of candidate solutions for theproblemat hand,and makes it evolve by iteratively applyinga set of stochastic operators. Introduction to Genetic Algorithms

More Related