1 / 23

Using GA’s to Solve Problems

Learn how Genetic Algorithms (GAs) can solve optimization problems by evolving solutions based on natural selection principles. Understand the components, process, and application of GAs through practical examples.

kirish
Download Presentation

Using GA’s to Solve Problems

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. Using GA’s to Solve Problems Amy Hoover

  2. What is a Genetic Algorithm? • Genetic Algorithm – “a search technique … to find exact or approximate solutions to optimization and search problems.” -Wikipedia

  3. Components of a GA • Chromosome • How we represent the individual • Fitness function • How we rate the individual • Mutation • Crossover

  4. How do GAs work? • Randomize initial population (of 5) • Note: These were arbitraily picked • A = 10111 • B = 11100 • C = 00110 • D = 00001 • E = 11011

  5. Evaluate the fitness of each individual (A, B, C, D, E) in the population • A = 10111 (fitness = 1+ 0 + 1 + 1+ 1 = 4) • B = 11100 (fitness = 1 + 1 + 1+ 0 + 0 = 3) • C = 00110 (fitness = 0 + 0 + 1+ 1 + 0 = 2) • D = 00001 (fitness = 0 + 0 + 0+ 0 + 1 = 1) • E = 11011 (fitness = 1 + 1 + 0+ 1 + 1 = 4)

  6. Repeat • Select parents • Who would we choose from the previous generation? (A and E) • Mate the parents, they plus their offspring form next generation • How do we mate them? • What will the next generation look like?

  7. Next Generation • A = 10111 (parent 1 clone) • E = 11011 (parent 2 clone) • F = ? • G = ? • H = ? • Which generation are F, G, and H from?

  8. Next Generation • A = 10111 (parent 1) • E = 11011 (parent 2) • F = ? • G = ? • H = ? • Which generation are F, G, and H from? • How can we make F, G, H?

  9. Crossover and Mutation • Let’s make F, G, H (Gen 1 from initial generation 0) • A = 10111 (parent 1) • E = 11011 (parent 2) • F = 11111 (Mutate A) • G = 11011(Crossover AE 2nd 3rd bits of E on A, also clone E ) • H = 10011 (Crossover AE 3rd and 4th of E) • Which generation are F, G, and H from? • How can we make F, G, H?

  10. Calculate the fitness of each individual • A = 10111 (parent 1) • E = 11011 (parent 2) • F = 11111 (Mutate A) • G = 11011 (Crossover AE) • H = 10011 (Crossover AE)

  11. Calculate the fitness of each individual • A = 10111 = 4 • E = 11011 = 4 • F = 11111 = 5 • G = 11011 = 4 • H = 10011 = 3 • Select parents (F,G)

  12. Repeat • Select parents (A, E, F, G, H) • How do we pick the parents? • Pick the top 2 from A, E, F, G, H • Mate parents (crossover, mutation) • Calculate fitness • (Repeat Select parents…)

  13. Example • Problem: I want to maximize the number of 0’s in a bit string • (I want A = 00000) • Let’s work through the psuedo code

  14. Example • Problem: I want to maximize the number of 0s in a bit string • (I want A = 00000) • Step 1: Randomize the initial population • A = 01101 • B = 11011 • C = 01010 • D = 01111 • E = 11111

  15. Example • Initial Population (gen 0) • A = 01101 • B = 11011 • C = 01010 • D = 01111 • E = 11111 • Calculate fitness (recall 0’s are good, 1’s are bad, we want to reward good genes!)

  16. Example • Initial Population • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • B = 11011 = 0 + 0 + 1 + 0 + 0 = 1 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • D = 01111 = 1 + 0 + 0 + 0 +0 = 1 • E = 11111 = 0 + 0 + 0 + 0 +0 = 0 • Reward 0’s, not 1’s

  17. Example • Initial Population • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • B = 11011 = 0 + 0 + 1 + 0 + 0 = 1 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • D = 01111 = 1 + 0 + 0+ 0+ 0 = 1 • E = 11111 = 0 + 0 + 0 + 0 + 0 = 0

  18. Example • Who should our parents be? (A and C) • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • B = 11011 = 0 + 0 + 1 + 0 + 0 = 1 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • D = 01111 = 1 + 0 + 0+ 0+ 0 = 1 • E = 11111 = 0 + 0 + 0 + 0 + 0 = 0

  19. Example • Who should our parents be? • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • What next?

  20. Mating! • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • F = 01100 = 3 • G = 01110 = 2 • H = 01011 = 2

  21. Calculate Fitness! • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • F = 01100 = 3 • G = 01110 = 2 • H = 01011 = 2

  22. Pick the top two! • A = 01101 = 1 + 0 + 0 + 1 + 0 = 2 • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • F = 01100 = 3 • G = 01110 = 2 • H = 01011 = 2 • Parents, C and F

  23. Start Over! • C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 • F = 01100 = 3 • G = ? • H = ? • I = ?

More Related