SlideShare a Scribd company logo
1 of 27
Introduction to GeneticAlgorithms 2
We toss a fair coin 60 times and get the
following initial population:
s1 = 1111010101 f (s1) = 7
s2 = 0111000101 f (s2) = 5
s3 = 1110110101 f (s3) = 7
s4 = 0100010011 f (s4) = 4
s5 = 1110111101 f (s5) = 8
s6 = 0100110000 f (s6) = 3
Introduction to GeneticAlgorithms 3
Next we apply fitness proportionate selection with the
roulette wheel method:
21
n
3
Area is
Proportional
to fitness
value
Individual i will have a
probability to be chosen
i
if
if
)(
)(
4
We repeat the extraction
as many times as the
number of individuals we
need to have the same
parent population size
(6 in our case)
Introduction to GeneticAlgorithms 4
Suppose that, after performing selection, we get
the following population:
s1` = 1111010101 (s1)
s2` = 1110110101 (s3)
s3` = 1110111101 (s5)
s4` = 0111000101 (s2)
s5` = 0100010011 (s4)
s6` = 1110111101 (s5)
Introduction to GeneticAlgorithms 5
Next we mate strings for crossover. For each
couple we decide according to crossover
probability (for instance 0.6) whether to actually
perform crossover or not
Suppose that we decide to actually perform
crossover only for couples (s1`, s2`) and (s5`, s6`). For
each couple, we randomly extract a crossover
point, for instance 2 for the first and 5 for the
second
Introduction to GeneticAlgorithms 6
s1` = 1111010101 s2` =
1110110101
s5` = 0100010011 s6` =
1110111101
Before crossover:
After crossover:
s1`` = 1110110101 s2`` =
1111010101
s5`` = 0100011101 s6`` =
1110110011
Introduction to GeneticAlgorithms 7
The final step is to apply random mutation: for each bit that we are to copy to
the new population we allow a small probability of error (for instance 0.1)
Before applying mutation:
s1`` = 1110110101
s2`` = 1111010101
s3`` = 1110111101
s4`` = 0111000101
s5`` = 0100011101
s6`` = 1110110011
Introduction to GeneticAlgorithms 8
In one generation, the total population fitness
changed from 34 to 37, thus improved by ~9%
At this point, we go through the same process
all over again, until a stopping criterion is met
Introduction to GeneticAlgorithms 9
A vector v = (i1 i2… in) represents a tour (v is a
permutation of {1,2,…,n})
Fitness f of a solution is the inverse cost of the
corresponding tour
Initialization: use either some heuristics, or a
random sample of permutations of {1,2,…,n}
We shall use the fitness proportionate selection
Introduction to GeneticAlgorithms 10
Next, starting from the second cut point of one parent, the cities from the other
parent are copied in the same order
The sequence of the cities in the second parent is 9 – 3 – 4 – 5 – 2 –
1 – 8 – 7 – 6
After removal of cities from the first offspring we get 9 – 3 – 2 – 1 – 8
This sequence is placed in the first offspring
o1 = (2 1 8 4 5 6 7 9 3), and similarly in the second
o2 = (3 4 5 1 8 7 6 9 2)
Introduction to GeneticAlgorithms 11
The sub-string between two randomly selected
points in the path is reversed
Example:
(1 2 3 4 5 6 7 8 9) is changed into (1 2 7 6 5 4 3 8 9)
Such simple inversion guarantees that the
resulting offspring is a legal tour
Example
 Simple problem: max x2 over {0,1,…,31}
 GA approach:
 Representation: binary code, e.g. 01101  13
 Population size: 4
 1-point xover, bitwise mutation
 Roulette wheel selection
 Random initialisation
 We show one generational cycle done by
hand
 Has been subject of many (early) studies
 still often used as benchmark for novel GAs
 Shows many shortcomings, e.g.
 Representation is too restrictive
 Mutation & crossovers only applicable for bit-string &
integer representations
 Selection mechanism sensitive for converging
populations with close fitness values
 Generational population model (step 5 in SGA repr.
cycle) can be improved with explicit survivor selection
 Performance with 1 Point Crossover depends on the order
that variables occur in the representation
 more likely to keep together genes that are near
each other
 Can never keep together genes from opposite
ends of string
 This is known as Positional Bias
 Can be exploited if we know about the structure
of our problem, but this is not usually the case
 Choose n random crossover points
 Split along those points
 Glue parts, alternating between parents
 Generalisation of 1 point (still some positional bias)
 Assign 'heads' to one parent, 'tails' to the other
 Flip a coin for each gene of the first child
 Make an inverse copy of the gene for the second child
 Inheritance is independent of position
 Decade long debate: which one is better / necessary / main-
background
 Answer (at least, rather wide agreement):
 it depends on the problem, but
 in general, it is good to have both
 both have another role
 mutation-only-EA is possible, xover-only-EA would not work
Exploration: Discovering promising areas in the search space,
i.e. gaining information on the problem
Exploitation: Optimising within a promising area, i.e. using
information
There is co-operationAND competition between them
 Crossover is explorative, it makes a big jump to an area
somewhere “in between” two (parent) areas
 Mutation is exploitative, it creates random small diversions,
thereby staying near (in the area of ) the parent
 Only crossover can combine information from two
parents
 Only mutation can introduce new information (alleles)
 Crossover does not change the allele frequencies of the
population (thought experiment: 50% 0’s on first bit in
the population, ?% after performing n crossovers)
 To hit the optimum you often need a ‘lucky’ mutation
Introduction to GeneticAlgorithms 24
In this section we take an in-depth look at the
working of the standard genetic algorithm,
explaining why GAs constitute an effective
search procedure
For simplicity we discuss binary string
representation of individuals
Introduction to GeneticAlgorithms 25
{0,1,#} is the symbol alphabet, where # is a
special wild card symbol
A schema is a template consisting of a string
composed of these three symbols
Example: the schema [01#1#] matches the
strings: [01010], [01011], [01110] and [01111]
Introduction to GeneticAlgorithms 26
The order of the schema S (denoted by o(S)) is the
number of fixed positions (0 or 1) presented in the
schema
Example: for S1 = [01#1#], o(S1) = 3
for S2 = [##1#1010], o(S2) = 5
The order of a schema is useful to calculate
survival probability of the schema for mutations
There are 2
l-o(S)
different strings that match S
Genetic algorithm (ga) binary and real  Vijay Bhaskar Semwal

More Related Content

Similar to Genetic algorithm (ga) binary and real Vijay Bhaskar Semwal

Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
guest9938738
 
Thomas Lenormand - Génétique des populations
Thomas Lenormand - Génétique des populationsThomas Lenormand - Génétique des populations
Thomas Lenormand - Génétique des populations
Seminaire MEE
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
zamakhan
 

Similar to Genetic algorithm (ga) binary and real Vijay Bhaskar Semwal (20)

GA.pptx
GA.pptxGA.pptx
GA.pptx
 
Introduction to Genetic algorithms
Introduction to Genetic algorithmsIntroduction to Genetic algorithms
Introduction to Genetic algorithms
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Genetic Algorithm by Example
Genetic Algorithm by ExampleGenetic Algorithm by Example
Genetic Algorithm by Example
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Genetic Algorithm (1).pdf
Genetic Algorithm (1).pdfGenetic Algorithm (1).pdf
Genetic Algorithm (1).pdf
 
Genetic
GeneticGenetic
Genetic
 
Diversity mechanisms for evolutionary populations in Search-Based Software En...
Diversity mechanisms for evolutionary populations in Search-Based Software En...Diversity mechanisms for evolutionary populations in Search-Based Software En...
Diversity mechanisms for evolutionary populations in Search-Based Software En...
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Thomas Lenormand - Génétique des populations
Thomas Lenormand - Génétique des populationsThomas Lenormand - Génétique des populations
Thomas Lenormand - Génétique des populations
 
Ga
GaGa
Ga
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Practical Genetic Algorithms
Practical Genetic AlgorithmsPractical Genetic Algorithms
Practical Genetic Algorithms
 
04 1 evolution
04 1 evolution04 1 evolution
04 1 evolution
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
RM 701 Genetic Algorithm and Fuzzy Logic lecture
RM 701 Genetic Algorithm and Fuzzy Logic lectureRM 701 Genetic Algorithm and Fuzzy Logic lecture
RM 701 Genetic Algorithm and Fuzzy Logic lecture
 
Chapter4_Multi_Reg_Estim.pdf.pdf
Chapter4_Multi_Reg_Estim.pdf.pdfChapter4_Multi_Reg_Estim.pdf.pdf
Chapter4_Multi_Reg_Estim.pdf.pdf
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
4.Genetic-Algorithms.ppt
4.Genetic-Algorithms.ppt4.Genetic-Algorithms.ppt
4.Genetic-Algorithms.ppt
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 

Recently uploaded (20)

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Genetic algorithm (ga) binary and real Vijay Bhaskar Semwal

  • 1.
  • 2. Introduction to GeneticAlgorithms 2 We toss a fair coin 60 times and get the following initial population: s1 = 1111010101 f (s1) = 7 s2 = 0111000101 f (s2) = 5 s3 = 1110110101 f (s3) = 7 s4 = 0100010011 f (s4) = 4 s5 = 1110111101 f (s5) = 8 s6 = 0100110000 f (s6) = 3
  • 3. Introduction to GeneticAlgorithms 3 Next we apply fitness proportionate selection with the roulette wheel method: 21 n 3 Area is Proportional to fitness value Individual i will have a probability to be chosen i if if )( )( 4 We repeat the extraction as many times as the number of individuals we need to have the same parent population size (6 in our case)
  • 4. Introduction to GeneticAlgorithms 4 Suppose that, after performing selection, we get the following population: s1` = 1111010101 (s1) s2` = 1110110101 (s3) s3` = 1110111101 (s5) s4` = 0111000101 (s2) s5` = 0100010011 (s4) s6` = 1110111101 (s5)
  • 5. Introduction to GeneticAlgorithms 5 Next we mate strings for crossover. For each couple we decide according to crossover probability (for instance 0.6) whether to actually perform crossover or not Suppose that we decide to actually perform crossover only for couples (s1`, s2`) and (s5`, s6`). For each couple, we randomly extract a crossover point, for instance 2 for the first and 5 for the second
  • 6. Introduction to GeneticAlgorithms 6 s1` = 1111010101 s2` = 1110110101 s5` = 0100010011 s6` = 1110111101 Before crossover: After crossover: s1`` = 1110110101 s2`` = 1111010101 s5`` = 0100011101 s6`` = 1110110011
  • 7. Introduction to GeneticAlgorithms 7 The final step is to apply random mutation: for each bit that we are to copy to the new population we allow a small probability of error (for instance 0.1) Before applying mutation: s1`` = 1110110101 s2`` = 1111010101 s3`` = 1110111101 s4`` = 0111000101 s5`` = 0100011101 s6`` = 1110110011
  • 8. Introduction to GeneticAlgorithms 8 In one generation, the total population fitness changed from 34 to 37, thus improved by ~9% At this point, we go through the same process all over again, until a stopping criterion is met
  • 9. Introduction to GeneticAlgorithms 9 A vector v = (i1 i2… in) represents a tour (v is a permutation of {1,2,…,n}) Fitness f of a solution is the inverse cost of the corresponding tour Initialization: use either some heuristics, or a random sample of permutations of {1,2,…,n} We shall use the fitness proportionate selection
  • 10. Introduction to GeneticAlgorithms 10 Next, starting from the second cut point of one parent, the cities from the other parent are copied in the same order The sequence of the cities in the second parent is 9 – 3 – 4 – 5 – 2 – 1 – 8 – 7 – 6 After removal of cities from the first offspring we get 9 – 3 – 2 – 1 – 8 This sequence is placed in the first offspring o1 = (2 1 8 4 5 6 7 9 3), and similarly in the second o2 = (3 4 5 1 8 7 6 9 2)
  • 11. Introduction to GeneticAlgorithms 11 The sub-string between two randomly selected points in the path is reversed Example: (1 2 3 4 5 6 7 8 9) is changed into (1 2 7 6 5 4 3 8 9) Such simple inversion guarantees that the resulting offspring is a legal tour
  • 13.  Simple problem: max x2 over {0,1,…,31}  GA approach:  Representation: binary code, e.g. 01101  13  Population size: 4  1-point xover, bitwise mutation  Roulette wheel selection  Random initialisation  We show one generational cycle done by hand
  • 14.
  • 15.
  • 16.
  • 17.  Has been subject of many (early) studies  still often used as benchmark for novel GAs  Shows many shortcomings, e.g.  Representation is too restrictive  Mutation & crossovers only applicable for bit-string & integer representations  Selection mechanism sensitive for converging populations with close fitness values  Generational population model (step 5 in SGA repr. cycle) can be improved with explicit survivor selection
  • 18.  Performance with 1 Point Crossover depends on the order that variables occur in the representation  more likely to keep together genes that are near each other  Can never keep together genes from opposite ends of string  This is known as Positional Bias  Can be exploited if we know about the structure of our problem, but this is not usually the case
  • 19.  Choose n random crossover points  Split along those points  Glue parts, alternating between parents  Generalisation of 1 point (still some positional bias)
  • 20.  Assign 'heads' to one parent, 'tails' to the other  Flip a coin for each gene of the first child  Make an inverse copy of the gene for the second child  Inheritance is independent of position
  • 21.  Decade long debate: which one is better / necessary / main- background  Answer (at least, rather wide agreement):  it depends on the problem, but  in general, it is good to have both  both have another role  mutation-only-EA is possible, xover-only-EA would not work
  • 22. Exploration: Discovering promising areas in the search space, i.e. gaining information on the problem Exploitation: Optimising within a promising area, i.e. using information There is co-operationAND competition between them  Crossover is explorative, it makes a big jump to an area somewhere “in between” two (parent) areas  Mutation is exploitative, it creates random small diversions, thereby staying near (in the area of ) the parent
  • 23.  Only crossover can combine information from two parents  Only mutation can introduce new information (alleles)  Crossover does not change the allele frequencies of the population (thought experiment: 50% 0’s on first bit in the population, ?% after performing n crossovers)  To hit the optimum you often need a ‘lucky’ mutation
  • 24. Introduction to GeneticAlgorithms 24 In this section we take an in-depth look at the working of the standard genetic algorithm, explaining why GAs constitute an effective search procedure For simplicity we discuss binary string representation of individuals
  • 25. Introduction to GeneticAlgorithms 25 {0,1,#} is the symbol alphabet, where # is a special wild card symbol A schema is a template consisting of a string composed of these three symbols Example: the schema [01#1#] matches the strings: [01010], [01011], [01110] and [01111]
  • 26. Introduction to GeneticAlgorithms 26 The order of the schema S (denoted by o(S)) is the number of fixed positions (0 or 1) presented in the schema Example: for S1 = [01#1#], o(S1) = 3 for S2 = [##1#1010], o(S2) = 5 The order of a schema is useful to calculate survival probability of the schema for mutations There are 2 l-o(S) different strings that match S