non-symbolic ai lecture 3

26
Summer 2006 Non-Symbolic AI le cture 3 1 EAS y Non-Symbolic AI lecture 3 Non-Symbolic AI lecture 3 More on Evolutionary Algorithms Last lecture discussed encoding real numbers as bits on a genotype (either binary encoding or Gray coding) Sometimes people choose to have real numbers directly represented on the genotype -- which might be: 2.034 -30.678 0.005 102.567 ... ... -89.432 Recombination will work in the same way as with normal discretely

Upload: cecil

Post on 16-Jan-2016

24 views

Category:

Documents


0 download

DESCRIPTION

Non-Symbolic AI lecture 3. More on Evolutionary Algorithms Last lecture discussed encoding real numbers as bits on a genotype (either binary encoding or Gray coding) Sometimes people choose to have real numbers directly represented on the genotype -- which might be: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

1

EASy

Non-Symbolic AI lecture 3Non-Symbolic AI lecture 3Non-Symbolic AI lecture 3Non-Symbolic AI lecture 3

More on Evolutionary AlgorithmsLast lecture discussed encoding real numbers as bits on a genotype (either binary encoding or Gray coding)

Sometimes people choose to have real numbers directly represented on the genotype -- which might be: 2.034 -30.678 0.005 102.567 ... ... -89.432

Recombination will work in the same way as with normal discretely encoded genotypes, but mutations will be handled differently.

Page 2: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

2

EASy

Mutating Real numbersMutating Real numbersMutating Real numbersMutating Real numbers

Various possibilities for mutating real numbers

One possibility is to change any mutated locus to a randomly chosen real number within the appropriate range -- but this is very disruptive.

So more usually a form of 'creep mutation' is used:eg. add a random number in range [-0.1 +0.1]or add a random number drawn from a Gaussian distribution with mean zero, and appropriate range.

Page 3: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

3

EASy

Evolution StrategiesEvolution StrategiesEvolution StrategiesEvolution Strategies

If the problem you are tackling has all the parametersnaturally expressed as real numbers, then maybe youshould investigate Evolution Strategies (see previous lecture)

These work primarily with a version of 'creep mutation',and this evolutionary paradigm has developedsophisticated strategies for modifying the amounts of'creep' in different dimensions as evolution proceeds.

Page 4: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

4

EASy

Different Search AlgorithmsDifferent Search AlgorithmsDifferent Search AlgorithmsDifferent Search Algorithms

Or indeed you could look at Simulated Annealing-- a non-evolutionary technique which nevertheless has some similarities.

These are all techniques for Search within amany-dimensional, real-valued Search Space.

Genetic Algorithms may be more appropriate for Search within high-dimensional Discrete Search Spaces.

Many design problems are such – but many are not.

Page 5: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

5

EASy

Why Should GAs work ?Why Should GAs work ?Why Should GAs work ?Why Should GAs work ?

John Holland (1975) 'Adaptation in Natural and Artificial Systems' -- and most of the textbooks -- explain this with the Schema Theorem, and ideas of building blocks.

Roughly speaking, building blocks are segments of the genotype which encode for functional components of the 'phenotype', or potential solution to the problem.

These building blocks can, in principle, be evaluated independently of all the rest, as varying between 'good' and 'bad'.

Page 6: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

6

EASy

Cartoon VersionCartoon VersionCartoon VersionCartoon Version

Cartoon version of genotypes:

*** long legs *****************short arms**********

***short legs***************** long arms ********** ^Recombination (when crossover happens to land appropriately) allows different parents like these in one generation to produce a child with long legs and long arms

Page 7: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

7

EASy

SchemataSchemataSchemataSchemata

Schemata (plural of schema) are a formalisation of this idea of a building block.

Consider binary genotypes of length 16. Let # be a 'wild-card' or 'dont-care' character.

Then #####00#010#####

is a schema of order 5 (5 specified alleles) andof defining length 6 (length of segment which includesspecified alleles).

Page 8: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

8

EASy

