SlideShare a Scribd company logo
Genetic algorithm (ga) binary and real  Vijay Bhaskar Semwal
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
Genetic algorithm (ga) binary and real  Vijay Bhaskar Semwal
Genetic algorithm (ga) binary and real  Vijay Bhaskar Semwal
Genetic algorithm (ga) binary and real  Vijay Bhaskar Semwal
 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

PPTX
Genetic algorithm artificial intelligence presentation
PPT
Genetic algorithms
PPT
Class GA. Genetic Algorithm,Genetic Algorithm
PPTX
Evolutionary Computing - Genetic Algorithms - An Introduction
PPTX
Genetic algorithm raktim
PPTX
Genetic algorithm
PDF
Genetic Algorithm
PPTX
Machine Learning - Genetic Algorithm Fundamental
Genetic algorithm artificial intelligence presentation
Genetic algorithms
Class GA. Genetic Algorithm,Genetic Algorithm
Evolutionary Computing - Genetic Algorithms - An Introduction
Genetic algorithm raktim
Genetic algorithm
Genetic Algorithm
Machine Learning - Genetic Algorithm Fundamental

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

PPTX
PPT
Introduction to Genetic algorithms
PPT
Genetic algorithms
PPTX
Genetic Algorithm by Example
PPTX
Genetic Algorithm
PPTX
Genetic Algorithm
PPTX
Genetic algorithm optimization technique.pptx
PDF
Genetic Algorithm (1).pdf
PPTX
Genetic
PDF
Diversity mechanisms for evolutionary populations in Search-Based Software En...
PPT
Genetic algorithm
PPT
Thomas Lenormand - Génétique des populations
PPT
PDF
3_GO_Olesya_Genetic_AlgorithmsOPTIMZTION.p.pdf
PPT
Genetic algorithms
PPT
Chapter four sampling and sampling distribution
PDF
Practical Genetic Algorithms
PDF
04 1 evolution
PPTX
Genetic algorithm
PDF
RM 701 Genetic Algorithm and Fuzzy Logic lecture
Introduction to Genetic algorithms
Genetic algorithms
Genetic Algorithm by Example
Genetic Algorithm
Genetic Algorithm
Genetic algorithm optimization technique.pptx
Genetic Algorithm (1).pdf
Genetic
Diversity mechanisms for evolutionary populations in Search-Based Software En...
Genetic algorithm
Thomas Lenormand - Génétique des populations
3_GO_Olesya_Genetic_AlgorithmsOPTIMZTION.p.pdf
Genetic algorithms
Chapter four sampling and sampling distribution
Practical Genetic Algorithms
04 1 evolution
Genetic algorithm
RM 701 Genetic Algorithm and Fuzzy Logic lecture
Ad

Recently uploaded (20)

PPTX
Welding lecture in detail for understanding
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
web development for engineering and engineering
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Sustainable Sites - Green Building Construction
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Lecture Notes Electrical Wiring System Components
Welding lecture in detail for understanding
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
web development for engineering and engineering
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Sustainable Sites - Green Building Construction
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
bas. eng. economics group 4 presentation 1.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT 4 Total Quality Management .pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Internet of Things (IOT) - A guide to understanding
CH1 Production IntroductoryConcepts.pptx
Lecture Notes Electrical Wiring System Components
Ad

Genetic algorithm (ga) binary and real Vijay Bhaskar Semwal

  • 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
  • 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