SlideShare a Scribd company logo
The Standard Genetic Algorithm Dr. Chrisantha Fernando Systems Biology Centre University of Birmingham
DIY Evolution.
Genotype Binary String Real numbered String 1101000101110101 1101011111110101 0.2, 0.5, 0.2, 0.83, 0.01, 0.3 0.6, 0.1, 0.5, 0.8, 0.9, 1.0 Represents length of  left leg.  Size of head, etc…
Evaluation  Interpret the genotype to produce the phenotype.  In the simplest case they are the same thing.  E.g. Imagine we desire the string  000000000 We can define  fitness   of any string as the number of places where it is the same as the above string, e.g.  000000000 010101010 ------------- 101010101 = 5 = Fitness
A Trivial Example int evaluate(int *g) { int i, r=0; for (i=0;i<10;i++)  r += (g(i) == 0); return(r); } I. Harvey
So first initialize a population int popn[30][10]; void initialise_popn() { int i,j; for (i=0;i<30;i++) for (j=0;j<10;j++) popn[i][j]= flip_a_bit(); } I. Harvey
Main Loop For n times round generation loop evaluate all the population (of 30) select preferentially the fitter ones as parents for 30 times round repro loop pick 2 from parental pool recombine to make 1 offspring mutate the offspring end repro loop throw away parental generation and replace with offspring End generation loop I. Harvey
More complicated Evaluations Genotype encodes a neural network.  Dario Floreano’s Lab
Even More Complicated Evaluations
Problems in Practice An evaluation may take a long time, in which case the genetic algorithm will be slow.  An evaluation may be noisy, so the same agent may have different fitness each time you make an evaluation. If it is too noisy, then good agents may be lost from the population.
Selection Methods Truncation Selection  All parents come from top 50% or top 20% etc.. Fitness Proportionate Selection E.g. if all fitnesses are 2, 4, 6, 8, 9, then select parent using roulette wheel selection with probability 2/29, 4/29, 6/29, 8/29, 9/29 Problems with this are  If early on one agent dominates there is too much selective pressure.  If later agents have very similar fitnesses there is too little selective pressure. Scaling methods can be used to get around these problems.
Rank Selection: Ignore absolute fitness, can use other slopes, but here the best is selected 2x more than the average.  0 2
Elitism Force a direct un-mutated copy of the best of the last generation.  Never loose the best.  Useful if there is a lot of noise in fitness assessments, or if mutation is very likely to produce a low fitness offspring.
Mutation (Asexual Reproduction) Mutate at randomly chosen loci with a small probability.  Mutate all loci by a very small amount (vector mutation).  With binary  you do bit flips, with real valued mutation you might multiply the value by a Gaussian distributed random number.
Recombination (Sexual Reproduction) 10100010 000111 00000011 101111 Parent A Parent B 10100010101111 00000011000111 1-point random equal crossover 0 01 0001 01 00111 Uniform crossover
The Competing Conventions Problem Head, Eye, Face, Leg Face, Eye, Leg, Head Head, Eye, Face,  Head Face, Eye, Leg,  Leg OK, so two heads, and two  legs. Sometimes competing conventions can help, some- times it can hinder.
Schema Theorem John Holland.  A theory of how GAs work. Not everyone agrees with this, but it is worth reading his book if you are interested.
A Black Art No universal algorithm suitable for all cases.  Need to get a feeling for it by doing it.
Relationship to Real Genomes Usually GAs use haploid genomes, not diploid ones, i.e. there is only one copy of each ‘gene’.
Homework. I’m happy to help if you need.  [email_address] The Card Problem You have 10 cards numbered from 1 to 10. You have to choose a way of dividing them into 2 piles, so that the cards in Pile_0 SUM to a number as close as possible to 36, and the remaining cards in Pile_1 MULTIPLY to a number as close as possible to 360. Genotype encoding Each card can be in Pile_0 or Pile_1, there are 1024 possible ways of sorting them into 2 piles, and you have to find the best. Think of a sensible way of encoding any possible solution-attempt as a genotype. Fitness Some of these solution-attempts will be closer to the target than others. Think of a sensible way of evaluating any solution-attempt and scoring it with a fitness-measure. The GA Write a program, in any sensible programming language, to run a GA with your genotype encoding and Fitness function. Run it 100 times and see what results you get. Who can write the GA that solves the problem in the least number of generations?

