SlideShare a Scribd company logo
23-Jun-18
Genetic Algorithms
2
Evolution
 Oversimplified description of how evolution works in biology:
 Organisms (animals or plants) produce a number of offspring
which are almost, but not entirely, like themselves
 Variation may be due to mutation (random changes)
 Variation may be due to sexual reproduction (offspring have some
characteristics from each parent)
 Some of these offspring may survive to produce offspring of their
own—some won’t
 The “better adapted” offspring are more likely to survive
 Over time, later generations become better and better adapted
 Genetic algorithms use this same process to “evolve” better
programs
3
Genotypes and phenotypes
 Genes are the basic “instructions” for building an
organism
 A chromosome is a sequence of genes
 Biologists distinguish between an organism’s genotype
(the genes and chromosomes) and its phenotype (what
the organism actually is like)
 Example: You might have genes to be tall, but never grow to
be tall for other reasons (such as poor diet)
 Similarly, “genes” may describe a possible solution to a
problem, without actually being the solution
4
The basic genetic algorithm
 Start with a large “population” of randomly generated
“attempted solutions” to a problem
 Repeatedly do the following:
 Evaluate each of the attempted solutions
 Keep a subset of these solutions (the “best” ones)
 Use these solutions to generate a new population
 Quit when you have a satisfactory solution (or you run out of time)
Conceptual Algorithm
6
A really simple example
 Suppose your “organisms” are 32-bit computer words
 You want a string in which all the bits are ones
 Here’s how you can do it:
 Create 100 randomly generated computer words
 Repeatedly do the following:
 Count the 1 bits in each word
 Exit if any of the words have all 32 bits set to 1
 Keep the ten words that have the most 1s (discard the rest)
 From each word, generate 9 new words as follows:
 Pick a random bit in the word and toggle (change) it
 Note that this procedure does not guarantee that the next
“generation” will have more 1 bits, but it’s likely
7
A more realistic example, part I
 Suppose you have a large number of (x, y) data points
 For example, (1.0, 4.1), (3.1, 9.5), (-5.2, 8.6), ...
 You would like to fit a polynomial (of up to degree 5) through
these data points
 That is, you want a formula y = ax5 + bx4 + cx3 + dx2 +ex + f that gives
you a reasonably good fit to the actual data
 Here’s the usual way to compute goodness of fit:
 Compute the sum of (actual y – predicted y)2 for all the data points
 The lowest sum represents the best fit
 There are some standard curve fitting techniques, but let’s assume
you don’t know about them
 You can use a genetic algorithm to find a “pretty good” solution
8
A more realistic example, part II
 Your formula is y = ax5 + bx4 + cx3 + dx2 +ex + f
 Your “genes” are a, b, c, d, e, and f
 Your “chromosome” is the array [a, b, c, d, e, f]
 Your evaluation function for one array is:
 For every actual data point (x, y), ( red to mean “actual data”)
 Compute ý = ax5 + bx4 + cx3 + dx2 +ex + f
 Find the sum of (y – ý)2 over all x
 The sum is your measure of “badness” (larger numbers are worse)
 Example: For [0, 0, 0, 2, 3, 5] and the data points (1, 12) and (2, 22):
 ý = 0x5 + 0x4 + 0x3 + 2x2 +3x + 5 is 2 + 3 + 5 = 10 when x is 1
 ý = 0x5 + 0x4 + 0x3 + 2x2 +3x + 5 is 8 + 6 + 5 = 19 when x is 2
 (12 – 10)2 + (22 – 19)2 = 22 + 32 = 13
 If these are the only two data points, the “badness” of [0, 0, 0, 2, 3, 5] is 13
9
A more realistic example, part III
 Your algorithm might be as follows:
 Create 100 six-element arrays of random numbers
 Repeat 500 times (or any other number):
 For each of the 100 arrays, compute its badness (using all data
points)
 Keep the ten best arrays (discard the other 90)
 From each array you keep, generate nine new arrays as
follows:
 Pick a random element of the six
 Pick a random floating-point number between 0.0 and 2.0
 Multiply the random element of the array by the random
floating-point number
 After all 500 trials, pick the best array as your final answer
