Developing a Generic Genetic Algorithm Melvin Neville Anaika

  • Slides: 38
Download presentation
Developing a Generic Genetic Algorithm Melvin Neville & Anaika Sibley Northern Arizona University Flagstaff,

Developing a Generic Genetic Algorithm Melvin Neville & Anaika Sibley Northern Arizona University Flagstaff, AZ 86011 9/25/2020 Neville & Sibley: SIGAda Houston 1

Introduction n Melvin Neville, CSE faculty – Artificial Life • Evolution of intelligence •

Introduction n Melvin Neville, CSE faculty – Artificial Life • Evolution of intelligence • Biological neural net modeling n Anaika Sibley, CSE student – ASCI-PALS research (DOE) 9/25/2020 Neville & Sibley: SIGAda Houston 2

Introduction n CSE 470: Introduction to Intelligent Systems – Neural Nets, Fuzzy Logic, Genetic

Introduction n CSE 470: Introduction to Intelligent Systems – Neural Nets, Fuzzy Logic, Genetic Algorithms – Building tools 9/25/2020 Neville & Sibley: SIGAda Houston 3

Outline n Introduction: Who we are and context n Genetic and Evolutionary Algorithms –

Outline n Introduction: Who we are and context n Genetic and Evolutionary Algorithms – Biological analogies – Genetic vs Evolutionary Algorithms – Our version – Sine function model n Conclusions: 9/25/2020 algorithm, teaching, Ada Neville & Sibley: SIGAda Houston 4

Genetic and Evolutionary Algorithms: Biological Analogies n Biological inspiration: evolution and Mendelian genetics n

Genetic and Evolutionary Algorithms: Biological Analogies n Biological inspiration: evolution and Mendelian genetics n Gene and Allele – Parameter variations n Chromosome – Linkage among parameters n Mutation – Allele alterations n Crossover – evading local minima 9/25/2020 Neville & Sibley: SIGAda Houston 5

Biological Analogies n Biological inspiration: evolution and Mendelian genetics n Evolution: – Selection and

Biological Analogies n Biological inspiration: evolution and Mendelian genetics n Evolution: – Selection and “fitness” – Role of chance? – Problem of local minima (maxima) 9/25/2020 Neville & Sibley: SIGAda Houston 6

Biological Analogies Chromosomes and Genes 9/25/2020 Neville & Sibley: SIGAda Houston 7

Biological Analogies Chromosomes and Genes 9/25/2020 Neville & Sibley: SIGAda Houston 7

Biological Analogies and Crossover 9/25/2020 Neville & Sibley: SIGAda Houston 8

Biological Analogies and Crossover 9/25/2020 Neville & Sibley: SIGAda Houston 8

Biological Analogies n Evolutionary Paradigm: The cycle – Selection among variants – “More fit”:

Biological Analogies n Evolutionary Paradigm: The cycle – Selection among variants – “More fit”: Better chance to survive to reproduce – Their alleles more represented – Mutation and crossover increase variation 9/25/2020 Neville & Sibley: SIGAda Houston 9

Genetic vs Evolutionary Algorithms n Major distinctions per Michalewicz – Representation: • GA: Bit

Genetic vs Evolutionary Algorithms n 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 9/25/2020 Neville & Sibley: SIGAda Houston 10

Genetic vs Evolutionary Algorithms n Major distinctions per Michalewicz (cont. ) – Timing of

Genetic vs Evolutionary Algorithms n 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 9/25/2020 Neville & Sibley: SIGAda Houston 11

Genetic vs Evolutionary Algorithms n Major distinctions per Michalewicz (cont. ) – Handling “illegal”

Genetic vs Evolutionary Algorithms n Major distinctions per Michalewicz (cont. ) – Handling “illegal” offspring: • GA: Penalize re fitness • ES: Discard or Impossible 9/25/2020 Neville & Sibley: SIGAda Houston 12

Our Version n Our algorithm: – 1. Initialize the generation counter to 0 –

Our Version n Our algorithm: – 1. Initialize the generation counter to 0 – 2. Initialize the population of entities – 3. Iterate through generations until some stopping criterion met 9/25/2020 Neville & Sibley: SIGAda Houston 13

Our Version n Our algorithm: – 3. Iterate through generations • • • 9/25/2020

Our Version n Our algorithm: – 3. Iterate through generations • • • 9/25/2020 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 n Our – – – parameters and data structures: Num. Win Child.

Our Version n Our – – – parameters and data structures: Num. Win Child. Per. Winners list Children list Priority. Queue 9/25/2020 Neville & Sibley: SIGAda Houston 15

Our Version n Our parameters and data structures: mutate (3. 3) (2) init Winners

Our Version n 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) select Priority Queue 9/25/2020 Neville & Sibley: SIGAda Houston 16

The Sine Function Model n Taylor’s series: f(y+h) = h 0 f(y)/0! + h

The Sine Function Model n Taylor’s series: f(y+h) = h 0 f(y)/0! + h 1 f’(y)/1! + h 2 f’’(y)/2! + h 3 f’’’(y)/3! + h 4 f’’’’(y)/4! + … n Sine series: sin x = x 1/1! – x 3/3! + x 5/5! – x 7/7! + … 9/25/2020 Neville & Sibley: SIGAda Houston 17

The Sine Function Model n Problem: to “evolve” the coefficients of the Sine Series

The Sine Function Model n Problem: to “evolve” the coefficients of the Sine Series n Subproblems: – Initial coefficient values? – Evaluation of “fitness”? – Interpretation of mutation? – Interpretation of crossover? 9/25/2020 Neville & Sibley: SIGAda Houston 18