More Related Content

ODP
Improving and Scaling Evolutionary Approaches to the MasterMind Problem
PDF
Mt Campbell
PDF
Workshop: Making the Best of the YouTube-Age
PPT
Leveraging On-Demand Compensation Management In A Global Environment
PPT
Do students with learning differences really need an i pad (1)
PPT
Living Labs for Territorial Innovation
PDF
The Amazon Basin - a Contested Landscape
PDF
ケーズホールディングス 経営の特徴「がんばらない経営」
Improving and Scaling Evolutionary Approaches to the MasterMind Problem
Mt Campbell
Workshop: Making the Best of the YouTube-Age
Leveraging On-Demand Compensation Management In A Global Environment
Do students with learning differences really need an i pad (1)
Living Labs for Territorial Innovation
The Amazon Basin - a Contested Landscape
ケーズホールディングス 経営の特徴「がんばらない経営」

Viewers also liked (20)

PPT
Sess_39_NAMCS&NHAMCS_hands-on_SCHAPPERT
PPT
xreferplus-dereksturdy
PDF
Comet: Making The Web a 2-Way Medium
PPT
Decimal Review
PPT
Silverlight For Students
PPT
Tips For Reading Oedipus
PPT
Ya aprendimos - Coalicion civica
PDF
PPT
Breidamerkurjokull Maps from Glasgow University
PPT
Lancering digitale collectie (2012-06-28)
PPT
Glaciation - the landscape of ablation
PPT
教案與教材設計
PDF
Marco T. Giordano, Identità Digitale e Reputazione Online – Pt. 2
KEY
EdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
PPT
Illusioni
PPTX
Navigating GeoJuice
PDF
TV Hackday - Opportunities
PPT
TLL Sicily: Building Partnerships for Territorial Living Labs for
PPTX
Vergani, RGW 2011 1
Sess_39_NAMCS&NHAMCS_hands-on_SCHAPPERT
xreferplus-dereksturdy
Comet: Making The Web a 2-Way Medium
Decimal Review
Silverlight For Students
Tips For Reading Oedipus
Ya aprendimos - Coalicion civica
Breidamerkurjokull Maps from Glasgow University
Lancering digitale collectie (2012-06-28)
Glaciation - the landscape of ablation
教案與教材設計
Marco T. Giordano, Identità Digitale e Reputazione Online – Pt. 2
EdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
Illusioni
Navigating GeoJuice
TV Hackday - Opportunities
TLL Sicily: Building Partnerships for Territorial Living Labs for
Vergani, RGW 2011 1
Ad

Similar to GeneticAlgorithm (20)

PPTX
Genetic algorithm optimization technique.pptx
PPT
Evolutionary algorithms
PPT
PPT
Genetic algorithms
PPT
Genetic algorithms
PPTX
PDF
Soft Computing- Dr. H.s. Hota 28.08.14.pdf
PPTX
GA of a Paper 2012.pptx
PPT
Genetic algorithm
PPTX
Genetic Algorithm
PPTX
introduction of genetic algorithm
PDF
Genetic Algorithms in Artificial Intelligence
PPT
Soft computing06
PDF
Solving non linear programming minimization problem using genetic algorithm
PDF
Lec 7 genetic algorithms
PPTX
Genetic Algorithm
PDF
Practical Genetic Algorithms
PPTX
Genetic Algorithm
PDF
Genetic algorithm in Artificial Intelligence with example
PPTX
Introduction to Genetic algorithm
Genetic algorithm optimization technique.pptx
Evolutionary algorithms
Genetic algorithms
Genetic algorithms
Soft Computing- Dr. H.s. Hota 28.08.14.pdf
GA of a Paper 2012.pptx
Genetic algorithm
Genetic Algorithm
introduction of genetic algorithm
Genetic Algorithms in Artificial Intelligence
Soft computing06
Solving non linear programming minimization problem using genetic algorithm
Lec 7 genetic algorithms
Genetic Algorithm
Practical Genetic Algorithms
Genetic Algorithm
Genetic algorithm in Artificial Intelligence with example
Introduction to Genetic algorithm
Ad