10
Asexual vs. sexual reproduction
 In the examples so far,
 Each “organism” (or “solution”) had only one parent
 Reproduction was asexual (without sex)
 The only way to introduce variation was through mutation
(random changes)
 In sexual reproduction,
 Each “organism” (or “solution”) has two parents
 Assuming that each organism has just one chromosome, new
offspring are produced by forming a new chromosome from
parts of the chromosomes of each parent
11
The really simple example again
 Suppose your “organisms” are 32-bit computer words,
and you want a string in which all the bits are ones
 Here’s how you can do it:
 Create 100 randomly generated computer words
 Repeatedly do the following:
 Count the 1 bits in each word
 Exit if any of the words have all 32 bits set to 1
 Keep the ten words that have the most 1s (discard the rest)
 From each word, generate 9 new words as follows:
 Choose one of the other words
 Take the first half of this word and combine it with the
second half of the other word
12
The example continued
 Half from one, half from the other:
0110 1001 0100 1110 1010 1101 1011 0101
1101 0100 0101 1010 1011 0100 1010 0101
0110 1001 0100 1110 1011 0100 1010 0101
 Or we might choose “genes” (bits) randomly:
0110 1001 0100 1110 1010 1101 1011 0101
1101 0100 0101 1010 1011 0100 1010 0101
0100 0101 0100 1010 1010 1100 1011 0101
 Or we might consider a “gene” to be a larger unit:
0110 1001 0100 1110 1010 1101 1011 0101
1101 0100 0101 1010 1011 0100 1010 0101
1101 1001 0101 1010 1010 1101 1010 0101
13
Comparison of simple examples
 In the simple example (trying to get all 1s):
 The sexual (two-parent, no mutation) approach, if it succeeds,
is likely to succeed much faster
 Because up to half of the bits change each time, not just one bit
 However, with no mutation, it may not succeed at all
 By pure bad luck, maybe none of the first (randomly generated) words
have (say) bit 17 set to 1
 Then there is no way a 1 could ever occur in this position
 Another problem is lack of genetic diversity
 Maybe some of the first generation did have bit 17 set to 1, but
none of them were selected for the second generation
 The best technique in general turns out to be sexual
reproduction with a small probability of mutation
14
Curve fitting with sexual reproduction
 Your formula is y = ax5 + bx4 + cx3 + dx2 +ex + f
 Your “genes” are a, b, c, d, e, and f
 Your “chromosome” is the array [a, b, c, d, e, f]
 What’s the best way to combine two chromosomes into
one?
 You could choose the first half of one and the second half of
the other: [a, b, c, d, e, f]
 You could choose genes randomly: [a, b, c, d, e, f]
 You could compute “gene averages:”
[(a+a)/2, (b+b)/2, (c+c)/2, (d+d)/2, (e+e)/2,(f+f)/2]
 The last may be the best, though it is difficult to know of a good
biological analogy for it
Three main types of rules
 The genetic algorithm uses three main types of
rules at each step to create the next generation
from the current population:
• Selection rules select the individuals, called parents, that
contribute to the population at the next generation.
• Crossover rules combine two parents to form children
for the next generation.
• Mutation rules apply random changes to individual
parents to form children.
15
16
Directed evolution
 Notice that, in the previous examples, we formed the
child organisms randomly
 We did not try to choose the “best” genes from each parent
 This is how natural (biological) evolution works
 Biological evolution is not directed—there is no “goal”
 Genetic algorithms use biology as inspiration, not as a set of
rules to be slavishly followed
 For trying to get a word of all 1s, there is an obvious
measure of a “good” gene
 But that’s mostly because it’s a silly example
 It’s much harder to detect a “good gene” in the curve-fitting
problem, harder still in almost any “real use” of a genetic
algorithm
17
Probabilistic matching
 In previous examples, we chose the N “best” organisms
as parents for the next generation
 A more common approach is to choose parents
randomly, based on their measure of goodness
 Thus, an organism that is twice as “good” as another is likely
to have twice as many offspring
 This has a couple of advantages:
 The best organisms will contribute the most to the next
generation
 Since every organism has some chance of being a parent, there
