lecture 10 evolutionary computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · lecture 10...

34
Lecture 10 Lecture 10 Evolutionary Computation: Evolutionary Computation: Evolution strategies and genetic programming Evolution strategies and genetic programming Evolution strategies Evolution strategies Evolution strategies Evolution strategies Genetic programming Genetic programming Summary Summary 11/14/2010 Intelligent Systems and Soft Computing 1

Upload: others

Post on 22-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Lecture 10Lecture 10

Evolutionary Computation: Evolutionary Computation: Evolution strategies and genetic programmingEvolution strategies and genetic programming

Evolution strategiesEvolution strategiesEvolution strategies Evolution strategies

Genetic programmingGenetic programmingp g gp g g

SummarySummary

11/14/2010 Intelligent Systems and Soft Computing 1

Page 2: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Evolution StrategiesEvolution StrategiesAnother approach to simulating natural Another approach to simulating natural

l ti d i G i th ll ti d i G i th l

gg

evolution was proposed in Germany in the early evolution was proposed in Germany in the early 1960s. Unlike genetic algorithms, this approach 1960s. Unlike genetic algorithms, this approach

called ancalled an evolution strategyevolution strategy was designedwas designed called an called an evolution strategy evolution strategy was designed was designed to solve technical optimisation problems.to solve technical optimisation problems.

11/14/2010 Intelligent Systems and Soft Computing 2

Page 3: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

In 1963 two students of the Technical In 1963 two students of the Technical University of Berlin, University of Berlin, Ingo Rechenberg Ingo Rechenberg and and HansHans--Paul SchwefelPaul Schwefel, were working on the , were working on the search for the optimal shapes of bodies in a search for the optimal shapes of bodies in a flow. They decided to try random changes in flow. They decided to try random changes in the parameters defining the shape following the the parameters defining the shape following the example of natural mutation. As a result, the example of natural mutation. As a result, the

l ti t t bl ti t t bevolution strategy was born.evolution strategy was born. Evolution strategies were developed as an Evolution strategies were developed as an

alternative to the engineer’s intuition. alternative to the engineer’s intuition. Unlike GAs, evolution strategies use only a Unlike GAs, evolution strategies use only a

11/14/2010 Intelligent Systems and Soft Computing 3

mutation operator.mutation operator.

Page 4: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Basic evolution strategiesBasic evolution strategiesIn its simplest form, termed as a (1In its simplest form, termed as a (11)1)--evolution evolution strategy, one parent generates one offspring per strategy, one parent generates one offspring per generation by applying generation by applying normally distributed normally distributed mutation. The (1mutation. The (11)1)--evolution strategy can be evolution strategy can be i l t d f lli l t d f llimplemented as follows:implemented as follows:

Step 1Step 1: : Choose the number of parameters Choose the number of parameters N N to to h bl d h d i f iblh bl d h d i f iblrepresent the problem, and then determine a feasible represent the problem, and then determine a feasible

range for each parameter:range for each parameter:

Define a standard deviation for each parameter and Define a standard deviation for each parameter and

xx 1max1min, , xx 2max2min, , . . . , NmaxNmin xx ,

11/14/2010 Intelligent Systems and Soft Computing 4

e e a sta da d dev at o o eac pa a ete a de e a sta da d dev at o o eac pa a ete a dthe function to be optimised.the function to be optimised.

Page 5: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 2Step 2: : Randomly select an initial value for each Randomly select an initial value for each parameter from the respective feasible range. The parameter from the respective feasible range. The set of these parameters will constitute the initial set of these parameters will constitute the initial

l i fl i fpopulation of parent parameters:population of parent parameters:xx11, , xx22, . . . , , . . . , xxNN

Step 3Step 3: : Calculate the solution associated with the Calculate the solution associated with the parent parameters:parent parameters:

X = f X = f ((xx11, , xx22, . . . , , . . . , xxNN))

11/14/2010 Intelligent Systems and Soft Computing 5

Page 6: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 4Step 4: : Create a new (offspring) parameter by Create a new (offspring) parameter by adding a normally distributed random variable adding a normally distributed random variable a a with mean zero and prewith mean zero and pre--selected deviation selected deviation to each to each parent parameter:parent parameter:

i i = 1, 2, . . . , = 1, 2, . . . , NN,0axx ii