More from guestfbf1e1 (11)

PPT
xrefer-lightowlers
PPT
unusualevent
PPT
training_tuftspma
PPT
20070612150756-0
PPT
DesmedtXSB
PPT
dorsdl2006-arrow
PPT
Joseph-Smarr-Plaxo-OSCON-2006
PPT
kevin_mcmahon_power_point_slides
PPT
WLCG-Discu
PPT
PPT
LearningProgressionstoELit_Anderson
xrefer-lightowlers
unusualevent
training_tuftspma
20070612150756-0
DesmedtXSB
dorsdl2006-arrow
Joseph-Smarr-Plaxo-OSCON-2006
kevin_mcmahon_power_point_slides
WLCG-Discu
LearningProgressionstoELit_Anderson

Recently uploaded (20)

PDF
Mathematical Economics 23lec03slides.pdf
PPTX
FL INTRODUCTION TO AGRIBUSINESS CHAPTER 1
PPTX
Introduction to Managemeng Chapter 1..pptx
PDF
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
PDF
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
PPTX
Unilever_Financial_Analysis_Presentation.pptx
PPTX
Session 3. Time Value of Money.pptx_finance
PPTX
Session 14-16. Capital Structure Theories.pptx
PDF
Buy Verified Stripe Accounts for Sale - Secure and.pdf
PPTX
The discussion on the Economic in transportation .pptx
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PDF
caregiving tools.pdf...........................
PDF
Lecture1.pdf buss1040 uses economics introduction
PDF
Copia de Minimal 3D Technology Consulting Presentation.pdf
PDF
Understanding University Research Expenditures (1)_compressed.pdf
PDF
5a An Age-Based, Three-Dimensional Distribution Model Incorporating Sequence ...
PDF
Unkipdf.pdf of work in the economy we are
PPTX
Antihypertensive_Drugs_Presentation_Poonam_Painkra.pptx
PDF
CLIMATE CHANGE AS A THREAT MULTIPLIER: ASSESSING ITS IMPACT ON RESOURCE SCARC...
PPT
E commerce busin and some important issues
Mathematical Economics 23lec03slides.pdf
FL INTRODUCTION TO AGRIBUSINESS CHAPTER 1
Introduction to Managemeng Chapter 1..pptx
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
Unilever_Financial_Analysis_Presentation.pptx
Session 3. Time Value of Money.pptx_finance
Session 14-16. Capital Structure Theories.pptx
Buy Verified Stripe Accounts for Sale - Secure and.pdf
The discussion on the Economic in transportation .pptx
ECONOMICS AND ENTREPRENEURS LESSONSS AND
caregiving tools.pdf...........................
Lecture1.pdf buss1040 uses economics introduction
Copia de Minimal 3D Technology Consulting Presentation.pdf
Understanding University Research Expenditures (1)_compressed.pdf
5a An Age-Based, Three-Dimensional Distribution Model Incorporating Sequence ...
Unkipdf.pdf of work in the economy we are
Antihypertensive_Drugs_Presentation_Poonam_Painkra.pptx
CLIMATE CHANGE AS A THREAT MULTIPLIER: ASSESSING ITS IMPACT ON RESOURCE SCARC...
E commerce busin and some important issues