‘‘Processing Schemata’Processing Schemata’‘‘Processing Schemata’Processing Schemata’

Considering this schema #####00#010##### then0000000001010000is just one of many genotypes corresponding to this schema -- and actually this genotype also corresponds simultaneously to many other schemata.

Implicitly, the GA 'evaluates' and 'processes' loadsof schemata in parallel, every generation.

Page 9: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

9

EASy

The Schema Theorem claims …The Schema Theorem claims …The Schema Theorem claims …The Schema Theorem claims …

... that schemata of short defining lengths (coding for building blocks such as 'cartoon legs') will, IF they are of above-average fitness, (..that is, evaluated whatever the other loci outside the schema are)get exponentially increasing numbers of trials in successive generations.

Ie, despite recombination and mutation being 'disruptive'(tho not too disruptive of short schemata)'good building blocks' will multiply and take over ---and 'mix and match' with other 'good building blocks'.

Page 10: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

10

EASy

Implications of the Schema Theorem ??Implications of the Schema Theorem ??Implications of the Schema Theorem ??Implications of the Schema Theorem ??

The Schema Theorem is formally proved subject to certain conditions.

This Theorem is widely interpreted as implying that RECOMBINATION is the 'powerhouse' of GAs,

-- whereas mutation is just a 'background operator‘ (whose only role is to add variety in loci where, throughout the whole population, no variety is left).

Page 11: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

11

EASy

Doubts about the Schema TheoremDoubts about the Schema TheoremDoubts about the Schema TheoremDoubts about the Schema Theorem

The Schema Theorem is formally correct.

But nowadays many people (including myself) believe it has been misinterpreted.

The 'subject to certain conditions' bit means that this exponential increase is only guaranteed over 1 generation

-- thereafter the conditions change!

Page 12: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

12

EASy

Recombination versus Mutation ?Recombination versus Mutation ?Recombination versus Mutation ?Recombination versus Mutation ?

So be aware that despite this common view in the textbooks, some people think that in some sense MUTATION is the powerhouse of GAs, with recombination as a background (tho often useful) genetic operator.

"The Schema Theorem is true, but not very significant"

Nevertheless, the common view of the importance of recombination lies behind the exclusive emphasis (often without any mutation) on recombination inGP = Genetic Programming.

Page 13: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

13

EASy

Some more GA wrinklesSome more GA wrinklesSome more GA wrinklesSome more GA wrinkles

You need not have a generational GA(where the whole population is swept aside every generation, and replaced by a fresh lot of offspring).

You can have a STEADY STATE GA.

Here just ONE member of the population is replaced at each time step, by the offspring of some others.

Page 14: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

14

EASy

Steady State GASteady State GASteady State GASteady State GA

Eg with a popn of 100:Choose a mum by some selection mechanism biased towards the fitter.Choose a dad by same method.Generate a child by recombination + mutationAdd the child to the populationKeep the numbers down to 100 by choosing someone else to die (eg at random, or biased towards the less fit)Roughly speaking, 100 times round this loop is equivalent to one generation of a generational GA

Page 15: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

15

EASy

Tournament SelectionTournament SelectionTournament SelectionTournament Selection

Here is a very simple way to implement the equivalent of linear rank selection in a Steady State GA

Pick 2 at random3.5 compare fitnesses

2.7

Fittest of tournament is mum – choose dad the same way

Generate offspring from mum and dad – the new offspring replaces someone chosen at random.Note: everyone else remains, including mum and dad.Repeat until happy!

Page 16: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

16

EASy

You needn’t even have death !You needn’t even have death !You needn’t even have death !You needn’t even have death !

microbes can evolve by horizontal transmissionof genes (within the same generation)rather than (or as well as) vertical transmission(down the generations, from parents to offspring).

ie recombination happens within generations

Microbial sex = 'hey, wanna swap some of my genes for yours?'rather than'lets make babies'

Page 17: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

17

EASy

Microbial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the picture

Page 18: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

18

EASy

