Genetic Programming
Genetic Programming
Genetic Algorithms
Advisor: Jonatan G
omez Perdomo, Ph.D.
[email protected]
Grupo de investigaci
on en vida artificial Research Group on Artificial Life (Alife)
Departamento de Ingeniera de Sistemas e Industrial
Facultad de Ingeniera
Universidad Nacional de Colombia
2nd Semester 2014
E. C. Cubides & J. G
omez (UN)
1 / 30
Outline
Contextualization
Evolutionary Algorithm
Genetic Programming
Representation of programs
Generation of initial populations
Selection strategy
Generation of offspring
Replacement strategy
Advantages and disadvantages
E. C. Cubides & J. G
omez (UN)
2 / 30
Contextualization
Outline
Contextualization
Evolutionary Algorithm
Genetic Programming
Representation of programs
Generation of initial populations
Selection strategy
Generation of offspring
Replacement strategy
Advantages and disadvantages
E. C. Cubides & J. G
omez (UN)
3 / 30
Contextualization
Soft Computing
SP = ANN + FL + EC
Soft
Artificial
Fuzzy
Evolutionary
Computing
Neural
Logic
Computation
Networks
E. C. Cubides & J. G
omez (UN)
4 / 30
Evolutionary Algorithm
Outline
Contextualization
Evolutionary Algorithm
Genetic Programming
Representation of programs
Generation of initial populations
Selection strategy
Generation of offspring
Replacement strategy
Advantages and disadvantages
E. C. Cubides & J. G
omez (UN)
5 / 30
Evolutionary Algorithm
E. C. Cubides & J. G
omez (UN)
6 / 30
Evolutionary Algorithm
Evolutionary Computation
EC = GA + ES + EP
Evolutionary
Genetic
Computation
Evolutionary
Evolutionary
Algorithms
Strategies
Programming
(Holland, 75)
(Rechenberger, 73)
(Fogel, Owens,
Walsh, 66)
GP
Genetic
Programming
(Jhon Koza, 1989)
E. C. Cubides & J. G
omez (UN)
7 / 30
Genetic Programming
Outline
Contextualization
Evolutionary Algorithm
Genetic Programming
Representation of programs
Generation of initial populations
Selection strategy
Generation of offspring
Replacement strategy
Advantages and disadvantages
E. C. Cubides & J. G
omez (UN)
8 / 30
Genetic Programming
Definition I
Definition
Genetic Programming (GP) is a branch of Genetic Algorithms, in which
individuals (chromosomes) of population are computer programs
(Koza, 92, Koza, 94, Koza, 99, Koza, 03) [1, 2, 3, 4].
E. C. Cubides & J. G
omez (UN)
9 / 30
Genetic Programming
John Koza
E. C. Cubides & J. G
omez (UN)
10 / 30
Genetic Programming
Differences
The main difference between GP and traditional GA is the representation
of the solution. GP creates computer programs in some particular
programming language to represent a solution, whereas genetic algorithms
create a string of numbers that represent the solution
Example
GA: 1001101100111000
E. C. Cubides & J. G
omez (UN)
11 / 30
Genetic Programming
Goal
The goal of the GP is to find a program that solves a problem such that
its analytic solution is very complicated to find.
Fitness
The fitness of a valid individual is generally obtained by the performance
and the behavior of it over a training data sets.
E. C. Cubides & J. G
omez (UN)
12 / 30
Genetic Programming
, ....
Terminals: a, b, c, . . . , 2, 1, 4, . . . .
E. C. Cubides & J. G
omez (UN)
13 / 30
Genetic Programming
Representation of programs
Representation of GP I
Representation
As any program can be represented as a tree or a set of trees (genotype),
the programs (chromosomes) usually are represented as data structures
(trees), these trees are obtained doing parsing over sentences (strings) of a
program (phenotype), from where GP is applied over a particular domain
(programming language).
E. C. Cubides & J. G
omez (UN)
14 / 30
Genetic Programming
Representation of programs
Representation of GP II
Phenotype and Genotype
Phenotype
Genotype
a+bc
2a
E. C. Cubides & J. G
omez (UN)
+
a
15 / 30
Genetic Programming
Representation of programs
Representation of GP III
Phenotype and Genotype
b +
b 2 4ac
(b, b), ((4, a), c)
, (2, a)
= + (1, b),
2a
b
4
E. C. Cubides & J. G
omez (UN)
c
a
16 / 30
Genetic Programming
Initial population I
Methods
As the mutation is almost always lethal, it is very restricted, then, the
diversity in the generations is obtained only into the initial population.
The main methods are:
Full
Grow
Ramped (half-and-half)
E. C. Cubides & J. G
omez (UN)
17 / 30
Genetic Programming
Initial population II
Full: Length of all branches equal to l > 0.
Example (Depth l = 2)
+
c a
+
b
(c b) + a
(a c) (a + b)
c a
(b c) (a c)
E. C. Cubides & J. G
omez (UN)
b
b+b
c (a b)
Doctorate in Computer Engineering
+
b a
(a b) (a + c)
2nd Semester 2014
18 / 30
Genetic Programming
c
a
c + (a 2)
ac
a
a
E. C. Cubides & J. G
omez (UN)
aa
Doctorate in Computer Engineering
+
b a
(a b) (a + c)
2nd Semester 2014
19 / 30
Genetic Programming
Initial population II
Ramped (half-and-half): if is the cardinal of the population, then l
trees of depth 1, 2, 3, . . . , l are created with the full
or grow
methods (the root has depth equal to 0). Thus, l trees
are generated, but as
jk
l
j lk
l l
l
j l k
l
l
then l l > 0. If l l > 0 then l l trees of
depth 1 or 2 or or l are generated to complete the
population.
E. C. Cubides & J. G
omez (UN)
20 / 30
Genetic Programming
Initial population IV
Example (For = 6 and depth l = 4, b/lc = 1, b/lcl = 2 )
l1 = 1
l3 = 3
l4 = 4
ac
l2 = 2
a
+
(c b) +
b
a
c ((a + a) b)
+
a
a
b
l5 = 3
l6 = 1
(a (c b)) (a + c)
E. C. Cubides & J. G
omez (UN)
p
b + (c + (a 2))
21 / 30
Genetic Programming
Selection strategy
Selection
E. C. Cubides & J. G
omez (UN)
22 / 30
Genetic Programming
Selection strategy
Operators I
Crossover: given a couple of programs, a subtree of each program is
randomly selected and these subtrees are swapped.
Example
E. C. Cubides & J. G
omez (UN)
+
c
b
b
b
c
b
b
c
Doctorate in Computer Engineering
23 / 30
Genetic Programming
Generation of offspring
Operators II
Mutation: given a program, a subtree of this program is randomly
selected and it is replaced by a new randomly generated tree.
Example
+
1
b
c
b
+
E. C. Cubides & J. G
omez (UN)
24 / 30
Genetic Programming
Generation of offspring
Operators II
Swap: given a function, a subfunction f is randomly selected, if this
subfunction has arity n 2, then two different parameters ai ,
aj (i 6= j) are randomly selected and these are swapping, thus
f (a1 , . . . , ai , . . . , aj , . . . , an ) f (a1 , . . . , aj , . . . , ai , . . . , an )
Example
+
1
E. C. Cubides & J. G
omez (UN)
+
a
+
b
25 / 30
Genetic Programming
Replacement strategy
Replacement strategy
E. C. Cubides & J. G
omez (UN)
worst
best
parent
random
most similar (crowding)
oldest
26 / 30
Genetic Programming
Advantages
E. C. Cubides & J. G
omez (UN)
27 / 30
Genetic Programming
Disadvantages
E. C. Cubides & J. G
omez (UN)
28 / 30
Genetic Programming
References I
E. C. Cubides & J. G
omez (UN)
29 / 30
Genetic Programming
Thank you
Questions?
E. C. Cubides & J. G
omez (UN)
30 / 30