Normally distributed mutations with mean zero Normally distributed mutations with mean zero reflect the natural process of evolution (smaller reflect the natural process of evolution (smaller p (p (changes occur more frequently than larger ones).changes occur more frequently than larger ones).

Step 5Step 5:: Calculate the solution associated with theCalculate the solution associated with theStep 5Step 5: : Calculate the solution associated with the Calculate the solution associated with the offspring parameters:offspring parameters:

11/14/2010 Intelligent Systems and Soft Computing 6

NxxxfX ,...,, 21

Page 7: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 6Step 6: : Compare the solution associated with the Compare the solution associated with the offspring parameters with the one associated with offspring parameters with the one associated with the parent parameters. If the solution for the the parent parameters. If the solution for the ff i i b h h f h lff i i b h h f h loffspring is better than that for the parents, replace offspring is better than that for the parents, replace

the parent population with the offspring the parent population with the offspring population Otherwise keep the parentpopulation Otherwise keep the parentpopulation. Otherwise, keep the parent population. Otherwise, keep the parent parameters.parameters.

Step 7Step 7: : Go to Step 4, and repeat the process until a Go to Step 4, and repeat the process until a ti f t l ti i h d ifi dti f t l ti i h d ifi dsatisfactory solution is reached, or a specified satisfactory solution is reached, or a specified

number of generations is considered.number of generations is considered.

11/14/2010 Intelligent Systems and Soft Computing 7

Page 8: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

An evolution strategy reflects the nature of a An evolution strategy reflects the nature of a chromosome.chromosome.

A single gene may simultaneously affect several A single gene may simultaneously affect several g g y yg g y ycharacteristics of the living organism.characteristics of the living organism.

On the other hand, a single characteristic of an On the other hand, a single characteristic of an , g, gindividual may be determined by the simultaneous individual may be determined by the simultaneous interactions of several genes.interactions of several genes.

The natural selection acts on a collection of genes, The natural selection acts on a collection of genes, not on a single gene in isolation.not on a single gene in isolation.g gg g

11/14/2010 Intelligent Systems and Soft Computing 8

Page 9: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Genetic programmingGenetic programming One of the central problems in computer science is One of the central problems in computer science is

how to make computers solve problems without how to make computers solve problems without being explicitly programmed to do so.being explicitly programmed to do so.

Genetic programming offers a solution through the Genetic programming offers a solution through the evolution of computer programs by methods of evolution of computer programs by methods of natural selectionnatural selection..

In fact, genetic programming is an extension of the In fact, genetic programming is an extension of the conventional genetic algorithm, but the goal of conventional genetic algorithm, but the goal of genetic programming is not just to evolve a bitgenetic programming is not just to evolve a bit--string representation of some problem but the string representation of some problem but the

t d th t l th blt d th t l th bl

11/14/2010 Intelligent Systems and Soft Computing 9

computer code that solves the problem.computer code that solves the problem.

Page 10: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Genetic programming is a recent development in Genetic programming is a recent development in the area of evolutionary computation. It was the area of evolutionary computation. It was greatly stimulated in the 1990s by greatly stimulated in the 1990s by John KozaJohn Koza..

According to Koza, genetic programming searches According to Koza, genetic programming searches the space of possible computer programs for a the space of possible computer programs for a program that is highly fit for solving the problem at program that is highly fit for solving the problem at hand.hand.

Any computer program is a sequence of operations Any computer program is a sequence of operations (functions) applied to values (arguments), but (functions) applied to values (arguments), but different programming languages may include different programming languages may include different types of statements and operations, and different types of statements and operations, and h diff i i ih diff i i i

11/14/2010 Intelligent Systems and Soft Computing 10

have different syntactic restrictions.have different syntactic restrictions.

Page 11: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Since genetic programming manipulates programs Since genetic programming manipulates programs by applying genetic operators, a programming by applying genetic operators, a programming language should permit a computer program to be language should permit a computer program to be manipulated as data and the newly created data to manipulated as data and the newly created data to be executed as a program. For these reasons, be executed as a program. For these reasons, LISPLISP h h i l fh h i l fLISP LISP was chosen as the main language for was chosen as the main language for genetic programming.genetic programming.

11/14/2010 Intelligent Systems and Soft Computing 11

Page 12: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

LISP structureLISP structureLISP has a highly symbolLISP has a highly symbol--oriented structure. Its oriented structure. Its b i d t t tb i d t t t tt dd li tli t A tA tbasic data structures are basic data structures are atoms atoms and and listslists. An atom . An atom is the smallest indivisible element of the LISP is the smallest indivisible element of the LISP syntax The numbersyntax The number 2121 the symbolthe symbol XX and the stringand the stringsyntax. The number syntax. The number 2121, the symbol , the symbol X X and the string and the string “This is a string” “This is a string” are examples of LISP atoms. A are examples of LISP atoms. A list is an object composed of atoms and/or otherlist is an object composed of atoms and/or otherlist is an object composed of atoms and/or other list is an object composed of atoms and/or other lists. LISP lists are written as an ordered collection lists. LISP lists are written as an ordered collection of items inside a pair of parentheses.of items inside a pair of parentheses.o te s s de a pa o pa e t eses.o te s s de a pa o pa e t eses.

11/14/2010 Intelligent Systems and Soft Computing 12

Page 13: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

For example the listFor example the listLISP structureLISP structure

For example, the list For example, the list

(( ((** A B) C)A B) C)

calls for the application of the subtraction function calls for the application of the subtraction function (() to two arguments, namely the list (*A B) and) to two arguments, namely the list (*A B) and(( ) to two arguments, namely the list ( A B) and ) to two arguments, namely the list ( A B) and the atom C. First, LISP applies the multiplication the atom C. First, LISP applies the multiplication function (*) to the atoms A and Bfunction (*) to the atoms A and Bfunction ( ) to the atoms A and B.function ( ) to the atoms A and B.

Once the list (*A B) is evaluated, LISP applies the Once the list (*A B) is evaluated, LISP applies the b i f i (b i f i ( ) h d) h dsubtraction function (subtraction function () to the two arguments, and ) to the two arguments, and

thus evaluates the entire list thus evaluates the entire list

11/14/2010 Intelligent Systems and Soft Computing 13

(( ((** A B) C).A B) C).

Page 14: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Graphical representation of LISP SGraphical representation of LISP S--expressionsexpressions

Both atoms and lists are called symbolic Both atoms and lists are called symbolic expressions orexpressions or SS--expressionsexpressions In LISP all dataIn LISP all dataexpressions or expressions or SS expressionsexpressions. In LISP, all data . In LISP, all data and all programs are Sand all programs are S--expressions. This gives expressions. This gives LISP the ability to operate on programs as if they LISP the ability to operate on programs as if they y p p g yy p p g ywere data. In other words, LISP programs can were data. In other words, LISP programs can modify themselves or even write other LISP modify themselves or even write other LISP programs. This remarkable property of LISP programs. This remarkable property of LISP makes it very attractive for genetic programming.makes it very attractive for genetic programming.

Any LISP SAny LISP S--expression can be depicted as a rooted expression can be depicted as a rooted pointpoint--labeled tree with ordered branches.labeled tree with ordered branches.

11/14/2010 Intelligent Systems and Soft Computing 14

Page 15: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

LISP SLISP S--expression (expression ( (*A B) C)(*A B) C)

* C

BA

11/14/2010 Intelligent Systems and Soft Computing 15

Page 16: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

How do we apply genetic programming How do we apply genetic programming pp y g p g gpp y g p g gto a problem?to a problem?B f l i ti i t blB f l i ti i t blBefore applying genetic programming to a problem, Before applying genetic programming to a problem, we must accomplish we must accomplish five preparatory stepsfive preparatory steps::

1. Determine the set of terminals. 1. Determine the set of terminals. 2. Select the set of primitive functions. 2. Select the set of primitive functions. 3. Define the fitness function. 3. Define the fitness function. 4. Decide on the parameters for controlling the run.4. Decide on the parameters for controlling the run.4. Decide on the parameters for controlling the run. 4. Decide on the parameters for controlling the run. 5. Choose the method for designating a result of 5. Choose the method for designating a result of

the runthe run

11/14/2010 Intelligent Systems and Soft Computing 16

the run.the run.

Page 17: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

The Pythagorean Theorem helps us to illustrate The Pythagorean Theorem helps us to illustrate y g py g pthese preparatory steps and demonstrate the these preparatory steps and demonstrate the potential of genetic programming. The theorem potential of genetic programming. The theorem says that the hypotenuse, says that the hypotenuse, cc, of a right triangle with , of a right triangle with short sides short sides a a and and b b is given byis given by

22 bac

The aim of genetic programming is to discover a The aim of genetic programming is to discover a program that matches this function.program that matches this function.p og a t at atc es t s u ct o .p og a t at atc es t s u ct o .

11/14/2010 Intelligent Systems and Soft Computing 17

Page 18: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

To measure the performance of the asTo measure the performance of the as--yetyet--pp yyundiscovered computer program, we will use a undiscovered computer program, we will use a number of different number of different fitness casesfitness cases. The fitness . The fitness cases for the Pythagorean Theorem are cases for the Pythagorean Theorem are represented by the samples of right triangles in represented by the samples of right triangles in Table. These fitness cases are chosen at random Table. These fitness cases are chosen at random over a range of values of variables over a range of values of variables aa and and bb..

Sidea Sideb Hypotenusec Sidea Sideb Hypotenusec3 5 5.830952 12 10 15.62049981 4 16124515 21 6 21 84033081 4 16.124515 21 6 21.840330

18 2 18.110770 7 4 8.06225832 11 33.837849 16 24 28.8444104 3 5 000000 2 9 9 219545

11/14/2010 Intelligent Systems and Soft Computing 18

4 3 5.000000 2 9 9.219545

Page 19: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 1Step 1: : Determine the set of terminals. Determine the set of terminals. The terminals correspond to the inputs of the The terminals correspond to the inputs of the computer program to be discovered. Our computer program to be discovered. Our

k ik i dd bbprogram takes two inputs, program takes two inputs, a a and and bb..

Step 2Step 2:: SelectSelect the set of primitive functions.the set of primitive functions.Step 2Step 2: : SelectSelect the set of primitive functions. the set of primitive functions. The functions can be presented by standard The functions can be presented by standard arithmetic operations, standard programming arithmetic operations, standard programming p , p g gp , p g goperations, standard mathematical functions, operations, standard mathematical functions, logical functions or domainlogical functions or domain--specific functions. specific functions. Our program will use four standard arithmetic Our program will use four standard arithmetic operations +, operations +, , * and , * and , and one mathematical , and one mathematical

11/14/2010 Intelligent Systems and Soft Computing 19

function function sqrtsqrt..

Page 20: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 3Step 3: : Define the fitness function. Define the fitness function. A fitness A fitness function evaluates how well a particular computer function evaluates how well a particular computer program can solve the problem. For our problem, program can solve the problem. For our problem, h fi f h bh fi f h bthe fitness of the computer program can be the fitness of the computer program can be

measured by the error between the actual result measured by the error between the actual result d d b th d th t ltd d b th d th t ltproduced by the program and the correct result produced by the program and the correct result

given by the fitness case. Typically, the error is given by the fitness case. Typically, the error is not measured over just one fitness case butnot measured over just one fitness case butnot measured over just one fitness case, but not measured over just one fitness case, but instead calculated as a sum of the absolute errors instead calculated as a sum of the absolute errors over a number of fitness cases The closer thisover a number of fitness cases The closer thisover a number of fitness cases. The closer this over a number of fitness cases. The closer this sum is to zero, the better the computer program.sum is to zero, the better the computer program.

11/14/2010 Intelligent Systems and Soft Computing 20

Page 21: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 4Step 4: : Decide on the parameters for controlling Decide on the parameters for controlling the run. the run. For controlling a run, genetic For controlling a run, genetic programming uses the same primary parameters programming uses the same primary parameters

h d f GA Th i l d hh d f GA Th i l d has those used for GAs. They include the as those used for GAs. They include the population size and the maximum number of population size and the maximum number of

ti t bti t bgenerations to be run.generations to be run.

Step 5Step 5:: Choose the method for designating aChoose the method for designating aStep 5Step 5: : Choose the method for designating a Choose the method for designating a result of the run. result of the run. It is common practice in It is common practice in genetic programming to designate the bestgenetic programming to designate the best--soso--far far g p g g gg p g g ggenerated program as the result of a run.generated program as the result of a run.

11/14/2010 Intelligent Systems and Soft Computing 21

Page 22: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Once these five steps are complete, a run can be Once these five steps are complete, a run can be p pp pmade. The run of genetic programming starts with made. The run of genetic programming starts with a random generation of an initial population of a random generation of an initial population of computer programs. Each program is composed of computer programs. Each program is composed of functions +, functions +, , , *, and and sqrtsqrt, and terminals , and terminals a a and and bb..

In the initial population, all computer programs In the initial population, all computer programs ll h fit b t i di id lll h fit b t i di id lusually have poor fitness, but some individuals are usually have poor fitness, but some individuals are

more fit than others. Just as a fitter chromosome is more fit than others. Just as a fitter chromosome is more likely to be selected for reproduction so amore likely to be selected for reproduction so amore likely to be selected for reproduction, so a more likely to be selected for reproduction, so a fitter computer program is more likely to survive by fitter computer program is more likely to survive by copying itself into the next generationcopying itself into the next generation

11/14/2010 Intelligent Systems and Soft Computing 22

copying itself into the next generation.copying itself into the next generation.

Page 23: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Crossover in genetic programming:Crossover in genetic programming:T l ST l S iiTwo parental STwo parental S--expressionsexpressions

* sqrt

a bsqrt a bsqrt

*

ba

a*

a

*

a a b b

a*

b

11/14/2010 Intelligent Systems and Soft Computing 23

( ( (sqr t ( (* a a) ( a b ))) a ) (* a b)) ( ( (sqrt ( (* bb) a)) b ) (sqrt ( a b)))

Page 24: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Crossover in genetic programming:Crossover in genetic programming:T ff i ST ff i S iiTwo offspring STwo offspring S--expressionsexpressions

sqrtsqrt

sqrt a b*

*

baa b

b

a*

b

a

*

a a b

b b

11/14/2010 Intelligent Systems and Soft Computing 24

( ( (sqrt ( (* a a ) ( a b))) a) (sqr t ( (* bb) a))) ( ((* a b ) b) (sqrt ( a b)))

Page 25: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Mutation in genetic programmingMutation in genetic programmingA mutation operator can randomly change any A mutation operator can randomly change any function or any terminal in the LISP Sfunction or any terminal in the LISP S expressionexpression

g p g gg p g g

function or any terminal in the LISP Sfunction or any terminal in the LISP S--expression. expression. Under mutation, a function can only be replaced by Under mutation, a function can only be replaced by a function and a terminal can only be replaced by aa function and a terminal can only be replaced by aa function and a terminal can only be replaced by a a function and a terminal can only be replaced by a terminal.terminal.

11/14/2010 Intelligent Systems and Soft Computing 25

Page 26: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Mutation in genetic programming:Mutation in genetic programming:Original SOriginal S--expressionsexpressions

* sqrt

a bsqrt a sqrt b

*

ba

a*

a

*

a a b

b

a*

b

11/14/2010 Intelligent Systems and Soft Computing 26

( ( (sqrt ( (* aa ) ( ab ))) a) (* ab )) ( ( (sqrt ( (* bb ) a)) b) (sqrt ( ab )))

Page 27: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Mutation in genetic programming:Mutation in genetic programming:Mutated SMutated S--expressionsexpressions

* sqrt

a bsqrt a sqrt a

*

ba

a*

a

*

a a b

b

a*

b

11/14/2010 Intelligent Systems and Soft Computing 27

( ( (sqrt ( (* a a) ( a b))) a) (* a b)) ( ( (sqrt ( (* b b) a)) a) (sqrt ( a b)))

Page 28: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

In summary, genetic programming creates computer In summary, genetic programming creates computer

Step 1Step 1:: Assign the maximum number of generationsAssign the maximum number of generations

programs by executing the following steps:programs by executing the following steps:

Step 1Step 1: : Assign the maximum number of generations Assign the maximum number of generations to be run and probabilities for cloning, crossover to be run and probabilities for cloning, crossover and mutation. Note that the sum of the probabilityand mutation. Note that the sum of the probabilityand mutation. Note that the sum of the probability and mutation. Note that the sum of the probability of cloning, the probability of crossover and the of cloning, the probability of crossover and the probability of mutation must be equal to one.probability of mutation must be equal to one.p y qp y q

Step 2Step 2: : GGenerate an initial population of computer enerate an initial population of computer f if i NN b bi i d lb bi i d lprograms of size programs of size N N by combining randomly by combining randomly

selected functions and terminals. selected functions and terminals.

11/14/2010 Intelligent Systems and Soft Computing 28

Page 29: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 3Step 3: : Execute each computer program in the Execute each computer program in the population and calculate its fitness with an population and calculate its fitness with an appropriate fitness function. Designate the bestappropriate fitness function. Designate the best--

f i di id l h l f hf i di id l h l f hsoso--far individual as the result of the run.far individual as the result of the run.

Step 4Step 4:: With the assigned probabilities select aWith the assigned probabilities select aStep 4Step 4: : With the assigned probabilities, select a With the assigned probabilities, select a genetic operator to perform cloning, crossover or genetic operator to perform cloning, crossover or mutation.mutation.mutation.mutation.

11/14/2010 Intelligent Systems and Soft Computing 29

Page 30: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 5Step 5: : If the cloning operator is chosen, select one If the cloning operator is chosen, select one computer program from the current population of computer program from the current population of programs and copy it into a new population.programs and copy it into a new population.

If the crossover operator is chosen, select a pair If the crossover operator is chosen, select a pair of computer programs from the currentof computer programs from the currentof computer programs from the current of computer programs from the current population, create a pair of offspring programs population, create a pair of offspring programs and place them into the new population.and place them into the new population.p p pp p p

If the mutation operator is chosen, select one If the mutation operator is chosen, select one t f th t l tit f th t l ticomputer program from the current population, computer program from the current population,

perform mutation and place the mutant into the perform mutation and place the mutant into the new populationnew population

11/14/2010 Intelligent Systems and Soft Computing 30

new population.new population.

Page 31: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Step 6Step 6: : Repeat Repeat Step 4 Step 4 until the size of the new until the size of the new population of computer programs becomes equal population of computer programs becomes equal to the size of the initial population, to the size of the initial population, NN..

Step 7Step 7: : Replace the current (parent) population Replace the current (parent) population with the new (offspring) populationwith the new (offspring) populationwith the new (offspring) population.with the new (offspring) population.

Step 8Step 8: : Go to Go to Step 3 Step 3 and repeat the process until and repeat the process until the termination criterion is satisfied.the termination criterion is satisfied.

11/14/2010 Intelligent Systems and Soft Computing 31

Page 32: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

Fitness history of the best SFitness history of the best S--expressionexpressionyy pp

100

80sqrt

40

60

* *

20

a

*

a b

*

b0 1 2 40

G e n e r a t i o n s B e s t o f g e n e r a t i o n3

11/14/2010 Intelligent Systems and Soft Computing 32

Page 33: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

What are the main advantages of genetic What are the main advantages of genetic programming compared to genetic algorithms?programming compared to genetic algorithms? Genetic programming applies the same Genetic programming applies the same

l ti h H til ti h H ti

programming compared to genetic algorithms? programming compared to genetic algorithms?

evolutionary approach. However, genetic evolutionary approach. However, genetic programming is no longer breeding bit strings that programming is no longer breeding bit strings that represent coded solutions but complete computerrepresent coded solutions but complete computerrepresent coded solutions but complete computer represent coded solutions but complete computer programs that solve a particular problemprograms that solve a particular problem..

The fundamental difficulty ofThe fundamental difficulty of GAs lies in theGAs lies in the The fundamental difficulty of The fundamental difficulty of GAs lies in the GAs lies in the problem representation, that is, in the fixedproblem representation, that is, in the fixed--length length coding A poor representation limits the power ofcoding A poor representation limits the power ofcoding. A poor representation limits the power of coding. A poor representation limits the power of a GA, and even worse, may lead to a false a GA, and even worse, may lead to a false solutionsolution

11/14/2010 Intelligent Systems and Soft Computing 33

solution.solution.

Page 34: Lecture 10 Evolutionary Computationrahimi/cs437/slides/lec10.pdf · 2010. 11. 14. · Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming ... 3 5 5.830952

A fixedA fixed--length coding is rather artificial. As it length coding is rather artificial. As it g gg gcannot provide a dynamic variability in length, cannot provide a dynamic variability in length, such a coding often causes considerable such a coding often causes considerable redundancy and reduces the efficiency of genetic redundancy and reduces the efficiency of genetic search. In contrast, genetic programming uses search. In contrast, genetic programming uses highhigh--level building blocks of variable length. level building blocks of variable length. Their size and complexity can change during Their size and complexity can change during b dib dibreeding.breeding.

Genetic programming works well in a large Genetic programming works well in a large b di d h i lb di d h i lnumber of different cases and has many potential number of different cases and has many potential

applications.applications.

11/14/2010 Intelligent Systems and Soft Computing 34