Microbial Genetic Algorithm – the algorithmMicrobial Genetic Algorithm – the algorithmMicrobial Genetic Algorithm – the algorithmMicrobial Genetic Algorithm – the algorithm

Pick two genotypes at randomCompare scores -> Winner and LoserGo along genotype, at each locus–with some prob copy from Winner to Loser (overwrite)–with some prob mutate that locus of the Loser

So ONLY the Loser gets changed (gives a version of Elitism for free!)

This allows what is technically a one-liner GA (bar the evaluate(), which is problem-specific) -- quite a long line !

Page 19: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

19

EASy

Microbial Genetic Algorithm – the one-linerMicrobial Genetic Algorithm – the one-linerMicrobial Genetic Algorithm – the one-linerMicrobial Genetic Algorithm – the one-liner

/* tournament loop */for (t=0;t<END;t++) /* loop along genotype of winner of tournament, selected in initial loop conditions */ for (W=(evaluate(a=POP*drand48())> evaluate(b=POP*drand48()) ? a : b), L=(W==a ? b : a), i=0; i<LEN; i++) /* throw dice to decide: cross or mutate */ if ((r=drand48())<REC+MUT) /* update genotype of loser */

gene[L][i]=(r<REC ? gene[W][i] : gene[L][i]^1);

Page 20: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

20

EASy

… … or slightly longeror slightly longer… … or slightly longeror slightly longer

int gene[POP][LEN];

Initialise genes at random; define problem-specific evaluate(n)

/* tournament loop */for (t=0;t<END;t++) { /* pick 2 at random, find Winner and Loser */ a=POP*drand48();

do {b=POP*drand48()} while (a==b); /*make sure a and b different */

if (evaluate(a) > evaluate(b)) {W=a; L=b;}else {W=b; L=a;}

To be continued …

Page 21: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

21

EASy

… … continuedcontinued… … continuedcontinued

Continued …

for (i=0;i<LEN;i++) {

if (drand48()<REC) /* cross with probability REC */

gene[L][i]=gene[W][i];

if (drand48()<MUT) /* mutate with probability MUT */

gene[L][i]=1-gene[L][i]; /* flip bit */

} /* end tournament loop */

Possible values for REC=0.5; ? And MUT=1.0/LEN; ?

Page 22: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

22

EASy

Microbial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the pictureMicrobial Genetic Algorithm – the picture

Page 23: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

23

EASy

Is there a point ?Is there a point ?Is there a point ?Is there a point ?

Microbial GA paper via my home pagehttp://www.informatics.susx.ac.uk/users/inmanh

It does actually work.

By no means guaranteed to be better than other GAs -- but does show how really simple a GA can be, and still work !

Apart from the one line, it needs declaration of gene[POP][LEN], initialisation of a random popn, and evaluate(n) that returns fitness of nth member.

Page 24: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

24

EASy

Embodied EvolutionEmbodied EvolutionEmbodied EvolutionEmbodied Evolution

Richard Watson, at Brandeis (papers available on web) has modified this to use with real robots in'Embodied Evolution'.

Robots go around 'broadcasting' their genes, and listening out to other broadcasts.

Fitter robots 'shout louder' (or more often)

Weaker robots are more likely to listen in, and use the genes they 'hear' to copy over their own.

Page 25: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

25

EASy

A mini-GA project – for Seminars week 3A mini-GA project – for Seminars week 3A mini-GA project – for Seminars week 3A mini-GA project – for Seminars week 3

You have 10 cards numbered 1 to 10.

You have to divide them into 2 piles so that:

1) The sum of the first pile is as close as possible to 36

2) And the product of all in second pile is as close as poss to 360

Hint: call the piles ‘0’ and ‘’1’, and use binary genotypes of length 10 to encode any possible solution.

Think of a suitable fitness function.

Page 26: Non-Symbolic AI lecture 3

Summer 2006Non-Symbolic AI lecture 3

26

EASy

Any questions so far … ?Any questions so far … ?Any questions so far … ?Any questions so far … ?

… with luck there should be time left for GA-related questions.