Download presentation
Presentation is loading. Please wait.
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 Fitness function Mutation Crossover
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 = (fitness = = 4) B = (fitness = = 3) C = (fitness = = 2) D = (fitness = = 1) E = (fitness = = 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 = (parent 1) E = (parent 2) F = (Mutate A) G = 11011(Crossover AE 2nd 3rd bits of E on A, also clone E ) H = (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 = (parent 1) E = (parent 2) F = (Mutate A) G = (Crossover AE) H = (Crossover AE)
11
Calculate the fitness of each individual
G = = 4 H = = 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)
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 Reward 0’s, not 1’s
B = = = 1 C = = = 3 D = = = 1 E = = = 0 Reward 0’s, not 1’s
17
Example Initial Population A = 01101 = 1 + 0 + 0 + 1 + 0 = 2
B = = = 1 C = = = 3 D = = = 1 E = = = 0
18
Example Who should our parents be? (A and C)
19
Example Who should our parents be? What next?
C = = = 3 What next?
20
Mating! A = = = 2 C = = = 3 F = = 3 G = = 2 H = = 2
21
Calculate Fitness! A = 01101 = 1 + 0 + 0 + 1 + 0 = 2
G = = 2 H = = 2
22
Pick the top two! A = 01101 = 1 + 0 + 0 + 1 + 0 = 2
F = = 3 G = = 2 H = = 2 Parents, C and F
23
Start Over! C = 01010 = 1 + 0 + 1 + 0 + 1 = 3 F = 01100 = 3 G = ?
H = ? I = ?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.