Transcript Document
Developing a Generic
Genetic Algorithm
Melvin Neville & Anaika Sibley
Northern Arizona University
Flagstaff, AZ 86011
7/20/2015
Neville & Sibley: SIGAda Houston
1
Introduction
Melvin Neville, CSE faculty
– Artificial Life
• Evolution of intelligence
• Biological neural net modeling
Anaika Sibley, CSE student
– ASCI-PALS research (DOE)
7/20/2015
Neville & Sibley: SIGAda Houston
2
Introduction
CSE 470: Introduction to Intelligent
Systems
– Neural Nets, Fuzzy Logic, Genetic
Algorithms
– Building tools
7/20/2015
Neville & Sibley: SIGAda Houston
3
Outline
Introduction: Who we are and context
Genetic and Evolutionary Algorithms
– Biological analogies
– Genetic vs Evolutionary Algorithms
– Our version
– Sine function model
Conclusions: algorithm, teaching, Ada
7/20/2015
Neville & Sibley: SIGAda Houston
4
Genetic and Evolutionary
Algorithms: Biological Analogies
Biological inspiration: evolution and
Mendelian genetics
Gene and Allele – Parameter variations
Chromosome – Linkage among
parameters
Mutation – Allele alterations
Crossover – evading local minima
7/20/2015
Neville & Sibley: SIGAda Houston
5
Biological Analogies
Biological inspiration: evolution and
Mendelian genetics
Evolution:
– Selection and “fitness”
– Role of chance?
– Problem of local minima (maxima)
7/20/2015
Neville & Sibley: SIGAda Houston
6
Biological Analogies
Chromosomes and Genes
Biological View
A B C D E
GA view
F G H
chromosome 1
a
b
c d
e
chromosome 2
7/20/2015
organism 1
f
g
h
organism 2
Neville & Sibley: SIGAda Houston
7
Biological Analogies
and Crossover
Biological View
A B C D E
chromosome 1
a
b
c d
e
chromosome 2
7/20/2015
GA view
f
g
h
organism 1
F G
H
organism 2
Neville & Sibley: SIGAda Houston
8
Biological Analogies
Evolutionary Paradigm: The cycle
– Selection among variants
– “More fit”: Better chance to survive to
reproduce
– Their alleles more represented
– Mutation and crossover increase variation
7/20/2015
Neville & Sibley: SIGAda Houston
9
Genetic vs Evolutionary
Algorithms
Major distinctions per Michalewicz
– Representation:
• GA: Bit vector
• ES: Floating-point vector
– Selection:
• GA: Repetitive random selection with fitness
influence
• ES: Fitness function without replacement
7/20/2015
Neville & Sibley: SIGAda Houston
10
Genetic vs Evolutionary
Algorithms
Major distinctions per Michalewicz (cont.)
– Timing of mutation and crossover:
• GA: After next generation selected
• ES: Before next generation selected
– Probabilities of mutation and crossover:
• GA: Constant
• ES: Can alter from generation to generation
7/20/2015
Neville & Sibley: SIGAda Houston
11
Genetic vs Evolutionary
Algorithms
Major distinctions per Michalewicz (cont.)
– Handling “illegal” offspring:
• GA: Penalize re fitness
• ES: Discard or Impossible
7/20/2015
Neville & Sibley: SIGAda Houston
12
Our Version
Our algorithm:
– 1. Initialize the generation counter to 0
– 2. Initialize the population of entities
– 3. Iterate through generations until some
stopping criterion met
7/20/2015
Neville & Sibley: SIGAda Houston
13
Our Version
Our algorithm:
– 3. Iterate through generations
•
•
•
•
•
•
7/20/2015
3.1 Increment generation counter
3.2 Each “winner” produces same # children
3.3 Each child subject to chance mutation
3.4 Each child has chance of crossover
3.5 The children are evaluated
3.6 The most fit are selected for the next
generation (“winners”)
Neville & Sibley: SIGAda Houston
14
Our Version
Our parameters and data structures:
–
–
–
–
–
NumWin
ChildPerWin
Winners list
Children list
PriorityQueue
7/20/2015
Neville & Sibley: SIGAda Houston
15
Our Version
Our parameters and data structures:
mutate
(3.3)
(2) init
Winners list
cross eval
(3.4) (3.5)
Children list
(3.2)
create children
to next generation (3.6)
(3.6) select
Priority Queue
7/20/2015
Neville & Sibley: SIGAda Houston
16
The Sine Function Model
Taylor’s series:
f(y+h) = h0f(y)/0! + h1f’(y)/1! + h2f’’(y)/2! +
h3f’’’(y)/3! + h4f’’’’(y)/4! + …
Sine series:
sin x = x1/1! – x3/3! + x5/5! – x7/7! + …
7/20/2015
Neville & Sibley: SIGAda Houston
17
The Sine Function Model
Problem: to “evolve” the coefficients of
the Sine Series
Subproblems:
– Initial coefficient values?
– Evaluation of “fitness”?
– Interpretation of mutation?
– Interpretation of crossover?
7/20/2015
Neville & Sibley: SIGAda Houston
18
The Sine Function Model
Initial coefficient values?
– Set to zero (they go in both directions)
7/20/2015
Neville & Sibley: SIGAda Houston
19
The Sine Function Model
Evaluation of fitness?
– Formula: Coefficients evaluated every N
(5) degrees range 0 .. 90 degrees: sum
square divergences from math library sin()
– Evaluation with initial coefficients of 0.0:
9.5000
7/20/2015
Neville & Sibley: SIGAda Houston
20
The Sine Function Model
Evaluation of fitness?
– Evaluation with “perfect” coefficients:
0.0000
– The “perfect” Coefficients (power of x):
0 => 0.0000000
4 => 0.0000000
1 => 1.0000000
5 => 0.0083333
2 => 0.0000000
6 => 0.0000000
3 => -0.1666667
7 => -0.0001984
7/20/2015
Neville & Sibley: SIGAda Houston
21
The Sine Function Model
Interpretation of mutation?
– 0 .. multiple genes can be selected
– Alteration in coefficients by +/- delta-values
– Delta-coefficient file:
0 => 0.1
4 => 0.002
1 => 0.05
5 => 0.0004
2 => 0.02
6 => 0.00006
3 => 0.008
7 => 0.00001
7/20/2015
Neville & Sibley: SIGAda Houston
22
The Sine Function Model
Interpretation of crossover?
– Random choice of organisms involved
– Random choice of pairings
– Random choice of single point of breakage
7/20/2015
Neville & Sibley: SIGAda Houston
23
Lessons Learned: The Algorithm
Parameters of run:
– NumWin = 20 Winners, ChildPerWin = 20
– 20000 maximum cycles
Eval at end: 0.000456 (start: 9.5000)
Coefs: 0 => -0.0000000
-0.0000000
1 => 0.9500000
2 => 0.0600000
3 => -0.1360000
7/20/2015
Neville & Sibley: SIGAda Houston
1.0000000
0.0000000
-0.1666667
24
Lessons Learned: Parameters
Change the Parameter Values
– Vary the number of Winners
– Vary the number of Children
Create Multiple Runs
Graph Results
7/20/2015
Neville & Sibley: SIGAda Houston
25
Seven Differing Runs
7/20/2015
Neville & Sibley: SIGAda Houston
26
Seven Differing Children
7/20/2015
Neville & Sibley: SIGAda Houston
27
Lessons Learned: The Algorithm
Breakdown of the evaluation:
Angle (deg)
0
5
10
30
60
90
7/20/2015
Evolved sin
0.0000
0.0833
0.1669
0.4921
0.8691
1.0015
Neville & Sibley: SIGAda Houston
Library sin
0.0000
0.0872
0.1736
0.5000
0.8660
1.000028
28
Lessons Learned: The Algorithm
Need to change deltas
Need to shake free of local minima
– Change crossover mechanism?
– Alter population sizes?
Domain knowledge very important
7/20/2015
Neville & Sibley: SIGAda Houston
29
Lessons Learned: Ada
Hard typing
Linked-list structure
Generics
7/20/2015
Neville & Sibley: SIGAda Houston
30
Lessons Learned: Ada
Hard typing:
– Student reaction (C++ and Java)
– The compiler as (stern) friend
7/20/2015
Neville & Sibley: SIGAda Houston
31
Lessons Learned: Ada
Linked-list Updating problem:
Node contents = pointer (thru GetContents())
Node
Contents
Real_Contents
7/20/2015
Node
Contents
Real_Contents
Neville & Sibley: SIGAda Houston
32
Lessons Learned: Ada
Linked-list Updating problem:
Copy node contents (thru Get/SetContents())
GetContents()
Node
Contents
7/20/2015
Copy of
Contents
Update fields
SetContents()
Neville & Sibley: SIGAda Houston
33
Lessons Learned: Ada
Linked-list Updating problem:
Direct access to (non-encapsulated) Contents
Node
Contents
7/20/2015
Neville & Sibley: SIGAda Houston
34
Lessons Learned: Ada
Generics:
– Powerful but complicated
– Allow tying together complicated instantiation
relationships
– (see paper)
7/20/2015
Neville & Sibley: SIGAda Houston
35
Conclusions
Genetic Algorithms potentially powerful
Final results may be stall at local
minimum
Domain knowledge important
Ada: definite strengths
Ada: particular problems
7/20/2015
Neville & Sibley: SIGAda Houston
36
The Sine Function Model
Taylor’s series:
f(y+h) = h0f(y)/0! + h1f’(y)/1! + h2f’’(y)/2! +
h3f’’’(y)/3! + h4f’’’’(y)/4! + …
Euler’s formula:
eix = cos x + i sin x
Substitute:
– Euler’s formula with y=z,h=ix => eixez
– Evaluate at z = 0
7/20/2015
Neville & Sibley: SIGAda Houston
37
The Sine Function Model
Substitute:
f(z + ix)z=0 = cos x + i sin x =
(ix)0ez/0! + (ix)1ez/1! + (ix)2ez/2! –
(ix)3ez/3! + (ix)4ez/4! + …
sin(x) = i-terms = x1/1! – x3/3! + x 5/5! - …
7/20/2015
Neville & Sibley: SIGAda Houston
38