Transcript
Page 1: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Genetic AlgorithmsGenetic Programming

Ata [email protected]

School of Computer ScienceUniversity of Birmingham

2003

Page 2: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

• Genetic algorithms

• Genetic programming

• Evolutionary computation

Page 3: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Evolutionary Computation

• Computation procedures patterned after biological evolution

• Search procedures that probabilistically applies search operators to a set of points in the search space

Page 4: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

The Evolutionary Cycle

Page 5: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 6: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 7: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 8: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 9: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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?

Page 10: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

• 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.

Page 11: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

GA steps in more detail

• Operators for GA– Crossover– Mutation

• Selection

Page 12: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 13: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Mutation

• After the recombination stage, just randomly alter a few genes

a B c D e F a B c D e F

Page 14: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

)(

)()(

Page 15: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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?

Page 16: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 17: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

An example: find the maximal peak of the function (difficult optimisation)

Page 18: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Solution

Page 19: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Expected behaviour of GA

Fitness

prop

orti

on

Fit

ness

Generation

generation

Page 20: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 21: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Another example of tree-structured program individual

Need to define:

Terminals: x,y,const

Primitive functions: sin, cos, , +,-, ()2

Page 22: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 23: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Mutation

Mutation pointA

B

D E

G H

C

F

I

a

b c

d

f g

e

h i

Page 24: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

An early simple example: The Block problem

Page 25: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003
Page 26: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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!

Page 27: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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}.

Page 28: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Fitness function

2121 88 mmmmsf i

Penalty Reward

(going fast)

Reward

(going straight)

Page 29: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

Results

Page 30: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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

Page 31: Genetic Algorithms Genetic Programming Ata Kaban A.Kaban@cs.bham.ac.uk School of Computer Science University of Birmingham 2003

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


Recommended