The Sine Function Model n Initial coefficient values? – Set to zero (they go

The Sine Function Model n Initial coefficient values? – Set to zero (they go in both directions) 9/25/2020 Neville & Sibley: SIGAda Houston 19

The Sine Function Model n Evaluation of fitness? – Formula: Coefficients evaluated every N

The Sine Function Model n 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 9/25/2020 Neville & Sibley: SIGAda Houston 20

The Sine Function Model n Evaluation of fitness? – Evaluation with “perfect” coefficients: 0.

The Sine Function Model n 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 9/25/2020 Neville & Sibley: SIGAda Houston 21

The Sine Function Model n Interpretation of mutation? – 0. . multiple genes can

The Sine Function Model n 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 9/25/2020 Neville & Sibley: SIGAda Houston 22

The Sine Function Model n Interpretation of crossover? – Random choice of organisms involved

The Sine Function Model n Interpretation of crossover? – Random choice of organisms involved – Random choice of pairings – Random choice of single point of breakage 9/25/2020 Neville & Sibley: SIGAda Houston 23

Lessons Learned: The Algorithm n Parameters of run: – Num. Win = 20 Winners,

Lessons Learned: The Algorithm n Parameters of run: – Num. Win = 20 Winners, Child. Per. Win = 20 – 20000 maximum cycles n Eval at end: 0. 000456 (start: 9. 5000) n Coefs: 0 => -0. 0000000 1 => 0. 9500000 2 => 0. 0600000 3 => -0. 1360000 9/25/2020 Neville & Sibley: SIGAda Houston 1. 0000000 0. 0000000 -0. 1666667 24

Lessons Learned: Parameters n Change the Parameter Values – Vary the number of Winners

Lessons Learned: Parameters n Change the Parameter Values – Vary the number of Winners – Vary the number of Children n Create Multiple Runs n Graph Results 9/25/2020 Neville & Sibley: SIGAda Houston 25

Seven Differing Runs 9/25/2020 Neville & Sibley: SIGAda Houston 26

Seven Differing Runs 9/25/2020 Neville & Sibley: SIGAda Houston 26

Seven Differing Children 9/25/2020 Neville & Sibley: SIGAda Houston 27

Seven Differing Children 9/25/2020 Neville & Sibley: SIGAda Houston 27

Lessons Learned: The Algorithm n Breakdown Angle (deg) 0 5 10 30 60 90

Lessons Learned: The Algorithm n Breakdown Angle (deg) 0 5 10 30 60 90 9/25/2020 of the evaluation: 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 n Need to change deltas n Need to shake free

Lessons Learned: The Algorithm n Need to change deltas n Need to shake free of local minima – Change crossover mechanism? – Alter population sizes? n Domain 9/25/2020 knowledge very important Neville & Sibley: SIGAda Houston 29

Lessons Learned: Ada n Hard typing n Linked-list structure n Generics 9/25/2020 Neville &

Lessons Learned: Ada n Hard typing n Linked-list structure n Generics 9/25/2020 Neville & Sibley: SIGAda Houston 30

Lessons Learned: Ada n Hard typing: – Student reaction (C++ and Java) – The

Lessons Learned: Ada n Hard typing: – Student reaction (C++ and Java) – The compiler as (stern) friend 9/25/2020 Neville & Sibley: SIGAda Houston 31

Lessons Learned: Ada n Linked-list Updating problem: Node contents = pointer (thru Get. Contents())

Lessons Learned: Ada n Linked-list Updating problem: Node contents = pointer (thru Get. Contents()) Node Contents Real_Contents 9/25/2020 Node Contents Real_Contents Neville & Sibley: SIGAda Houston 32

Lessons Learned: Ada n Linked-list Updating problem: Copy node contents (thru Get/Set. Contents()) Get.

Lessons Learned: Ada n Linked-list Updating problem: Copy node contents (thru Get/Set. Contents()) Get. Contents() Node Contents 9/25/2020 Copy of Contents Update fields Set. Contents() Neville & Sibley: SIGAda Houston 33

Lessons Learned: Ada n Linked-list Updating problem: Direct access to (non-encapsulated) Contents Node Contents

Lessons Learned: Ada n Linked-list Updating problem: Direct access to (non-encapsulated) Contents Node Contents 9/25/2020 Neville & Sibley: SIGAda Houston 34

Lessons Learned: Ada n Generics: – Powerful but complicated – Allow tying together complicated

Lessons Learned: Ada n Generics: – Powerful but complicated – Allow tying together complicated instantiation relationships – (see paper) 9/25/2020 Neville & Sibley: SIGAda Houston 35

Conclusions n Genetic Algorithms potentially powerful n Final results may be stall at local

Conclusions n Genetic Algorithms potentially powerful n Final results may be stall at local minimum n Domain knowledge important n Ada: definite strengths n Ada: particular problems 9/25/2020 Neville & Sibley: SIGAda Houston 36

The Sine Function Model n Taylor’s series: f(y+h) = h 0 f(y)/0! + h

The Sine Function Model n Taylor’s series: f(y+h) = h 0 f(y)/0! + h 1 f’(y)/1! + h 2 f’’(y)/2! + h 3 f’’’(y)/3! + h 4 f’’’’(y)/4! + … n Euler’s formula: eix = cos x + i sin x n Substitute: – Euler’s formula with y=z, h=ix => eixez – Evaluate at z = 0 9/25/2020 Neville & Sibley: SIGAda Houston 37

The Sine Function Model n Substitute: f(z + ix)z=0 = cos x + i

The Sine Function Model n Substitute: f(z + ix)z=0 = cos x + i sin x = (ix)0 ez/0! + (ix)1 ez/1! + (ix)2 ez/2! – (ix)3 ez/3! + (ix)4 ez/4! + … sin(x) = i-terms = x 1/1! – x 3/3! + x 5/5! - … 9/25/2020 Neville & Sibley: SIGAda Houston 38