is somewhat less loss of genetic diversity
18
Genetic programming
 A string of bits could represent a program
 If you want a program to do something, you might try to
evolve one
 As a concrete example, suppose you want a program to
help you choose stocks in the stock market
 There is a huge amount of data, going back many years
 What data has the most predictive value?
 What’s the best way to combine this data?
 A genetic program is possible in theory, but it might
take millions of years to evolve into something useful
 How can we improve this?
19
Concluding remarks
 Genetic algorithms are—
 Fun! They are enjoyable to program and to work with
 This is probably why they are a subject of active research
 Mind-bogglingly slow—you don’t want to use them if you
have any alternatives
 Good for a very few types of problems
 Genetic algorithms can sometimes come up with a solution when you
can see no other way of tackling the problem
20
The End

More Related Content

What's hot

Software testing
Software testing Software testing
Software testing
Kunal Prajapati
 
Text compression
Text compressionText compression
Text compression
Sammer Qader
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
hafizhamza0322
 
boolean algebra and logic simplification
boolean algebra and logic simplificationboolean algebra and logic simplification
boolean algebra and logic simplification
Unsa Shakir
 
Unit 6 interprocessor arbitration
Unit 6 interprocessor arbitrationUnit 6 interprocessor arbitration
Unit 6 interprocessor arbitration
Dipesh Vaya
 
Encoding Techniques
Encoding TechniquesEncoding Techniques
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
Vignesh Saravanan
 
Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 
Human computer interaction
Human  computer interactionHuman  computer interaction
Human computer interaction
Ayusha Patnaik
 
Multiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchartMultiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchart
Tanjarul Islam Mishu
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Exploring GOMs
Exploring GOMsExploring GOMs
Exploring GOMs
jbellWCT
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing Machine
Rajendran
 
Robot Software Architecture (Mobile Robots)
Robot Software Architecture (Mobile Robots)Robot Software Architecture (Mobile Robots)
Robot Software Architecture (Mobile Robots)
Satyanarayana Mekala
 
5 black box and grey box testing
5   black box and grey box testing5   black box and grey box testing
5 black box and grey box testing
Yisal Khan
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
Gaurav Subham
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Stavros Vassos
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
Syed Muhammad Zeejah Hashmi
 

What's hot (20)

Software testing
Software testing Software testing
Software testing
 
Text compression
Text compressionText compression
Text compression
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
boolean algebra and logic simplification
boolean algebra and logic simplificationboolean algebra and logic simplification
boolean algebra and logic simplification
 
Unit 6 interprocessor arbitration
Unit 6 interprocessor arbitrationUnit 6 interprocessor arbitration
Unit 6 interprocessor arbitration
 
Encoding Techniques
Encoding TechniquesEncoding Techniques
Encoding Techniques
 
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
 
Cache memory
Cache memoryCache memory
Cache memory
 
Human computer interaction
Human  computer interactionHuman  computer interaction
Human computer interaction
 
Multiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchartMultiplication algorithm, hardware and flowchart
Multiplication algorithm, hardware and flowchart
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Memory management
Memory managementMemory management
Memory management
 
Exploring GOMs
Exploring GOMsExploring GOMs
Exploring GOMs
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing Machine
 
Robot Software Architecture (Mobile Robots)
Robot Software Architecture (Mobile Robots)Robot Software Architecture (Mobile Robots)
Robot Software Architecture (Mobile Robots)
 
5 black box and grey box testing
5   black box and grey box testing5   black box and grey box testing
5 black box and grey box testing
 
Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
Arrays
ArraysArrays
Arrays
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture6-Part1
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 

Similar to Lec 7 genetic algorithms

45 genetic-algorithms
45 genetic-algorithms45 genetic-algorithms
45 genetic-algorithms
grskrishna
 
Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic Algorithms
Derek Kane
 
Gadoc
GadocGadoc
Artificial intelligence cs607 handouts lecture 11 - 45
Artificial intelligence   cs607 handouts lecture 11 - 45Artificial intelligence   cs607 handouts lecture 11 - 45
Artificial intelligence cs607 handouts lecture 11 - 45
Sattar kayani
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
rabidityfactor
 
