Genetic AlgorithmsGenetic Programming
School of Computer ScienceUniversity of Birmingham
2003
• Genetic algorithms
• Genetic programming
• Evolutionary computation
Evolutionary Computation
• Computation procedures patterned after biological evolution
• Search procedures that probabilistically applies search operators to a set of points in the search space
The Evolutionary Cycle
When are useful
• Hard discrete optimisation problems – when the search space is very large– E.g. choosing the NN topology
• Very hard continuous optimisation problems
• Evolutionary simulations
Genetic algorithms (inventors)
• John Holland “Adaptation in Natural and Artificial Systems”, University of Michigan Press (1975)- Genetic Algorithms
• Lawrence Fogel, M. Evans, M. Walsh “Artificial Intelligence through Simulated Evolution”, Wiley, 1966 - Evolutionary programming
• Ingo Rechenburg, 1965 - Evolutionary Strategies
Machine Learning and Genetic Algorithms
• Most Machine Learning is concerned with constructing a hypothesis from examples that generalises well – fast but very biased
• GA is a discovery-search over hypotheses– slow and unbiased
The Genetic Algorithm
1. Create a population of encoded potential solutions (chromosomes)
2. Evaluate the fitness of all the chromosomes
3. Select fitter chromosomes to form new candidate population
4. Form new candidate population by recombining genes from candidate population
5. Mutate
6. Until satisfied go to 2
Representing hypotheses as strings (‘chromosomes’)
• E.g. – Outlook{Sunny, Overcast, Rain},– Wind {Strong, Week}– PlayTennis {Yes, No}
• Represent ‘(Overcast V Rain)(Wind=Strong)’ by 011 10
• Represent‘IF Wind=Strong THEN PlayTennis=yes’ by 111 10 10 or 111 10 1Can you figure out the rationale?
• In the previous example:– Fixed length string representations for single rules
– The outcome should not be constrained (11 or 00 for PlayTennis would not make sense)
• Designing a suitable string-based representation of hypothesis is not always as simple…
• Much of the success of the GA will depend on doing this is a sensitive way.
GA steps in more detail
• Operators for GA– Crossover– Mutation
• Selection
Crossover
• Take the new candidate solutions after selection and recombine genetic material
A b c D e f a B c D e f
a B c D e F A b c D e F
A b c D e f a B c D e F
a B c D e F A b c D e f
Mutation
• After the recombination stage, just randomly alter a few genes
a B c D e F a B c D e F
Selection
• Fitness: numerical value returned by our criterion of ranking hypotheses
• Selection procedures:– Fitness proportionate selection
– Tournament selection (size 2):
1. choose two chromosomes h1 and h2 at random2. promote the fitter of the two to the next candidate
population3. until new candidate population full go to 1.
Many other possibilities! Can you figure out the rationale?
p
jj
ii
hFitness
hFitnesshP
1
)(
)()(
Selection strategy
• We want to have some way to ensure that better individuals have a better chance of being parents then less good individuals
• This will give us selection pressure which will drive the population forward.
• We have to be careful to give less good individuals at least some chance of being parents – they may include some useful genetic material
• What could go wrong with the ‘Fitness proportionate selection’ procedure?
What could go wrong with ‘Fitness proportionate selection’?
• Danger of premature convergence because outstanding individuals take over the entire population very quickly
• Low selection pressure when fitness values are near each other
An example: find the maximal peak of the function (difficult optimisation)
Solution
Expected behaviour of GA
Fitness
prop
orti
on
Fit
ness
Generation
generation
Genetic Programming
• Extension of GA for evolving computer programs (Koza 1992)
– represent programs as LISP expressions
– e.g.
(IF (GT (x) (0)) (x) (-x))
IF
GT x -x
x 0
Another example of tree-structured program individual
Need to define:
Terminals: x,y,const
Primitive functions: sin, cos, , +,-, ()2
Crossover on Trees
A
B
D E
G H
C
F
I
J
a
b c
d
f g
e
h i
i
e
h
A
B
D E
G H
C
F
I
J
a
b c
d
f g
Mutation
Mutation pointA
B
D E
G H
C
F
I
a
b c
d
f g
e
h i
An early simple example: The Block problem
The GA solution (learned program):
• Trained on 166 test problems• Using a population of 300 programs• After 10 generations• The solution found by GA which solves all 166
cases:
(EQ (DU (MT CS) (NOT CS))
(DU (MS NN) (NOT NN)))• What it does? Simple but it makes sense!
Example: Evolving programs on a mobile robot
• Goal: obstacle avoidance• inputs from eight sensors on robot {s1-s8} with values
between {0,1023} (higher values mean closer obstacle)• output to two motors (speeds) m1,m2 with values between
{0,15}.
Fitness function
2121 88 mmmmsf i
Penalty Reward
(going fast)
Reward
(going straight)
Results
Electronic Filter Circuit Design
•Individuals are programs that transform beginning circuit to final circuit by
•Adding/subtracting components and connections
•Fitness: computed by simulating the circuit
•Population of 640,000 has been run on a parallel processor
•After 137 generations, the discovered circuits exhibited performance competitive with best human designs
Summary•Evolutionary programming conducts randomised parallel search through the hypothesis space
•Approaches learning as an optimisation problem (optimise fitness)
•Evaluation of fitness can be very indirect
•Nice metaphor with Darwinian theory of biological evolution
•Little theoretical justification for many of the heuristics