Upload
-
View
272
Download
0
Embed Size (px)
Citation preview
8/2/2019 Grammatical Evo
1/126
Introduction
Gecco 2006 Grammatical Evolution Tutorial
Conor Ryan
Biocomputing and Developmental Systems GroupDepartment of Computer Science and Information Systems
University of Limerick
8th July 2006
(University of Limerick) Grammatical Evolution 8th July 2006 1 / 81
http://find/8/2/2019 Grammatical Evo
2/126
Introduction
Outline
1
Introduction
2 Grammatical Evolution
3 Genetic Operators
4 GAuGE
5 Chorus
6 Degeneracy
7 Wrapping
8 Search Techni ues
(University of Limerick) Grammatical Evolution 8th July 2006 2 / 81
http://find/http://goback/8/2/2019 Grammatical Evo
3/126
Introduction
Issues with GP
Function/terminal set must have closure
Single types only
Trees grow, or bloat
(University of Limerick) Grammatical Evolution 8th July 2006 3 / 81
http://find/8/2/2019 Grammatical Evo
4/126
Introduction
Issues with GP
Function/terminal set must have closure
Single types only
Trees grow, or bloat
(University of Limerick) Grammatical Evolution 8th July 2006 3 / 81
http://find/8/2/2019 Grammatical Evo
5/126
Introduction
Issues with GP
Function/terminal set must have closure
Single types only
Trees grow, or bloat
(University of Limerick) Grammatical Evolution 8th July 2006 3 / 81
I d i
http://find/8/2/2019 Grammatical Evo
6/126
Introduction
Biological Phenomena
No simple one to one mapping
Genes produce proteins
Proteins combine to create phenotype
Linear strings
Genomes are always held on strings
Unconstrained searchRepair not performed
(University of Limerick) Grammatical Evolution 8th July 2006 4 / 81
I t d ti
http://find/http://goback/8/2/2019 Grammatical Evo
7/126
Introduction
Biological Phenomena
No simple one to one mapping
Genes produce proteins
Proteins combine to create phenotype
Linear strings
Genomes are always held on strings
Unconstrained search
Repair not performed
(University of Limerick) Grammatical Evolution 8th July 2006 4 / 81
Introduction
http://find/http://goback/8/2/2019 Grammatical Evo
8/126
Introduction
Biological Phenomena
No simple one to one mapping
Genes produce proteins
Proteins combine to create phenotype
Linear strings
Genomes are always held on strings
Unconstrained search
Repair not performed
(University of Limerick) Grammatical Evolution 8th July 2006 4 / 81
Grammatical Evolution
http://find/http://goback/8/2/2019 Grammatical Evo
9/126
Grammatical Evolution
Grammatical Evolution
Grammatical Evolution (GE)
GA to evolve programsMorphogenetic Effect:
Genotype mapped to phenotype
Phenotype is a compilable program
Genome governs mapping of a BNF/attribute grammar definition
to the program
(University of Limerick) Grammatical Evolution 8th July 2006 5 / 81
Grammatical Evolution
http://find/http://goback/8/2/2019 Grammatical Evo
10/126
Grammatical Evolution
Grammatical Evolution
Grammatical Evolution (GE)
GA to evolve programsMorphogenetic Effect:
Genotype mapped to phenotype
Phenotype is a compilable program
Genome governs mapping of a BNF/attribute grammar definition
to the program
(University of Limerick) Grammatical Evolution 8th July 2006 5 / 81
Grammatical Evolution
http://find/http://goback/8/2/2019 Grammatical Evo
11/126
Grammatical Evolution
Grammatical Evolution
Grammatical Evolution (GE)
GA to evolve programsMorphogenetic Effect:
Genotype mapped to phenotype
Phenotype is a compilable program
Genome governs mapping of a BNF/attribute grammar definition
to the program
(University of Limerick) Grammatical Evolution 8th July 2006 5 / 81
Grammatical Evolution
http://find/http://goback/8/2/2019 Grammatical Evo
12/126
Grammatical Evolution
Grammatical Evolution
Here genome (a binary string) is mapped to compilable C code
Can potentially evolve programs in any language, with arbitrary
complexity
Any structure than be specified with a grammar, e.g. graphs,
neural networks, etc.
(University of Limerick) Grammatical Evolution 8th July 2006 6 / 81
Grammatical Evolution Grammars
http://find/8/2/2019 Grammatical Evo
13/126
Language Definition
Backus Naur Form (BNF)Notation for expressing a languages grammar as Production Rules
BNF Grammar consists of the tuple < T,N,P,S > where
T is Terminals setN is Non-Terminals set
P is Production Rules setS is Start Symbol (a member of N)
BNF Example
T = {Sin, Cos, Tan, Log, +,, /,, X, (, )}
S =< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 7 / 81
Grammatical Evolution Grammars
http://find/8/2/2019 Grammatical Evo
14/126
Language Definition
Backus Naur Form (BNF)Notation for expressing a languages grammar as Production Rules
BNF Grammar consists of the tuple < T,N,P,S > where
T is Terminals setN is Non-Terminals set
P is Production Rules setS is Start Symbol (a member of N)
BNF Example
T = {Sin, Cos, Tan, Log, +,, /,, X, (, )}
S =< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 7 / 81
Grammatical Evolution Grammars
http://find/http://goback/8/2/2019 Grammatical Evo
15/126
Language Definition
Backus Naur Form (BNF)Notation for expressing a languages grammar as Production Rules
BNF Grammar consists of the tuple < T,N,P,S > where
T is Terminals setN is Non-Terminals set
P is Production Rules setS is Start Symbol (a member of N)
BNF Example
T = {Sin, Cos, Tan, Log, +,, /,, X, (, )}
S =< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 7 / 81
Grammatical Evolution Grammars
http://find/http://goback/8/2/2019 Grammatical Evo
16/126
BNF Definition
N = {expr, op, pre_op}
And P can be represented as:
(1) ::= (A)
| ( ) (B)
| ( ) (C)
| (D)
(2) ::= + (A)
| - ( B )| / ( C )
| * ( D )
(University of Limerick) Grammatical Evolution 8th July 2006 8 / 81
Grammatical Evolution Grammars
http://find/http://goback/8/2/2019 Grammatical Evo
17/126
BNF Definition
(3) ::= Sin (A)
| Cos (B)
| Tan (C)
(4) ::= X (A)
A Genetic Algorithm is used to control choice of production rule
(University of Limerick) Grammatical Evolution 8th July 2006 9 / 81
Grammatical Evolution Architecture
http://find/http://goback/8/2/2019 Grammatical Evo
18/126
Architecture
(University of Limerick) Grammatical Evolution 8th July 2006 10 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
19/126
Related GP Systems
Name Genome Representation
Koza Tree Direct
Banzhaf et al Linear Direct
Gruau Tree Graph Grammar
Whigham Tree Derivation Tree
Wong & Leung Tree Logic Grammars
Paterson Linear GrammarRepair mechanisms..
Koza - none needed
Banzhaf - required for syntactically legal individualsGruau - none needed
Whigham - all crossovers subject to repair
Wong & Leung - all crossovers subject to repair
Paterson - under/overspecification.
(University of Limerick) Grammatical Evolution 8th July 2006 11 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
20/126
Related GP Systems
Name Genome Representation
Koza Tree Direct
Banzhaf et al Linear Direct
Gruau Tree Graph Grammar
Whigham Tree Derivation Tree
Wong & Leung Tree Logic Grammars
Paterson Linear GrammarRepair mechanisms..
Koza - none needed
Banzhaf - required for syntactically legal individualsGruau - none needed
Whigham - all crossovers subject to repair
Wong & Leung - all crossovers subject to repair
Paterson - under/overspecification.
(University of Limerick) Grammatical Evolution 8th July 2006 11 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
21/126
Repair
(University of Limerick) Grammatical Evolution 8th July 2006 12 / 81
Grammatical Evolution Comparison
http://find/8/2/2019 Grammatical Evo
22/126
Repair
(University of Limerick) Grammatical Evolution 8th July 2006 12 / 81
Grammatical Evolution Comparison
http://find/8/2/2019 Grammatical Evo
23/126
Repair
(University of Limerick) Grammatical Evolution 8th July 2006 12 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
24/126
Repair
(University of Limerick) Grammatical Evolution 8th July 2006 12 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
25/126
Repair
(University of Limerick) Grammatical Evolution 8th July 2006 13 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
26/126
Grammatical Evolution
In contrast GE usesBNF - Paterson/Whigham/Wong etc.Variable Length Linear Chromosomes - Koza/Gruau/BanzhafGenome encodes pseudo-random numbersDegenerate Genetic Code
Several genes map to same phenotypeWrap individuals
Use 8 bit codons
Each codon represents at least one Production RuleGene contains many codons
Pseudo-random numbers determine what production rule will be
used
(University of Limerick) Grammatical Evolution 8th July 2006 14 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
27/126
Grammatical Evolution
In contrast GE usesBNF - Paterson/Whigham/Wong etc.Variable Length Linear Chromosomes - Koza/Gruau/BanzhafGenome encodes pseudo-random numbersDegenerate Genetic Code
Several genes map to same phenotypeWrap individuals
Use 8 bit codons
Each codon represents at least one Production RuleGene contains many codons
Pseudo-random numbers determine what production rule will be
used
(University of Limerick) Grammatical Evolution 8th July 2006 14 / 81
Grammatical Evolution Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
28/126
Grammatical Evolution
Expression of a Codonresults in an Amino Acid
(choice in the derivation sequence)
Amino acidscan combine to form a functional protein (i.e.
Terminals such as +, X or Sin, can combine)
(University of Limerick) Grammatical Evolution 8th July 2006 15 / 81
Grammatical Evolution Comparison
G
http://find/http://goback/8/2/2019 Grammatical Evo
29/126
Grammatical Evolution
Expression of a Codonresults in an Amino Acid
(choice in the derivation sequence)Amino acidscan combine to form a functional protein (i.e.Terminals such as +, X or Sin, can combine)
(University of Limerick) Grammatical Evolution 8th July 2006 15 / 81
Grammatical Evolution Example
E l I di id l
http://find/http://goback/8/2/2019 Grammatical Evo
30/126
Example Individual
To complete BNF definition for a function written in a subset of C
we include.....
::=
::= float symb(float X)
::=
::= float a; ::= a = ;
::= return (a);
Note implementation details.....
Function is limited to a single line of codeIf required can get GE to generate multi-line functions.....modify
::= ;
| ;
(University of Limerick) Grammatical Evolution 8th July 2006 16 / 81
Grammatical Evolution Example
E l I di id l
http://find/8/2/2019 Grammatical Evo
31/126
Example Individual
To complete BNF definition for a function written in a subset of C
we include.....
::=
::= float symb(float X)
::=
::= float a; ::= a = ;
::= return (a);
Note implementation details.....
Function is limited to a single line of codeIf required can get GE to generate multi-line functions.....modify
::= ;
| ;
(University of Limerick) Grammatical Evolution 8th July 2006 16 / 81
Grammatical Evolution Example
E l I di id l
http://find/http://goback/8/2/2019 Grammatical Evo
32/126
Example Individual
In this subset of C all individuals of the form
float symb(float x)
{
float a;
a = ;return(a);
}
Only < expr > will be evolved
Each non-terminal is mapped to a terminal before any othersundergo a mapping process
(University of Limerick) Grammatical Evolution 8th July 2006 17 / 81
Grammatical Evolution Example
E m l I di id l
http://find/http://goback/8/2/2019 Grammatical Evo
33/126
Example Individual
Given the individual
220 203 51 123 2 45 ....what will happen?
has 4 production rules to choose from
(1) ::= (A)
| ( ) (B)
| ( ) (C)
| (D)
Taking first codon 220 we get 220 MOD 4 = 0Gives < op >< expr >
Next choice for the first
Taking next codon 203 we get 203 MOD 4 = 3Gives < op >< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 18 / 81
Grammatical Evolution Example
Example Individual
http://find/http://goback/8/2/2019 Grammatical Evo
34/126
Example Individual
Given the individual
220 203 51 123 2 45 ....what will happen?
has 4 production rules to choose from
(1) ::= (A)
| ( ) (B)
| ( ) (C)
| (D)
Taking first codon 220 we get 220 MOD 4 = 0Gives < op >< expr >
Next choice for the first
Taking next codon 203 we get 203 MOD 4 = 3Gives < op >< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 18 / 81
Grammatical Evolution Example
Example Individual
http://find/8/2/2019 Grammatical Evo
35/126
Example Individual
Given the individual
220 203 51 123 2 45 ....what will happen?
has 4 production rules to choose from
(1) ::= (A)
| ( ) (B)
| ( ) (C)
| (D)
Taking first codon 220 we get 220 MOD 4 = 0Gives < op >< expr >
Next choice for the first
Taking next codon 203 we get 203 MOD 4 = 3Gives < op >< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 18 / 81
Grammatical Evolution Example
Example Individual
http://find/8/2/2019 Grammatical Evo
36/126
Example Individual
Given the individual
220 203 51 123 2 45 ....what will happen?
has 4 production rules to choose from
(1) ::= (A)
| ( ) (B)
| ( ) (C)
| (D)
Taking first codon 220 we get 220 MOD 4 = 0Gives < op >< expr >
Next choice for the first
Taking next codon 203 we get 203 MOD 4 = 3Gives < op >< expr >
(University of Limerick) Grammatical Evolution 8th July 2006 18 / 81
Grammatical Evolution Example
Example Individual
http://find/8/2/2019 Grammatical Evo
37/126
Example Individual
involves no choice
Mapped to X...only one productionNow have X < expr >
220 203 51 123 2 45
Read next codon to choose
Next is third codon , value 51, so get 51 MOD 4 = 3Now have X
Next choice for
Next codon is 123 so get 123 MOD 4 = 3Now have X
Again involves no choice
Finally we get X X
The extra codons at end of genome are simply ignored in mapping
the genotype to phenotype
(University of Limerick) Grammatical Evolution 8th July 2006 19 / 81
Grammatical Evolution Example
Example Individual
http://find/http://goback/8/2/2019 Grammatical Evo
38/126
Example Individual
involves no choice
Mapped to X...only one productionNow have X < expr >
220 203 51 123 2 45
Read next codon to choose
Next is third codon , value 51, so get 51 MOD 4 = 3Now have X
Next choice for
Next codon is 123 so get 123 MOD 4 = 3Now have X
Again involves no choice
Finally we get X X
The extra codons at end of genome are simply ignored in mapping
the genotype to phenotype
(University of Limerick) Grammatical Evolution 8th July 2006 19 / 81
Grammatical Evolution Example
Example Individual
http://find/8/2/2019 Grammatical Evo
39/126
Example Individual
involves no choice
Mapped to X...only one productionNow have X < expr >
220 203 51 123 2 45
Read next codon to choose
Next is third codon , value 51, so get 51 MOD 4 = 3Now have X
Next choice for
Next codon is 123 so get 123 MOD 4 = 3Now have X
Again involves no choice
Finally we get X X
The extra codons at end of genome are simply ignored in mapping
the genotype to phenotype
(University of Limerick) Grammatical Evolution 8th July 2006 19 / 81
Grammatical Evolution Mapping
Example Mapping Overview
http://find/http://goback/8/2/2019 Grammatical Evo
40/126
Example Mapping Overview
Figure: Example Mapping Outline
:: = |() |
8/2/2019 Grammatical Evo
41/126
Derivation Tree Structure
1 2 5 7
220 203 51 123 2 45
Not all nodes require a choice!
(University of Limerick) Grammatical Evolution 8th July 2006 21 / 81
Grammatical Evolution Mapping
Codons are polymorphic
http://find/http://goback/8/2/2019 Grammatical Evo
42/126
Codons are polymorphic
When mapping < expr >, we calculate
220 mod 4
However, if we were mapping < pre op > with 220, we wouldcalculate
220 mod 3
because there are just three choices
Meaning of a codon depends on its context
(University of Limerick) Grammatical Evolution 8th July 2006 22 / 81
Grammatical Evolution Mapping
Codons are polymorphic
http://find/http://goback/8/2/2019 Grammatical Evo
43/126
Codons are polymorphic
When mapping < expr >, we calculate
220 mod 4
However, if we were mapping < pre op > with 220, we wouldcalculate
220 mod 3
because there are just three choices
Meaning of a codon depends on its context
(University of Limerick) Grammatical Evolution 8th July 2006 22 / 81
Grammatical Evolution Mapping
Mapping Process
http://find/http://goback/8/2/2019 Grammatical Evo
44/126
Mapping Process
No simple one to one mapping in GE
Mapping Process to generate programs
Separate Search and Solution Spaces
Ensure validity of individualsRemove language dependencyMaintain diversity
(University of Limerick) Grammatical Evolution 8th July 2006 23 / 81
Grammatical Evolution Mapping
Genetic Code Degeneracy
http://find/http://goback/8/2/2019 Grammatical Evo
45/126
g y
Figure: The Degenerate Genetic Code
(University of Limerick) Grammatical Evolution 8th July 2006 24 / 81
Grammatical Evolution Mapping
Genetic Code Degeneracy
http://find/http://goback/8/2/2019 Grammatical Evo
46/126
g y
Neutral Mutations
Mutations having no effect on Phenotype Fitness
Help preserve individual validity
Gradual accumulation of mutations without harming functionalityRevisit later
(University of Limerick) Grammatical Evolution 8th July 2006 25 / 81
Grammatical Evolution Initialisation
Initialisation
http://find/8/2/2019 Grammatical Evo
47/126
Individuals are strings of random numbers
No guarantee that they will terminateIndividuals can be veryshort.
::=
| ( )
| ( )
|
Production
->
always leads to termination
is the start symbol
On average, a quarter of all individuals are just one point
(University of Limerick) Grammatical Evolution 8th July 2006 26 / 81
Grammatical Evolution Initialisation
Initialisation
http://find/http://goback/8/2/2019 Grammatical Evo
48/126
Individuals are strings of random numbers
No guarantee that they will terminateIndividuals can be veryshort.
::=
| ( )
| ( )
|
Production
->
always leads to termination
is the start symbol
On average, a quarter of all individuals are just one point
(University of Limerick) Grammatical Evolution 8th July 2006 26 / 81
Grammatical Evolution Initialisation
Sensible Initialisation
http://find/http://goback/8/2/2019 Grammatical Evo
49/126
Generate a spread of individual sizes.Based on Ramped Half and Half initialisation in GP
For all tree depths from 2 to maximum size
Generate an equal number of trees of that size
Use fullfor 50%Use grow for 50%
Similar in GE, but generate derivation treesof equivalent size
(University of Limerick) Grammatical Evolution 8th July 2006 27 / 81
Grammatical Evolution Initialisation
Sensible Initialisation - 2
http://find/http://goback/8/2/2019 Grammatical Evo
50/126
Record which number choice was made for each step
Perform an unmod on list of choices
Produce a number between 0 and 255 that produces the originalnumber when moded by the number of choices for that
productionruleEnsures that all individuals are valid
Reduces the number of clones (easier to detect)
Eliminates single point individuals (if desired)
(University of Limerick) Grammatical Evolution 8th July 2006 28 / 81
Grammatical Evolution Initialisation
Sensible Initialisation - 2
http://find/http://goback/8/2/2019 Grammatical Evo
51/126
Record which number choice was made for each step
Perform an unmod on list of choices
Produce a number between 0 and 255 that produces the originalnumber when moded by the number of choices for that
productionruleEnsures that all individuals are valid
Reduces the number of clones (easier to detect)
Eliminates single point individuals (if desired)
(University of Limerick) Grammatical Evolution 8th July 2006 28 / 81
Genetic Operators
Genetic Operators
http://find/http://goback/8/2/2019 Grammatical Evo
52/126
Perform unconstrained Evolutionary SearchGE employs standard operators of Genetic Algorithms
Point mutation, one-point crossover etc.
Sometimes modified version of one-point crossover, SensibleCrossover, is used:
Effective lengthActual length
(University of Limerick) Grammatical Evolution 8th July 2006 29 / 81
Genetic Operators
Genetic Operators
http://find/http://goback/8/2/2019 Grammatical Evo
53/126
Perform unconstrained Evolutionary SearchGE employs standard operators of Genetic Algorithms
Point mutation, one-point crossover etc.
Sometimes modified version of one-point crossover, SensibleCrossover, is used:
Effective lengthActual length
(University of Limerick) Grammatical Evolution 8th July 2006 29 / 81
Genetic Operators Crossover
Crossover
http://find/8/2/2019 Grammatical Evo
54/126
What actually happens in crossover?Preliminary : Visualisation.
Crossover is performed at genotypic level
(University of Limerick) Grammatical Evolution 8th July 2006 30 / 81
Genetic Operators Crossover
Crossover
http://find/8/2/2019 Grammatical Evo
55/126
What actually happens in crossover?Preliminary : Visualisation.
Crossover is performed at genotypic level
(University of Limerick) Grammatical Evolution 8th July 2006 30 / 81
Genetic Operators Crossover
Crossover
http://find/8/2/2019 Grammatical Evo
56/126
What actually happens in crossover?Preliminary : Visualisation.
Crossover is performed at genotypic level
(University of Limerick) Grammatical Evolution 8th July 2006 30 / 81
Genetic Operators Crossover
Crossover
http://find/8/2/2019 Grammatical Evo
57/126
What actually happens in crossover?Preliminary : Visualisation.
Crossover is performed at genotypic level
(University of Limerick) Grammatical Evolution 8th July 2006 30 / 81
Genetic Operators Crossover
Crossover
http://find/8/2/2019 Grammatical Evo
58/126
What actually happens in crossover?Preliminary : Visualisation.
Crossover is performed at genotypic level
(University of Limerick) Grammatical Evolution 8th July 2006 30 / 81
Genetic Operators Ripple Crossover
Ripple Crossover
http://find/8/2/2019 Grammatical Evo
59/126
Analyse 1-point crossover in terms of derivation & syntax treesUse a closedgrammar
E::= (+ E E) {0}
|(- E E) {1}
|(- E E) {2}|(- E E) {3}
|X {4}
|Y {5}
No polymorphism, because there is only one non-terminal, i.e.
one context
(University of Limerick) Grammatical Evolution 8th July 2006 31 / 81
Genetic Operators Ripple Crossover
Ripple Crossover
http://find/8/2/2019 Grammatical Evo
60/126
Analyse 1-point crossover in terms of derivation & syntax treesUse a closedgrammar
E::= (+ E E) {0}
|(- E E) {1}
|(- E E) {2}|(- E E) {3}
|X {4}
|Y {5}
No polymorphism, because there is only one non-terminal, i.e.
one context
(University of Limerick) Grammatical Evolution 8th July 2006 31 / 81
Genetic Operators Ripple Crossover
Different Views of Crossover
http://find/8/2/2019 Grammatical Evo
61/126
(University of Limerick) Grammatical Evolution 8th July 2006 32 / 81
http://find/8/2/2019 Grammatical Evo
62/126
Genetic Operators Ripple Crossover
Different Views of Crossover
8/2/2019 Grammatical Evo
63/126
(University of Limerick) Grammatical Evolution 8th July 2006 32 / 81
Genetic Operators Ripple Crossover
Different Views of Crossover
http://find/http://goback/8/2/2019 Grammatical Evo
64/126
(University of Limerick) Grammatical Evolution 8th July 2006 32 / 81
Genetic Operators Ripple Crossover
Different Views of Crossover
http://find/http://goback/8/2/2019 Grammatical Evo
65/126
(University of Limerick) Grammatical Evolution 8th July 2006 32 / 81
Genetic Operators Ripple Crossover
Rebuilding individuals
http://find/http://goback/8/2/2019 Grammatical Evo
66/126
Parent left with spine
Tail swapped with other parent
4 5 9 4 5 2 0 5 2 2
Unmapped E terms must be mapped
Use tail from other parent
(University of Limerick) Grammatical Evolution 8th July 2006 33 / 81
Genetic Operators Ripple Crossover
Rebuilding individuals
http://find/http://goback/8/2/2019 Grammatical Evo
67/126
Parent left with spine
Tail swapped with other parent
4 5 9 4 5 2 0 5 2 2
Unmapped E terms must be mapped
Use tail from other parent
(University of Limerick) Grammatical Evolution 8th July 2006 33 / 81
Genetic Operators Ripple Crossover
Intrinsic Polymorphism
http://find/http://goback/8/2/2019 Grammatical Evo
68/126
With more than one non-terminal, a codon could be useddifferently in the offspring
(University of Limerick) Grammatical Evolution 8th July 2006 34 / 81
Genetic Operators Ripple Crossover
Intrinsic Polymorphism
http://find/8/2/2019 Grammatical Evo
69/126
With more than one non-terminal, a codon could be useddifferently in the offspring
(University of Limerick) Grammatical Evolution 8th July 2006 34 / 81
Genetic Operators Ripple Crossover
Intrinsic Polymorphism
http://find/8/2/2019 Grammatical Evo
70/126
With more than one non-terminal, a codon could be useddifferently in the offspring
(University of Limerick) Grammatical Evolution 8th July 2006 34 / 81
Genetic Operators Ripple Crossover
Intrinsic Polymorphism
http://find/8/2/2019 Grammatical Evo
71/126
With more than one non-terminal, a codon could be useddifferently in the offspring
(University of Limerick) Grammatical Evolution 8th July 2006 34 / 81
Genetic Operators Ripple Crossover
Effects of Ripple Crossover
http://find/http://goback/8/2/2019 Grammatical Evo
72/126
Symbolic Regression GrammarsClosed Grammar
E ::= x
| ( + E E ) | ( * E E )
| ( - E E ) | ( / E E )And the context free grammar:
Exp ::= Var | Exp Op Exp
Var ::= x
Op ::= + | * | - | /
(University of Limerick) Grammatical Evolution 8th July 2006 35 / 81
Genetic Operators Ripple Crossover
Effects (contd.)
http://find/http://goback/8/2/2019 Grammatical Evo
73/126
Santa Fe ant trail grammarsClosed grammar
E ::= move() | left() | right()
| iffoodahead(E E) | prog2(E, E)
Context free grammar:
Code ::= Line | prog2(Line, Code)
Line ::= Condition | Action
Action ::= move() | right() | left()
Condition ::= iffoodahead(Code, Code)
(University of Limerick) Grammatical Evolution 8th July 2006 36 / 81
Genetic Operators Ripple Crossover
Symbolic Regresssion Success Rates
http://find/http://goback/8/2/2019 Grammatical Evo
74/126
Both ripple crossovers start more slowly, but reach higher fitness.
(University of Limerick) Grammatical Evolution 8th July 2006 37 / 81
Genetic Operators Ripple Crossover
Santa Fe Success Rates
http://find/8/2/2019 Grammatical Evo
75/126
Both ripple crossovers again start more slowly, but reach similar
fitness.
(University of Limerick) Grammatical Evolution 8th July 2006 38 / 81
Genetic Operators Ripple Crossover
Santa Fe - Extended Run
http://find/http://goback/8/2/2019 Grammatical Evo
76/126
Success rates on the Santa Fe ant trail problem, averaged over 100
runs, for 250 generations. Ripple crossovers start slowly, but reach
higher fitness.
(University of Limerick) Grammatical Evolution 8th July 2006 39 / 81
Genetic Operators Alternative Crossovers
Other types of Crossover?
http://find/http://goback/8/2/2019 Grammatical Evo
77/126
Homologous Crossover
Try not to cross in identical areas
Uniform
Same size homologousSame size two point
(University of Limerick) Grammatical Evolution 8th July 2006 40 / 81
Genetic Operators Alternative Crossovers
Homologous Crossover - First point
Record rule histories for each individual
http://find/http://goback/8/2/2019 Grammatical Evo
78/126
Record rule histories for each individual
Align rule histories of parents
(University of Limerick) Grammatical Evolution 8th July 2006 41 / 81
Genetic Operators Alternative Crossovers
Homologous Crossover - First point
Record rule histories for each individual
http://find/http://goback/8/2/2019 Grammatical Evo
79/126
Record rule histories for each individual
Align rule histories of parents
(University of Limerick) Grammatical Evolution 8th July 2006 41 / 81
Genetic Operators Alternative Crossovers
Homologous Crossover - Second Point
http://find/http://goback/8/2/2019 Grammatical Evo
80/126
Choose second point outside of area of similarity
(University of Limerick) Grammatical Evolution 8th July 2006 42 / 81
Genetic Operators Alternative Crossovers
Crossover comparisons (Cumulative Freq. Success)
http://find/8/2/2019 Grammatical Evo
81/126
(University of Limerick) Grammatical Evolution 8th July 2006 43 / 81
Genetic Operators Alternative Crossovers
Productivity of Operators (Ratio of successes)
http://find/http://goback/8/2/2019 Grammatical Evo
82/126
(University of Limerick) Grammatical Evolution 8th July 2006 44 / 81 Genetic Operators Alternative Crossovers
Relative size of crossover fragments
http://find/8/2/2019 Grammatical Evo
83/126
Ratio of the average fragment size being swapped and the average
chromosome length at each generation averaged over 20 runs.
(University of Limerick) Grammatical Evolution 8th July 2006 45 / 81 Genetic Operators Alternative Crossovers
Headless Chicken - Crossover or Macromutation
http://find/http://goback/8/2/2019 Grammatical Evo
84/126
Appears Crossover works
50% material exchange with 1-point over entire runs
If useful material exchanged then swapping random fragmentsshould degrade performance?
(University of Limerick) Grammatical Evolution 8th July 2006 46 / 81 Genetic Operators Alternative Crossovers
Headless Chicken Comparison
http://find/http://goback/8/2/2019 Grammatical Evo
85/126
(University of Limerick) Grammatical Evolution 8th July 2006 47 / 81 Genetic Operators Explanation
Why does crossover work?
http://find/8/2/2019 Grammatical Evo
86/126
Take a cue from GP crossover - The Eve Effect :
All individuals in the final generation tend to evolve from the sameancestor
The upper parts of individuals tend to come from the same
individual
(University of Limerick) Grammatical Evolution 8th July 2006 48 / 81 Genetic Operators Explanation
Why does crossover work?
http://find/http://goback/8/2/2019 Grammatical Evo
87/126
Take a cue from GP crossover - The Eve Effect :
All individuals in the final generation tend to evolve from the sameancestor
The upper parts of individuals tend to come from the same
individual
(University of Limerick) Grammatical Evolution 8th July 2006 48 / 81 Genetic Operators Explanation
GE View of Eve Effect?
http://find/8/2/2019 Grammatical Evo
88/126
Individuals grow from left to right
(University of Limerick) Grammatical Evolution 8th July 2006 49 / 81 Genetic Operators Explanation
Size of region of similarity increases over time
Area immediately beyond region of similarity is region of
di
http://find/http://goback/8/2/2019 Grammatical Evo
89/126
discovery :
(University of Limerick) Grammatical Evolution 8th July 2006 50 / 81 Genetic Operators Explanation
Size of region of similarity increases over time
Area immediately beyond region of similarity is region of
di
http://find/8/2/2019 Grammatical Evo
90/126
discovery :
(University of Limerick) Grammatical Evolution 8th July 2006 50 / 81 Genetic Operators Explanation
Size of region of similarity increases over time
Area immediately beyond region of similarity is region of
di
http://find/http://goback/8/2/2019 Grammatical Evo
91/126
discovery :
(University of Limerick) Grammatical Evolution 8th July 2006 50 / 81 GAuGE Introduction
The GAuGE System
http://find/8/2/2019 Grammatical Evo
92/126
Genetic Algorithms using Grammatical Evolution
Purpose:
Position independent genetic algorithm;
No under- or over-specification;
Independent of search engine.
Based on mapping process (similar to GE):
Specify position and value of each variable at genotypic level;
Map genotype strings into functional phenotype strings.
(University of Limerick) Grammatical Evolution 8th July 2006 51 / 81 GAuGE Introduction
The GAuGE System
http://find/8/2/2019 Grammatical Evo
93/126
Genetic Algorithms using Grammatical Evolution
Purpose:
Position independent genetic algorithm;
No under- or over-specification;
Independent of search engine.
Based on mapping process (similar to GE):
Specify position and value of each variable at genotypic level;
Map genotype strings into functional phenotype strings.
(University of Limerick) Grammatical Evolution 8th July 2006 51 / 81 GAuGE Mapping
Mapping in the GAuGE System
Transform binary string into integer string:
P bl h i bl ( ) i h
http://find/8/2/2019 Grammatical Evo
94/126
Problem has 4 variables ( = 4), with range 0 . . . 7;
Choose position field size (pfs = 2);
Choose value field size (vfs = 4);
Calculate binary string length:
L = (pfs+ vfs) = (2 + 4) 4 = 24 bits
(University of Limerick) Grammatical Evolution 8th July 2006 52 / 81 GAuGE Mapping
Mapping in the GAuGE System
Transform binary string into integer string:
P bl h 4 i bl ( 4) ith 0 7
http://find/http://goback/8/2/2019 Grammatical Evo
95/126
Problem has 4 variables ( = 4), with range 0 . . . 7;
Choose position field size (pfs = 2);
Choose value field size (vfs = 4);
Calculate binary string length:
L = (pfs+ vfs) = (2 + 4) 4 = 24 bits
(University of Limerick) Grammatical Evolution 8th July 2006 52 / 81 GAuGE Mapping
Mapping in the GAuGE System
Transform binary string into integer string:
P bl h 4 i bl ( 4) ith 0 7
http://find/8/2/2019 Grammatical Evo
96/126
Problem has 4 variables ( = 4), with range 0 . . . 7;
Choose position field size (pfs = 2);
Choose value field size (vfs = 4);
Calculate binary string length:
L = (pfs+ vfs) = (2 + 4) 4 = 24 bits
(University of Limerick) Grammatical Evolution 8th July 2006 52 / 81 GAuGE Mapping
Mapping in the GAuGE System
Transform binary string into integer string:
Problem has 4 variables ( 4) with range 0 7;
http://find/8/2/2019 Grammatical Evo
97/126
Problem has 4 variables ( = 4), with range 0 . . . 7;
Choose position field size (pfs = 2);
Choose value field size (vfs = 4);
Calculate binary string length:
L = (pfs+ vfs) = (2 + 4) 4 = 24 bits
0 0 1 0 0 1 1 0 1 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0
0 9 2 13 1 4 1 2
Binary string
Integer string
(University of Limerick) Grammatical Evolution 8th July 2006 52 / 81 GAuGE Mapping
Calculating Phenotype
I t t i
http://find/8/2/2019 Grammatical Evo
98/126
p v p v p v vp
0 9 2 13 1 4 1 2
Integer string
0 1 2 3???Phenotype ?
(University of Limerick) Grammatical Evolution 8th July 2006 53 / 81
GAuGE Mapping
Calculating Phenotype
I t t i
http://find/8/2/2019 Grammatical Evo
99/126
p v p v p v vp
0p: 0 % =
1
0 9 2 13 1 4 1 2
v: 9 % =
Integer string
0 1 2 31 ???Phenotype
4
8
(University of Limerick) Grammatical Evolution 8th July 2006 54 / 81
GAuGE Mapping
Calculating Phenotype
Integer string
http://find/8/2/2019 Grammatical Evo
100/126
p v p v p v vp
0 9 2 13 1 4 1 2
Integer string
p: 2 % =
v:13 % =
2
6
1 ??Phenotype2106
8
3
(University of Limerick) Grammatical Evolution 8th July 2006 55 / 81
GAuGE Mapping
Calculating Phenotype
Integer string
http://find/http://goback/8/2/2019 Grammatical Evo
101/126
p v p v p v vp
0 9 2 13 1 4 1 2
Integer string
1 ?Phenotype106
p: 1 % =
v: 4 % = 4
1
4
8
2
(University of Limerick) Grammatical Evolution 8th July 2006 56 / 81
GAuGE Mapping
The GAuGE System
Integer string
http://find/8/2/2019 Grammatical Evo
102/126
p v p v p v vp
0 9 2 13 1 4 1 2
Integer string
1Phenotype0
6
p: 1 % =
4
v: 2 % =
0
2
2
8
1
(University of Limerick) Grammatical Evolution 8th July 2006 57 / 81
GAuGE Summary
Where is Gauge useful?
http://find/http://goback/8/2/2019 Grammatical Evo
103/126
GAuGE adapts the representation to the problem
Useful where interactions between genes not known
GAuGE is cheap
Far less complicated than algorithms that try to model gene
interactions/relationshipsGAuGE discovers saliency
Most important genes end up on left side of strings
(University of Limerick) Grammatical Evolution 8th July 2006 58 / 81
Chorus Introduction
Chorus
http://find/http://goback/8/2/2019 Grammatical Evo
104/126
Mapping Independent Codons - no ripple effect
Codon % Total number of rules in the grammar
Competition between the Genes
Concentration Table
Variable length binary strings
8 bit codons
(University of Limerick) Grammatical Evolution 8th July 2006 59 / 81
Chorus Introduction
Grammar specification
S=
(0) ::=
http://find/http://goback/8/2/2019 Grammatical Evo
105/126
(0) ::
(1) | ( )
(2) | ( )
(3) |
(4) ::= +
( 5 ) | -
( 6 ) | *
( 7 ) | /
(8) ::= Sin
(9) | Cos
(A) | Exp(B) | Log
(C) ::= 1.0
( D ) | X
(University of Limerick) Grammatical Evolution 8th July 2006 60 / 81
Chorus Introduction
Mapping - 1
Four non terminals:
http://find/8/2/2019 Grammatical Evo
106/126
Four non-terminals:
0..3, 4..7, 8..B, C..D
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 0 0 0 0 0 0 0 0 0 0 0 0
(University of Limerick) Grammatical Evolution 8th July 2006 61 / 81
Chorus Introduction
Mapping - 2
Four non-terminals:
http://find/http://goback/8/2/2019 Grammatical Evo
107/126
Four non terminals:
0..3, 4..7, 8..B, C..D
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2
(University of Limerick) Grammatical Evolution 8th July 2006 62 / 81
Chorus Introduction
Mapping - 3
Four non-terminals:
http://find/8/2/2019 Grammatical Evo
108/126
0..3, 4..7, 8..B, C..D
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 0 2
(University of Limerick) Grammatical Evolution 8th July 2006 63 / 81
Chorus Introduction
Mapping - 4
Four non-terminals:
http://find/8/2/2019 Grammatical Evo
109/126
0..3, 4..7, 8..B, C..D
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 0 2
X 0 0 0 0 1 0 0 0 1 1 0 0 0 1
(University of Limerick) Grammatical Evolution 8th July 2006 64 / 81
Chorus Introduction
Mapping - 5
Four non-terminals:
0 3 4 7 8 B C D
http://find/8/2/2019 Grammatical Evo
110/126
0..3, 4..7, 8..B, C..D
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 0 2
X 0 0 0 0 1 0 0 0 1 1 0 0 0 1X+ 0 0 0 0 0 0 0 0 1 1 0 0 0 1
(University of Limerick) Grammatical Evolution 8th July 2006 65 / 81
Chorus Introduction
Mapping - 6
Four non-terminals:
0..3, 4..7, 8..B, C..D
http://find/8/2/2019 Grammatical Evo
111/126
p , p , p p ,
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 0 2X 0 0 0 0 1 0 0 0 1 1 0 0 0 1
X+ 0 0 0 0 0 0 0 0 1 1 0 0 0 1X+ 0 0 0 0 0 0 0 0 1 1 0 0 0 1
(University of Limerick) Grammatical Evolution 8th July 2006 66 / 81
Chorus Introduction
Mapping - 7
Four non-terminals:
0..3, 4..7, 8..B, C..D
http://goforward/http://find/8/2/2019 Grammatical Evo
112/126
209 102 190 55 65 15 255 87
D 4 8 D 9 1 3 3
0 1 2 3 4 5 6 7 8 9 A B C D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 1 0 0 0 1 1 0 0 0 2X 0 0 0 0 1 0 0 0 1 1 0 0 0 1
X+ 0 0 0 0 0 0 0 0 1 1 0 0 0 1X+ 0 0 0 0 0 0 0 0 1 1 0 0 0 1X+X 0 0 0 0 0 0 0 0 1 1 0 0 0 0
(University of Limerick) Grammatical Evolution 8th July 2006 67 / 81
Degeneracy Performance
Cumulative Freq. with and without degeneracy
http://find/8/2/2019 Grammatical Evo
113/126
No huge difference : Normal, 4- and 6-bit top three in both
(University of Limerick) Grammatical Evolution 8th July 2006 68 / 81
Degeneracy Variety
Mean Variety - Any degeneracy helps!
http://find/8/2/2019 Grammatical Evo
114/126
(University of Limerick) Grammatical Evolution 8th July 2006 69 / 81
Degeneracy Variety
Unique Individuals
http://find/8/2/2019 Grammatical Evo
115/126
(University of Limerick) Grammatical Evolution 8th July 2006 70 / 81
Degeneracy Variety
Conclusions
http://find/8/2/2019 Grammatical Evo
116/126
Conclusions:
Improves genetic diversityImproves frequency of success on Santa Fe ant trailTuneable/Evolvable Degeneracy a good idea?
(University of Limerick) Grammatical Evolution 8th July 2006 71 / 81
Wrapping Number of individuals wrapped
Number of individuals wrapped
Wrap Count & Invalid Individuals
http://find/8/2/2019 Grammatical Evo
117/126
Figure: Number of individuals wrapped on the symbolic regression and SantaFe trail problems.
(University of Limerick) Grammatical Evolution 8th July 2006 72 / 81
Wrapping Number of individuals wrapped
Wrapping and Invalid Individuals
http://find/http://goback/8/2/2019 Grammatical Evo
118/126
Figure: The number of invalid individuals for each generation in the presenceand absence of wrapping.
(University of Limerick) Grammatical Evolution 8th July 2006 73 / 81
Wrapping Performance
Performance
Freq. of Success
http://find/http://goback/8/2/2019 Grammatical Evo
119/126
Figure: Figure shows the cumulative frequency of success measures on bothproblems with and without the presence of wrapping.
(University of Limerick) Grammatical Evolution 8th July 2006 74 / 81
Wrapping Genome Lengths
Lengths (Some Definitions)
http://find/http://goback/8/2/2019 Grammatical Evo
120/126
Actual length
Entire length of individual
Effective length
Number of codons used
(Note! Can be less than or greater than actual length)
(University of Limerick) Grammatical Evolution 8th July 2006 75 / 81
Wrapping Genome Lengths
Genome Lengths
http://find/http://goback/8/2/2019 Grammatical Evo
121/126
(University of Limerick) Grammatical Evolution 8th July 2006 76 / 81
Wrapping Summary
Summary
http://find/http://goback/8/2/2019 Grammatical Evo
122/126
For SR (left) wrapping off has the longest actual length
Effective length virtually the same
For SF (right) wrapping on longer in both cases.
Conclusions:
Wrapping improves frequency of success on Santa Fe ant trailNo effect on Symbolic Regression cumulative frequencyProvides some constraint on genome lengths
(University of Limerick) Grammatical Evolution 8th July 2006 77 / 81
Wrapping Wrapping & Degeneracy
Wrapping & Degeneracy
http://find/8/2/2019 Grammatical Evo
123/126
Removing both....
Cumulative frequency of success degradesGenome lengths increase over 60% on Symbolic RegressionGenetic diversity no worse than without degeneracy alone
(University of Limerick) Grammatical Evolution 8th July 2006 78 / 81
Search Techniques Other Algorithms
Search Techniques
http://find/http://goback/8/2/2019 Grammatical Evo
124/126
Other techniques
Simulated AnnealingHill ClimbingRandom Search
(University of Limerick) Grammatical Evolution 8th July 2006 79 / 81
Search Techniques Comparison
Comparison
Three standard GP problems
http://find/http://goback/8/2/2019 Grammatical Evo
125/126
Santa Fe trailSymbolic Integration (integrate Cos(x) + 2x + 1)Symbolic regression x4 + x3 + x2 + x
Metaheuristic
Problem RS HC SA GASanta Fe 54% 7% 14% 81%
Symbolic Integration 66% 4% 3% 100%
Symbolic Regression 0% 0% 0% 59%
(University of Limerick) Grammatical Evolution 8th July 2006 80 / 81
The Future
The Future
http://find/http://goback/8/2/2019 Grammatical Evo
126/126
The Grammar (Attribute Grammars)
Search & Evolutionary Dynamics
Applications
Newest Code Release
http://waldo.csisdmz.ul.ie/libGE/
(University of Limerick) Grammatical Evolution 8th July 2006 81 / 81
http://find/