GeneticAlgorithm

  • 1. The Standard Genetic Algorithm Dr. Chrisantha Fernando Systems Biology Centre University of Birmingham
  • 3. Genotype Binary String Real numbered String 1101000101110101 1101011111110101 0.2, 0.5, 0.2, 0.83, 0.01, 0.3 0.6, 0.1, 0.5, 0.8, 0.9, 1.0 Represents length of left leg. Size of head, etc…
  • 4. Evaluation Interpret the genotype to produce the phenotype. In the simplest case they are the same thing. E.g. Imagine we desire the string 000000000 We can define fitness of any string as the number of places where it is the same as the above string, e.g. 000000000 010101010 ------------- 101010101 = 5 = Fitness
  • 5. A Trivial Example int evaluate(int *g) { int i, r=0; for (i=0;i<10;i++) r += (g(i) == 0); return(r); } I. Harvey
  • 6. So first initialize a population int popn[30][10]; void initialise_popn() { int i,j; for (i=0;i<30;i++) for (j=0;j<10;j++) popn[i][j]= flip_a_bit(); } I. Harvey
  • 7. Main Loop For n times round generation loop evaluate all the population (of 30) select preferentially the fitter ones as parents for 30 times round repro loop pick 2 from parental pool recombine to make 1 offspring mutate the offspring end repro loop throw away parental generation and replace with offspring End generation loop I. Harvey
  • 8. More complicated Evaluations Genotype encodes a neural network. Dario Floreano’s Lab
  • 9. Even More Complicated Evaluations
  • 10. Problems in Practice An evaluation may take a long time, in which case the genetic algorithm will be slow. An evaluation may be noisy, so the same agent may have different fitness each time you make an evaluation. If it is too noisy, then good agents may be lost from the population.
  • 11. Selection Methods Truncation Selection All parents come from top 50% or top 20% etc.. Fitness Proportionate Selection E.g. if all fitnesses are 2, 4, 6, 8, 9, then select parent using roulette wheel selection with probability 2/29, 4/29, 6/29, 8/29, 9/29 Problems with this are If early on one agent dominates there is too much selective pressure. If later agents have very similar fitnesses there is too little selective pressure. Scaling methods can be used to get around these problems.
  • 12. Rank Selection: Ignore absolute fitness, can use other slopes, but here the best is selected 2x more than the average. 0 2
  • 13. Elitism Force a direct un-mutated copy of the best of the last generation. Never loose the best. Useful if there is a lot of noise in fitness assessments, or if mutation is very likely to produce a low fitness offspring.
  • 14. Mutation (Asexual Reproduction) Mutate at randomly chosen loci with a small probability. Mutate all loci by a very small amount (vector mutation). With binary you do bit flips, with real valued mutation you might multiply the value by a Gaussian distributed random number.
  • 15. Recombination (Sexual Reproduction) 10100010 000111 00000011 101111 Parent A Parent B 10100010101111 00000011000111 1-point random equal crossover 0 01 0001 01 00111 Uniform crossover
  • 16. The Competing Conventions Problem Head, Eye, Face, Leg Face, Eye, Leg, Head Head, Eye, Face, Head Face, Eye, Leg, Leg OK, so two heads, and two legs. Sometimes competing conventions can help, some- times it can hinder.
  • 17. Schema Theorem John Holland. A theory of how GAs work. Not everyone agrees with this, but it is worth reading his book if you are interested.
  • 18. A Black Art No universal algorithm suitable for all cases. Need to get a feeling for it by doing it.
  • 19. Relationship to Real Genomes Usually GAs use haploid genomes, not diploid ones, i.e. there is only one copy of each ‘gene’.
  • 20. Homework. I’m happy to help if you need. [email_address] The Card Problem You have 10 cards numbered from 1 to 10. You have to choose a way of dividing them into 2 piles, so that the cards in Pile_0 SUM to a number as close as possible to 36, and the remaining cards in Pile_1 MULTIPLY to a number as close as possible to 360. Genotype encoding Each card can be in Pile_0 or Pile_1, there are 1024 possible ways of sorting them into 2 piles, and you have to find the best. Think of a sensible way of encoding any possible solution-attempt as a genotype. Fitness Some of these solution-attempts will be closer to the target than others. Think of a sensible way of evaluating any solution-attempt and scoring it with a fitness-measure. The GA Write a program, in any sensible programming language, to run a GA with your genotype encoding and Fitness function. Run it 100 times and see what results you get. Who can write the GA that solves the problem in the least number of generations?