A Review On Genetic Algorithm And Its Applications
A Review On Genetic Algorithm And Its ApplicationsA Review On Genetic Algorithm And Its Applications
A Review On Genetic Algorithm And Its Applications
Karen Gomez
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
Pratheeban Rajendran
 
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
Geoff Harcourt
 
Machine Learning - Genetic Algorithm Fundamental
Machine Learning - Genetic Algorithm FundamentalMachine Learning - Genetic Algorithm Fundamental
Machine Learning - Genetic Algorithm Fundamental
Anggi Andriyadi
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
ESUG
 
GeneticAlgorithm
GeneticAlgorithmGeneticAlgorithm
GeneticAlgorithmguestfbf1e1
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithmsguest9938738
 
A voyage-inward-02
A voyage-inward-02A voyage-inward-02
A voyage-inward-02
Raman Kannan
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
Megha V
 
Sheet1Student Name ________________________________10-coin trialO.docx
Sheet1Student Name  ________________________________10-coin trialO.docxSheet1Student Name  ________________________________10-coin trialO.docx
Sheet1Student Name ________________________________10-coin trialO.docx
bjohn46
 
Genetic Algorithm 2 -.pptx
Genetic Algorithm 2 -.pptxGenetic Algorithm 2 -.pptx
Genetic Algorithm 2 -.pptx
TAHANMKH
 
Introduction to Genetic algorithms
Introduction to Genetic algorithmsIntroduction to Genetic algorithms
Introduction to Genetic algorithms
Akhil Kaushik
 
1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial
BenitoSumpter862
 
1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial
SantosConleyha
 
Practical Genetic Algorithms
Practical Genetic AlgorithmsPractical Genetic Algorithms
Practical Genetic Algorithms
Julian Bunn
 

Similar to Lec 7 genetic algorithms (20)

45 genetic-algorithms
45 genetic-algorithms45 genetic-algorithms
45 genetic-algorithms
 
Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic Algorithms
 
Gadoc
GadocGadoc
Gadoc
 
Artificial intelligence cs607 handouts lecture 11 - 45
Artificial intelligence   cs607 handouts lecture 11 - 45Artificial intelligence   cs607 handouts lecture 11 - 45
Artificial intelligence cs607 handouts lecture 11 - 45
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
A Review On Genetic Algorithm And Its Applications
A Review On Genetic Algorithm And Its ApplicationsA Review On Genetic Algorithm And Its Applications
A Review On Genetic Algorithm And Its Applications
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
Info to Genetic Algorithms - DC Ruby Users Group 11.10.2016
 
Machine Learning - Genetic Algorithm Fundamental
Machine Learning - Genetic Algorithm FundamentalMachine Learning - Genetic Algorithm Fundamental
Machine Learning - Genetic Algorithm Fundamental
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
GeneticAlgorithm
GeneticAlgorithmGeneticAlgorithm
GeneticAlgorithm
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
A voyage-inward-02
A voyage-inward-02A voyage-inward-02
A voyage-inward-02
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Sheet1Student Name ________________________________10-coin trialO.docx
Sheet1Student Name  ________________________________10-coin trialO.docxSheet1Student Name  ________________________________10-coin trialO.docx
Sheet1Student Name ________________________________10-coin trialO.docx
 
Genetic Algorithm 2 -.pptx
Genetic Algorithm 2 -.pptxGenetic Algorithm 2 -.pptx
Genetic Algorithm 2 -.pptx
 
Introduction to Genetic algorithms
Introduction to Genetic algorithmsIntroduction to Genetic algorithms
Introduction to Genetic algorithms
 
1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial
 
1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial1. What is your reaction to Kant applying his idea of a categorial
1. What is your reaction to Kant applying his idea of a categorial
 
Practical Genetic Algorithms
Practical Genetic AlgorithmsPractical Genetic Algorithms
Practical Genetic Algorithms
 

More from Eyob Sisay

Lec 9 conclusion
Lec 9  conclusionLec 9  conclusion
Lec 9 conclusion
Eyob Sisay
 
Lec 8 ai implementation
Lec 8  ai implementationLec 8  ai implementation
Lec 8 ai implementation
Eyob Sisay
 
