sass ga talk - slac · sass talk, may 4, 2011 patricia voll 1. what is a genetic algorithm?...
TRANSCRIPT
Genetic Algorithms SASS Talk, May 4, 2011
Patricia Voll
1
What is a Genetic Algorithm?
Solution!
Generate Random
Population
Evaluate Fitness
Generate New
Population:
Select Parents
Crossover
MutationReplace Old Population
Test for End Condition
Start
2
Outline• What are the
genes?
• Defining a Population
• Fitness
• Selection
• Mixing/Crossover
• Mutation
• Carry-Over
• End Condition
3
Simple Example• Problem: On a surface with hills and valleys, where
is the highest point?
�5
0
5
�5
0
5
�200
�100
0
100
4
Variables as Genetic Code
• An “individual” is a set of variables that form a possible solution to the problem.
• Ex: a set of x and y coordinates
Ex: (x, y) = (1, 3)
5
Variable “Genes”: Binary
• Gray Decoding vs. Standard Binary
• Set Minimum and Maximum
# - Binary0 - 0000001 - 0000012 - 0000103 - 0000114 - 000100
..........7 - 0001118 - 001000
..........15 - 00111116 - 010000
Ex: (x, y) = (1, 3)→ (001, 011)
6
Populations• A set of individuals• Populations need to be large enough to have
variety, but small enough to allow fast evaluation • Ex: a set of (x, y) coordinates
0.986674 −0.2285873.87339 −1.65946.41143 −2.60451−2.89927 −3.37351−6.58189 0.271406−3.25734 −5.20694−0.490348 2.43147−0.0859103 4.88067
5.45403 5.04831−3.5718 −1.16343
x y
7
Generating a Population• Start with random population covering solution
space
• Each generation is mixed to form next generation
8
Fitness• GAs require a way to evaluate the fitness
of each individual in order to determine the best solutions so far and to recognize when end conditions are met
• Ex: the height of the surface at the (x, y) locationFor (x, y) = (1, 3)z = −(x− 1)2 − (y − 4)2 + 200J2(y) sinx
= −(1− 1)2 − (3− 4)2 + 200J2(y) sin(1)= 80.8063
9
Selection• How to pick the parents of the next generation?
• Want to pick the more fit individuals to be parents to get the best solutions
• But, don’t want to constrain solution space too early
• Ex: Tournament Selection
(x,y, z) combatants →tournament →new parent(1, 3, 80.8063) vs. (2,−2, 27.1662) →80.8063 > 27.1662 →(1, 3, 80.8063) winner!(4, 5,−17.0481) vs. (−4,−5,−98.9519) →− 17.0481 > −98.9519 →(4, 5,−17.0481) winner!
10
Mixing/Crossover• In binary, pick cut points (randomly?) at which to cut and then
splice the binary genes together
• with variables that are not in binary, choose a new splice method:• pick a number between the two parent variables (randomly?)• include a weighting toward the parent variable with greater
fitness• include possibility of child variable outside the bounds of
parent variables
Ex: Parents: (10101010) and (01010101)One Cut Point: (10110101) and (01001010)Multiple Cuts: (11011001) and (00100110)
(x,y, z) parents →(x,y, z) children(1, 3, 80.8063) (1.5, 4, 72.3932)(4, 5,−17.0481) (2, 3.5, 82.1561)
11
Mutation• In binary: flip a digit
• set probability for mutation of an individual
• set probability for flip of each digit
• Ex:
• No binary: add or subtract a certain amount
• set probability of mutation
• set the bounds for the mutation
• how to determine the mutation amount? Random number? Weighting?
• Ex:
00010000001001
(1.5, 4, 72.3932)→ (1.7, 4, 71.7286)
12
Carry-over• You don’t want to lose your best individual!
• If the best fitness of the new population is less than the best fitness of the old population, carry over the old best
• How many to carry over?
13
End Condition• What is your fitness goal?
• How many generations?
• Convergence?
�5
0
5
�5
0
5
�200
�100
0
100
14
Convergence
15
Possible Issues• Local Maxima
• to avoid, don’t converge too quickly
• Repeated fitness evaluation can take a lot of computing power
• Tweaking required to get the parameters right for each individual problem
�5
0
5
�5
0
5
�200
�100
0
100
16
Advantages
• Adaptability to complex problems
• Can change parameters as the population evolves
• Helpful when there is a huge parameter space
17
Discussion Problem
http://xkcd.com/720/
18