Professional Documents
Culture Documents
GENETIC PROGRAMMING
John R. Koza
Consulting Professor (Medical Informatics)
Department of Medicine
School of Medicine
Consulting Professor
Department of Electrical Engineering
School of Engineering
Stanford University
Stanford, California 94305
koza@stanford.edu
http://www.smi.stanford.edu/people/koza/
DEFINITION OF THE GENETIC
ALGORITHM (GA)
Generation 0 Generation 1
011 $3 111
001 $1 010
110 $6 110
010 $2 010
HAMBURGER RESTAURANT
PROBLEM
• Price
1 = $ 0.50 price
0 = $10.00 price
• Drink
1 = Coca Cola
0 = Wine
• Ambiance
1 = Fast snappy service
0 = Leisurely service with tuxedoed waiter
CHROMOSOME (GENOME) OF THE
GLOBAL OPTIMUM
McDONALD's
1 1 1
THE SEARCH SPACE
1 000
2 001
3 010
4 011
5 100
6 101
7 110
8 111
Generation 0
1 011 3
2 001 1
3 110 6
4 010 2
Total
Worst
Average
Best
DEFINITION OF THE GENETIC
ALGORITHM (GA)
0.17
0.25
0.08
0.5
DARWINIAN FITNESS
PROPORTIONATE SELECTION
X1 Y1 Z1 X2 Y2 Z2 …
+0010 -1110 +0001 +0011 -1011 +0011 …
A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
0010 1110 0001 0011 1011 0011 1111 0011 0011 1010
A0 A1 A2 … A127
a0 a1 a2 … a127
N M GENOME
1 1 0 1 1 1 1
1 1 1 1 0 1 1
1 0 1 1 1 0 0
1 1 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 1 0 1 1
1 1 0 1 1 1 0
GENETIC ALGORITHM USING
VARIABLE-LENGTH STRINGS
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
GP FLOWCHART
A COMPUTER PROGRAM IN C
int foo (int time)
{
int temp1, temp2;
if (time > 10)
temp1 = 3;
else
temp1 = 4;
temp2 = temp1 + 1 + 2;
return (temp2);
}
OUTPUT OF C PROGRAM
Time Output
0 6
1 6
2 6
3 6
4 6
5 6
6 6
7 6
8 6
9 6
10 6
11 7
12 7
PROGRAM TREE
• Available functions
F = {+, -, *, %, IFLTE}
• Available terminals
T = {X, Y, Random-Constants}
• The random programs are:
– Of different sizes and shapes
– Syntactically valid
– Executable
GP GENETIC OPERATIONS
• Reproduction
• Mutation
• Crossover (sexual recombination)
• Architecture-altering operations
MUTATION OPERATION
MUTATION OPERATION
Independent Dependent
variable X variable Y
-1.00 1.00
-0.80 0.84
-0.60 0.76
-0.40 0.76
-0.20 0.84
0.00 1.00
0.20 1.24
0.40 1.56
0.60 1.96
0.80 2.44
1.00 3.00
PREPARATORY STEPS
x+1 x2 + 1 2 x
GENERATION 1
Second offspring
First offspring of of crossover of
Mutant of (c) crossover of (a)
(a) and (b)
and (b) picking “+” of
Copy of (a) picking “2” picking “+” of parent (a) and
as mutation parent (a) and
point left-most “x” of
left-most “x” of parent (b) as
parent (b) as crossover points
crossover points
CLASSIFICATION
GP TABLEAU – INTERTWINED
SPIRALS
Objective: Create a program to classify a given
point in the x-y plane to the red or
blue spiral
1 Terminal set: T = {X,Y,Random-Constants}
2 Function set: F = {+,-,*,%,IFLTE,SIN,COS}
3 Fitness: The number of correctly classified
points (0 – 194)
4 Parameters: M = 10,000. G = 51
5 Termination: An individual program scores 194
WALL-FOLLOWER
FITNESS
BEST OF GENERATION 57
BOX MOVER – BEST OF GEN 0
BOX MOVER
GEN 45 – FITNESS CASE 1
TRUCK BACKER UPPER
TRUCK BACKER UPPER
• 4-Dimensional control problem
– horizontal position, x
– vertical position, y
– angle between trailer and horizontal, t
– angle between trailer and cab, d
• One control variable (steering wheel turn angle)
• State transition equations map the 4 state
variables into 1 output (the control variable)
• Simulation run over many initial conditions and
over hundreds of time steps
GENETIC PROGRAMMING: ON THE
PROGRAMMING OF COMPUTERS BY
MEANS OF NATURAL SELECTION
(Koza 1992)
2 MAIN POINTS FROM 1992 BOOK
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
COMPUTER PROGRAMS
(- (* (* W0 L0) H0)
(* (* W1 L1) H1))
DIFFERENCE IN VOLUMES
D = L0W0H0 – L1W1H1
AUTOMATICALLY DEFINED
FUNCTION volume
AUTOMATICALLY DEFINED
FUNCTION volume
(progn
(defun volume (arg0 arg1 arg2)
(values
(* arg0 (* arg1 arg2))))
(values
(- (volume L0 W0 H0)
(volume L1 W1 H1))))
AUTOMATICALLY DEFINED
FUNCTIONS
Fitness case L0 W0 H0 L1 W1 H1 V0 V1 D
1 3 4 7 2 5 3 84 30 54
2 7 10 9 10 3 1 630 30 600
3 10 9 4 8 1 6 360 48 312
4 3 9 5 1 6 4 135 24 111
5 4 3 2 7 6 1 24 42 -18
6 3 3 1 9 5 4 9 180 -171
7 5 9 9 1 7 6 405 42 363
8 1 2 9 3 9 2 18 54 -36
9 2 6 8 2 6 10 96 120 -24
10 8 1 10 7 5 1 80 35 45
DIVIDE AND CONQUER
DIVIDE AND CONQUER
• Identify regularities
• Change the representation
• Solve the overall problem
ADF IMPLEMENTATION
• Each overall program in population includes
– a main result-producing branch (RPB) and
– function-defining branch (i.e., automatically defined
function, ADF)
• In generation 0, create random programs with
different ingredients for the RPB and the ADF
– Terminal set for ADF typically contains dummy
arguments (formal parameters), such as ARG0,
ARG1, …
– Function set of the RPB contains ADF0
– ADFs are private and associated with a particular
individual program in the population
ADF MUTATION
• Stacks
• Queues
• Lists
• Rings
COMPUTER PROGRAMS
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
GENETIC PROGRAMMING III: DARWINIAN
INVENTION AND PROBLEM SOLVING
(Koza, Bennett, Andre, Keane 1999)
SUBROUTINE DUPLICATION
SUBROUTINE CREATION
SUBROUTINE DELETION
ARGUMENT DUPLICATION
ARGUMENT DELETION
16 ATTRIBUTES OF A SYSTEM FOR
AUTOMATICALLY CREATING COMPUTER
PROGRAMS
• Resistor R function
• Capacitor C function
• Inductor L function
• Diode D function
• Transistor Q function (3-leaded)
COMPONENT-CREATING FUNCTIONS
TOPOLOGY-MODIFYING FUNCTIONS
• SERIES division
• PARALLEL division
• VIA
• FLIP
TOPOLOGY-MODIFYING FUNCTIONS
DEVELOPMENT-CONTROLLING
FUNCTIONS
• END function
• NOP (No Operation) function
• SAFE_CUT function
THE INITIAL CIRCUIT
DEVELOPMENTAL GP
z0
+ IN OUT
Embryonic Circuit
Program Tree
Fitness
DESIRED BEHAVIOR OF A LOWPASS
FILTER
EVOLVED CAMPBELL FILTER
U. S. patent 1,227,113
George Campbell
American Telephone and Telegraph
1917
EVOLVED ZOBEL FILTER
U. S. patent 1,538,964
Otto Zobel
American Telephone and Telegraph Company
1925
EVOLVED SALLEN-KEY FILTER
EVOLVED DARLINGTON EMITTER-
FOLLOWER SECTION
U. S. patent 2,663,806
Sidney Darlington
Bell Telephone Laboratories
1953
NEGATIVE FEEDBACK
HAROLD BLACK’S RIDE ON THE
LACKAWANNA FERRY
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
SIX POST-2000 PATENTED
INVENTIONS
EVOLVED HIGH CURRENT LOAD CIRCUIT
REGISTER-CONTROLLED CAPACITOR
CIRCUIT
LOW-VOLTAGE CUBIC CIRCUIT
VOLTAGE-CURRENT-CONVERSION
CIRCUIT
LOW-VOLTAGE BALUN CIRCUIT
TUNABLE INTEGRATED ACTIVE FILTER
21st-CENTURY PATENTED INVENTIONS
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
NOVELTY-DRIVEN EVOLUTION
• gain • lead
• integrator • lag
• differentiator • two-parameter lag
• adder • absolute value
• subtractor • limiter
• multiplier • divider
• differential input • delay
integrators • conditional operators
• inverter (switches)
FUNCTION SET FOR
CONTROLLER SYNTHESIS
F = {GAIN,INVERTER,LEAD,LAG,LAG2,
DIFFERENTIAL_INPUT_INTEGRATOR,
DIFFERENTIATOR, ADD_SIGNAL,
SUB_SIGNAL,ADD_3_SIGNAL,ADF0,
ADF1,ADF2,ADF3,ADF4}
TERMINAL SET FOR
CONTROLLER SYNTHESIS
T = { REFERENCE_SIGNAL,
CONTROLLER_OUTPUT,
PLANT_OUTPUT}
CONSTRAINED SYNTACTIC
STRUCTURE
(PROGN3
(TURN-RIGHT 0.125)
(LANDMARK
(REPEAT 2
(PROGN2
(DRAW 1.0 HALF-MM-WIRE)
(DRAW 0.5 NO-WIRE)))
(TRANSLATE-RIGHT 0.125 0.75))
USING A TURTLE TO DRAW TWO-
DIMENSIONAL ANTENNA
BEST-OF-RUN ANTENNA FROM
GENERATION 90
3-DIMENSIONAL ANTENNA
NASA EVOLVED ANTENNA
PID tuning rules that outperform the Ziegler-Nichols and Åström-Hägglund tuning rules
General-purpose controllers outperforming Ziegler-Nichols and Åström-Hägglund rules
PROGRESSION OF QUALITATIVELY MORE
SUBSTANTIAL RESULTS PRODUCED BY GP
• Toy problems
• Human-competitive non-patent results
• 20th-century patented inventions
• 21st-century patented inventions
• Patentable new inventions
PARALLELIZATION WITH SEMI-ISOLATED
SUBPOPULATIONS
GP PARALLELIZATION
D
H G F E
EVOLVED SORTING NETWORK
GP 1987–2002
• Long neck
• Long tongue
• Vegetable-digesting enzymes in stomach
• 4 legs
• Long legs
• Brown coloration
THE DESIGN OF A GOOD GIRAFE
• Initial structure(s)
• Fitness measure
• Operations for creating new structures
• Parameters
• Termination criterion and method of
designating the result
SPACE WITH MANY LOCAL OPTIMA
SEARCH METHODS
Biologically inspired
TURING (1948)
LOGIC-BASED SEARCH
CULTURAL SEARCH
GENETICAL OR EVOLUTIONARY
SEARCH