Lec 6 learning
Lec 6 learningLec 6 learning
Lec 6 learning
Eyob Sisay
 
Lec 5 uncertainty
Lec 5 uncertaintyLec 5 uncertainty
Lec 5 uncertainty
Eyob Sisay
 
Lec 4 expert systems
Lec 4  expert systemsLec 4  expert systems
Lec 4 expert systems
Eyob Sisay
 
Lec 3 1 reasoning
Lec 3  1 reasoningLec 3  1 reasoning
Lec 3 1 reasoning
Eyob Sisay
 
Lec 3 knowledge acquisition representation and inference
Lec 3  knowledge acquisition representation and inferenceLec 3  knowledge acquisition representation and inference
Lec 3 knowledge acquisition representation and inference
Eyob Sisay
 
Lec 2 1 informed search
Lec 2 1  informed searchLec 2 1  informed search
Lec 2 1 informed search
Eyob Sisay
 
Lec 2 agents
Lec 2 agentsLec 2 agents
Lec 2 agents
Eyob Sisay
 
Lec 0 about the course
Lec 0 about the courseLec 0 about the course
Lec 0 about the course
Eyob Sisay
 
Lec 1 introduction
Lec 1  introductionLec 1  introduction
Lec 1 introduction
Eyob Sisay
 
Security and Privacy Challenges in Cloud Computing Environments
Security and Privacy Challenges in Cloud Computing EnvironmentsSecurity and Privacy Challenges in Cloud Computing Environments
Security and Privacy Challenges in Cloud Computing Environments
Eyob Sisay
 
A Survey on Wireless Mesh Networks (WMN)
A Survey on Wireless Mesh Networks (WMN)A Survey on Wireless Mesh Networks (WMN)
A Survey on Wireless Mesh Networks (WMN)
Eyob Sisay
 

More from Eyob Sisay (13)

Lec 9 conclusion
Lec 9  conclusionLec 9  conclusion
Lec 9 conclusion
 
Lec 8 ai implementation
Lec 8  ai implementationLec 8  ai implementation
Lec 8 ai implementation
 
Lec 6 learning
Lec 6 learningLec 6 learning
Lec 6 learning
 
Lec 5 uncertainty
Lec 5 uncertaintyLec 5 uncertainty
Lec 5 uncertainty
 
Lec 4 expert systems
Lec 4  expert systemsLec 4  expert systems
Lec 4 expert systems
 
Lec 3 1 reasoning
Lec 3  1 reasoningLec 3  1 reasoning
Lec 3 1 reasoning
 
Lec 3 knowledge acquisition representation and inference
Lec 3  knowledge acquisition representation and inferenceLec 3  knowledge acquisition representation and inference
Lec 3 knowledge acquisition representation and inference
 
Lec 2 1 informed search
Lec 2 1  informed searchLec 2 1  informed search
Lec 2 1 informed search
 
Lec 2 agents
Lec 2 agentsLec 2 agents
Lec 2 agents
 
Lec 0 about the course
Lec 0 about the courseLec 0 about the course
Lec 0 about the course
 
Lec 1 introduction
Lec 1  introductionLec 1  introduction
Lec 1 introduction
 
Security and Privacy Challenges in Cloud Computing Environments
Security and Privacy Challenges in Cloud Computing EnvironmentsSecurity and Privacy Challenges in Cloud Computing Environments
Security and Privacy Challenges in Cloud Computing Environments
 
A Survey on Wireless Mesh Networks (WMN)
A Survey on Wireless Mesh Networks (WMN)A Survey on Wireless Mesh Networks (WMN)
A Survey on Wireless Mesh Networks (WMN)
 

Recently uploaded

MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 

Recently uploaded (20)

MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 

