380 likes | 568 Views
Developing a Generic Genetic Algorithm. Melvin Neville & Anaika Sibley Northern Arizona University Flagstaff, AZ 86011. Introduction. Melvin Neville, CSE faculty Artificial Life Evolution of intelligence Biological neural net modeling Anaika Sibley, CSE student ASCI-PALS research (DOE).
E N D
Developing a Generic Genetic Algorithm Melvin Neville & Anaika Sibley Northern Arizona University Flagstaff, AZ 86011 Neville & Sibley: SIGAda Houston
Introduction • Melvin Neville, CSE faculty • Artificial Life • Evolution of intelligence • Biological neural net modeling • Anaika Sibley, CSE student • ASCI-PALS research (DOE) Neville & Sibley: SIGAda Houston
Introduction • CSE 470: Introduction to Intelligent Systems • Neural Nets, Fuzzy Logic, Genetic Algorithms • Building tools Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
Biological Analogies • Biological inspiration: evolution and Mendelian genetics • Evolution: • Selection and “fitness” • Role of chance? • Problem of local minima (maxima) Neville & Sibley: SIGAda Houston
Biological Analogies Chromosomes and Genes Neville & Sibley: SIGAda Houston
Biological Analogies and Crossover Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
Genetic vs Evolutionary Algorithms • Major distinctions per Michalewicz (cont.) • Handling “illegal” offspring: • GA: Penalize re fitness • ES: Discard or Impossible Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
Our Version • Our algorithm: • 3. Iterate through generations • 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
Our Version • Our parameters and data structures: • NumWin • ChildPerWin • Winners list • Children list • PriorityQueue Neville & Sibley: SIGAda Houston
Our Version • Our parameters and data structures: mutate cross eval (2) init (3.3) (3.4) (3.5) (3.2) create children to next generation (3.6) (3.6) select Winners list Children list Priority Queue Neville & Sibley: SIGAda Houston
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! + … Neville & Sibley: SIGAda Houston
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? Neville & Sibley: SIGAda Houston
The Sine Function Model • Initial coefficient values? • Set to zero (they go in both directions) Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
The Sine Function Model • Interpretation of crossover? • Random choice of organisms involved • Random choice of pairings • Random choice of single point of breakage Neville & Sibley: SIGAda Houston
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 1.0000000 2 => 0.0600000 0.0000000 3 => -0.1360000 -0.1666667 Neville & Sibley: SIGAda Houston
Lessons Learned: Parameters • Change the Parameter Values • Vary the number of Winners • Vary the number of Children • Create Multiple Runs • Graph Results Neville & Sibley: SIGAda Houston
Seven Differing Runs Neville & Sibley: SIGAda Houston
Seven Differing Children Neville & Sibley: SIGAda Houston
Lessons Learned: The Algorithm • Breakdown of the evaluation: Angle (deg) Evolved sin Library sin 0 0.0000 0.0000 5 0.0833 0.0872 10 0.1669 0.1736 30 0.4921 0.5000 60 0.8691 0.8660 90 1.0015 1.000028 Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Hard typing • Linked-list structure • Generics Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Hard typing: • Student reaction (C++ and Java) • The compiler as (stern) friend Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Linked-list Updating problem: Node contents = pointer (thru GetContents()) Node Node Contents Contents Real_Contents Real_Contents Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Linked-list Updating problem: Copy node contents (thru Get/SetContents()) Update fields GetContents() Copy of Contents SetContents() Node Contents Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Linked-list Updating problem: Direct access to (non-encapsulated) Contents Node Contents Neville & Sibley: SIGAda Houston
Lessons Learned: Ada • Generics: • Powerful but complicated • Allow tying together complicated instantiation relationships • (see paper) Neville & Sibley: SIGAda Houston
Conclusions • Genetic Algorithms potentially powerful • Final results may be stall at local minimum • Domain knowledge important • Ada: definite strengths • Ada: particular problems Neville & Sibley: SIGAda Houston
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 Neville & Sibley: SIGAda Houston
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! - … Neville & Sibley: SIGAda Houston