Lec 7 genetic algorithms

  • 2. 2 Evolution  Oversimplified description of how evolution works in biology:  Organisms (animals or plants) produce a number of offspring which are almost, but not entirely, like themselves  Variation may be due to mutation (random changes)  Variation may be due to sexual reproduction (offspring have some characteristics from each parent)  Some of these offspring may survive to produce offspring of their own—some won’t  The “better adapted” offspring are more likely to survive  Over time, later generations become better and better adapted  Genetic algorithms use this same process to “evolve” better programs
  • 3. 3 Genotypes and phenotypes  Genes are the basic “instructions” for building an organism  A chromosome is a sequence of genes  Biologists distinguish between an organism’s genotype (the genes and chromosomes) and its phenotype (what the organism actually is like)  Example: You might have genes to be tall, but never grow to be tall for other reasons (such as poor diet)  Similarly, “genes” may describe a possible solution to a problem, without actually being the solution
  • 4. 4 The basic genetic algorithm  Start with a large “population” of randomly generated “attempted solutions” to a problem  Repeatedly do the following:  Evaluate each of the attempted solutions  Keep a subset of these solutions (the “best” ones)  Use these solutions to generate a new population  Quit when you have a satisfactory solution (or you run out of time)
  • 6. 6 A really simple example  Suppose your “organisms” are 32-bit computer words  You want a string in which all the bits are ones  Here’s how you can do it:  Create 100 randomly generated computer words  Repeatedly do the following:  Count the 1 bits in each word  Exit if any of the words have all 32 bits set to 1  Keep the ten words that have the most 1s (discard the rest)  From each word, generate 9 new words as follows:  Pick a random bit in the word and toggle (change) it  Note that this procedure does not guarantee that the next “generation” will have more 1 bits, but it’s likely
  • 7. 7 A more realistic example, part I  Suppose you have a large number of (x, y) data points  For example, (1.0, 4.1), (3.1, 9.5), (-5.2, 8.6), ...  You would like to fit a polynomial (of up to degree 5) through these data points  That is, you want a formula y = ax5 + bx4 + cx3 + dx2 +ex + f that gives you a reasonably good fit to the actual data  Here’s the usual way to compute goodness of fit:  Compute the sum of (actual y – predicted y)2 for all the data points  The lowest sum represents the best fit  There are some standard curve fitting techniques, but let’s assume you don’t know about them  You can use a genetic algorithm to find a “pretty good” solution
  • 8. 8 A more realistic example, part II  Your formula is y = ax5 + bx4 + cx3 + dx2 +ex + f  Your “genes” are a, b, c, d, e, and f  Your “chromosome” is the array [a, b, c, d, e, f]  Your evaluation function for one array is:  For every actual data point (x, y), ( red to mean “actual data”)  Compute ý = ax5 + bx4 + cx3 + dx2 +ex + f  Find the sum of (y – ý)2 over all x  The sum is your measure of “badness” (larger numbers are worse)  Example: For [0, 0, 0, 2, 3, 5] and the data points (1, 12) and (2, 22):  ý = 0x5 + 0x4 + 0x3 + 2x2 +3x + 5 is 2 + 3 + 5 = 10 when x is 1  ý = 0x5 + 0x4 + 0x3 + 2x2 +3x + 5 is 8 + 6 + 5 = 19 when x is 2  (12 – 10)2 + (22 – 19)2 = 22 + 32 = 13  If these are the only two data points, the “badness” of [0, 0, 0, 2, 3, 5] is 13
  • 9. 9 A more realistic example, part III  Your algorithm might be as follows:  Create 100 six-element arrays of random numbers  Repeat 500 times (or any other number):  For each of the 100 arrays, compute its badness (using all data points)  Keep the ten best arrays (discard the other 90)  From each array you keep, generate nine new arrays as follows:  Pick a random element of the six  Pick a random floating-point number between 0.0 and 2.0  Multiply the random element of the array by the random floating-point number  After all 500 trials, pick the best array as your final answer
  • 10. 10 Asexual vs. sexual reproduction  In the examples so far,  Each “organism” (or “solution”) had only one parent  Reproduction was asexual (without sex)  The only way to introduce variation was through mutation (random changes)  In sexual reproduction,  Each “organism” (or “solution”) has two parents  Assuming that each organism has just one chromosome, new offspring are produced by forming a new chromosome from parts of the chromosomes of each parent
  • 11. 11 The really simple example again  Suppose your “organisms” are 32-bit computer words, and you want a string in which all the bits are ones  Here’s how you can do it:  Create 100 randomly generated computer words  Repeatedly do the following:  Count the 1 bits in each word  Exit if any of the words have all 32 bits set to 1  Keep the ten words that have the most 1s (discard the rest)  From each word, generate 9 new words as follows:  Choose one of the other words  Take the first half of this word and combine it with the second half of the other word
  • 12. 12 The example continued  Half from one, half from the other: 0110 1001 0100 1110 1010 1101 1011 0101 1101 0100 0101 1010 1011 0100 1010 0101 0110 1001 0100 1110 1011 0100 1010 0101  Or we might choose “genes” (bits) randomly: 0110 1001 0100 1110 1010 1101 1011 0101 1101 0100 0101 1010 1011 0100 1010 0101 0100 0101 0100 1010 1010 1100 1011 0101  Or we might consider a “gene” to be a larger unit: 0110 1001 0100 1110 1010 1101 1011 0101 1101 0100 0101 1010 1011 0100 1010 0101 1101 1001 0101 1010 1010 1101 1010 0101
  • 13. 13 Comparison of simple examples  In the simple example (trying to get all 1s):  The sexual (two-parent, no mutation) approach, if it succeeds, is likely to succeed much faster  Because up to half of the bits change each time, not just one bit  However, with no mutation, it may not succeed at all  By pure bad luck, maybe none of the first (randomly generated) words have (say) bit 17 set to 1  Then there is no way a 1 could ever occur in this position  Another problem is lack of genetic diversity  Maybe some of the first generation did have bit 17 set to 1, but none of them were selected for the second generation  The best technique in general turns out to be sexual reproduction with a small probability of mutation
  • 14. 14 Curve fitting with sexual reproduction  Your formula is y = ax5 + bx4 + cx3 + dx2 +ex + f  Your “genes” are a, b, c, d, e, and f  Your “chromosome” is the array [a, b, c, d, e, f]  What’s the best way to combine two chromosomes into one?  You could choose the first half of one and the second half of the other: [a, b, c, d, e, f]  You could choose genes randomly: [a, b, c, d, e, f]  You could compute “gene averages:” [(a+a)/2, (b+b)/2, (c+c)/2, (d+d)/2, (e+e)/2,(f+f)/2]  The last may be the best, though it is difficult to know of a good biological analogy for it
  • 15. Three main types of rules  The genetic algorithm uses three main types of rules at each step to create the next generation from the current population: • Selection rules select the individuals, called parents, that contribute to the population at the next generation. • Crossover rules combine two parents to form children for the next generation. • Mutation rules apply random changes to individual parents to form children. 15
  • 16. 16 Directed evolution  Notice that, in the previous examples, we formed the child organisms randomly  We did not try to choose the “best” genes from each parent  This is how natural (biological) evolution works  Biological evolution is not directed—there is no “goal”  Genetic algorithms use biology as inspiration, not as a set of rules to be slavishly followed  For trying to get a word of all 1s, there is an obvious measure of a “good” gene  But that’s mostly because it’s a silly example  It’s much harder to detect a “good gene” in the curve-fitting problem, harder still in almost any “real use” of a genetic algorithm
  • 17. 17 Probabilistic matching  In previous examples, we chose the N “best” organisms as parents for the next generation  A more common approach is to choose parents randomly, based on their measure of goodness  Thus, an organism that is twice as “good” as another is likely to have twice as many offspring  This has a couple of advantages:  The best organisms will contribute the most to the next generation  Since every organism has some chance of being a parent, there is somewhat less loss of genetic diversity
  • 18. 18 Genetic programming  A string of bits could represent a program  If you want a program to do something, you might try to evolve one  As a concrete example, suppose you want a program to help you choose stocks in the stock market  There is a huge amount of data, going back many years  What data has the most predictive value?  What’s the best way to combine this data?  A genetic program is possible in theory, but it might take millions of years to evolve into something useful  How can we improve this?
  • 19. 19 Concluding remarks  Genetic algorithms are—  Fun! They are enjoyable to program and to work with  This is probably why they are a subject of active research  Mind-bogglingly slow—you don’t want to use them if you have any alternatives  Good for a very few types of problems  Genetic algorithms can sometimes come up with a solution when you can see no other way of tackling the problem