SlideShare a Scribd company logo
Genetic Algorithm
40
states
(often encoded as a string of 0s and 1s)
better states.
crossover, and mutation
Genetic/ Evolutionary algorithms
 Developed by John Holland in 1975
 inspired by biological mutation & evolution
 stochastic (means non-deterministic) search techniques
based on the mechanism of natural selection and genetics
 A successor state is generated by combining two parent
 Start with k randomly generated states (population)
 A state is represented as a string over a finite alphabet
 Evaluation function (fitness function). Higher values for
 Produce the next generation of states by selection,
CSE, IUT
43
“Select The Best, Discard The Rest”
 fitness function is upto user (problem specific)-
means to evaluate the potential of a candidate in
the population. e.g. for a binary representation
fitness function could be:
 f(i) = ∑i f(i) ;where i is from 1 to l (l=total length of the sequence)
 And in the selection step, the probability of getting
selection for a candidate is:
 Prob i = f(i) / ∑i f(i)
CSE, IUT
44
Encoding
The process of representing the solution in the form of a string that
conveys the necessary information.
 Binary Encoding – Most common method of encoding.
Chromosomes are strings of 1s and 0s and each position in the
chromosome represents a particular characteristic of the problem.
Permutation Encoding – Useful in ordering problems such as the
Traveling Salesman Problem (TSP). Example. In TSP, every
chromosome is a string of numbers, each of which represents a city to
be visited.
 Value Encoding – Used in problems where complicated values, such
as real numbers, are used and where binary encoding would not suffice.
CSE, IUT
45
e.g. n-queen
 GA representation and encoding of the following
arrangement can be written as: fitness of the chromosome
v1 (24748552) is 28 – 4 = 24 (No. of non attacking pair of queens)
• Encoding is given by the row no. of each column.
 That is because only 4 pairs of queens attack each other:
 The queens on 1st and 8th column
 The queens on 2nd and 4th column
 The queens on 6th and 7th column
 The queens on 3rd and 8th column
CSE, IUT
46
Genetic algorithms
 Fitness function: number of non-attacking pairs of queens
(min = 0, max = 8c2 excluding same pair = 28)
 24/(24+23+20+11) = 31%

 23/(24+23+20+11) = 29% etc
 Here single point crossover & mutation occurred
CSE, IUT
41
Genetic/ Evolutionary algorithms
 Outline of the Basic Genetic Algorithm
1 [Start] Generate random population of n chromosomes (suitable solutions for the
problem)
2 [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
3 [New population] Create a new population by repeating following steps until the new
population is complete
 [Selection] Select two parent chromosomes from a population according to their
fitness (the better fitness, the bigger chance to be selected)
 [Crossover] With a crossover probability cross over the parents to form a new
offspring (children). If no crossover was performed, offspring is an exact copy of
parents.
 [Mutation] With a mutation probability mutate new offspring at each locus (position
in chromosome).
 [Accepting] Place new offspring in a new population (keep population size constant)
4 [Replace] Use new generated population for a further run of algorithm
5 [Test] If the end condition is satisfied, stop, and return the best solution in current
population
 [Loop] Go to step 3
CSE, IUT
41
Genetic/ Evolutionary algorithms
CSE, IUT
47
Genetic algorithms
By doing this Crossover, it helps to accelerate the search at an
early stage of evolution
For detail about genetic algorithm refer to GA1.pdf in
ftp://10.220.20.25/CSE 4701
CSE, IUT
48
Another Example
(Assignment 1: Deadline 15 Feb, 2018)
 Data population: RGB colours
 Aim: to obtain darkest colour represented by
(0, 0, 0)
 This is a minimisation problem, i.e. a good
colour is one that fits for (colour) --> 0.
 We now tabulate our data as shown
CSE, IUT
49
 Start at a random pattern like this:
Colour Red Green Blue
C1 80 170 689
C2 130 690 15
C3 24 8 317
where
Fitness for (C1) = 80 + 170 + 689 = 939
Fitness for (C2) = 130 + 690 + 15 = 835
Fitness for (C3) = 24 + 8 + 317 = 349
CSE, IUT
50
Fitness (C2) = 130 + 690 + 15 = 835
C1
 Start at a random pattern like this:
Colour Red Green Blue
C1 80 170 689
C2 130 690 15
C3 24 8 317
FITTEST
PLACED TOP
C3
Fitness (C1) = 80 + 170 + 689 = 939
C2
Fitness (C3) = 24 + 8 + 317 = 349
CSE, IUT
51
 After a Selection is done on the sample:
** Remember, this is a minimisation problem..
Colour Fitness
C3 349
C2 835
C1 939
CSE, IUT
52
C4 24 8 15C4 is crossover(C3,C2)= (24, 8, 15)
C6 is crossover(C2,C1)= (130, 690, 689)
GA: Reproduction & Crossover
 So far, we have this
Colour Red Green Blue Colour Fitness
C1 80 170 689 C3 349
C2 130 690 15 C2 835
C3 24 8 317 C1 939
Next step is to reproduce the pattern, like this,
by crossing over:
Colour Red Green Blue
C5 is crossover(C3,C1)= (24, 8, 689)
C5 24 8 689
C6 130 690 689
CSE, IUT
53
 perform mutation, and we have
C7 is obtained by mutating(4) =(24, 8, 13)
C8 is obtained by mutating(5) =(25, 9, 689 )
C9 is obtained by mutating(6) =(128, 688, 689)
Colour Red Green Blue
New population of C7 24 8 13
3 chromosomes C8 25 9 689
C9 128 688 689
CSE, IUT
54
Conclusion (up to “mutation” to get a new data set)
 Some solutions have improved (after first iteration):
Getting better rather fast
Slightly improved of the answer
Fitness for C7 = (24 + 8 + 13) = 45
Fitness for C8 = (25 + 9 + 689) = 743
Fitness for C9 = (128 + 688 + 689 ) = 1505
If the process is iterated, population will converge to
have fitness near to zero (colour) --> 0.
Continue..............
CSE, IUT

More Related Content

PPTX
Genetic algorithm
PPTX
Genetic Algorithm
PPT
PDF
Genetic Algorithms
PPT
5 csp
PPTX
Genetic algorithm
PDF
Genetic Algorithm
PPTX
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
Genetic algorithm
Genetic Algorithm
Genetic Algorithms
5 csp
Genetic algorithm
Genetic Algorithm
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...

What's hot (20)

PPT
Genetic algorithms
PDF
Multi Layer Perceptron & Back Propagation
PPTX
Genetic Algorithm
PDF
Metaheuristic Algorithms: A Critical Analysis
PPTX
Unification and Lifting
PPT
Genetic algorithm
PDF
Genetic Algorithm (GA) Optimization - Step-by-Step Example
PDF
Naive Bayes Classifier
PPTX
Ga ppt (1)
PDF
Unit4: Knowledge Representation
PPTX
Bat algorithm
PPTX
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
PPTX
Artificial Intelligence Searching Techniques
PPTX
04 Multi-layer Feedforward Networks
PPTX
Flowchart of GA
PPTX
Bat algorithm and applications
PPTX
Genetic Algorithms
PPTX
The world of loss function
PPTX
Naive Bayes Presentation
PDF
Deep Dive into Hyperparameter Tuning
Genetic algorithms
Multi Layer Perceptron & Back Propagation
Genetic Algorithm
Metaheuristic Algorithms: A Critical Analysis
Unification and Lifting
Genetic algorithm
Genetic Algorithm (GA) Optimization - Step-by-Step Example
Naive Bayes Classifier
Ga ppt (1)
Unit4: Knowledge Representation
Bat algorithm
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Artificial Intelligence Searching Techniques
04 Multi-layer Feedforward Networks
Flowchart of GA
Bat algorithm and applications
Genetic Algorithms
The world of loss function
Naive Bayes Presentation
Deep Dive into Hyperparameter Tuning
Ad

Similar to Genetic algorithm (20)

PPTX
Genetic algorithm optimization technique.pptx
PPTX
introduction of genetic algorithm
PPTX
Genetic Algorithm
PPTX
PPTX
Genetic Algorithm
PDF
Genetic algorithm
PPT
Genetic Algorithms - GAs
PPTX
Genetic algorithm
PDF
3_GO_Olesya_Genetic_AlgorithmsOPTIMZTION.p.pdf
PPTX
GA of a Paper 2012.pptx
PPTX
Genetic Algorithm
PPT
0101.genetic algorithm
PPT
Genetic algorithm
PPT
Evolutionary algorithms
PPT
Genetic algorithms
PDF
Genetic Algorithms in Artificial Intelligence
PPTX
Genetic algorithm
PDF
A Review On Genetic Algorithm And Its Applications
PDF
Soft Computing- Dr. H.s. Hota 28.08.14.pdf
PPT
Ff meeting 25nov03
Genetic algorithm optimization technique.pptx
introduction of genetic algorithm
Genetic Algorithm
Genetic Algorithm
Genetic algorithm
Genetic Algorithms - GAs
Genetic algorithm
3_GO_Olesya_Genetic_AlgorithmsOPTIMZTION.p.pdf
GA of a Paper 2012.pptx
Genetic Algorithm
0101.genetic algorithm
Genetic algorithm
Evolutionary algorithms
Genetic algorithms
Genetic Algorithms in Artificial Intelligence
Genetic algorithm
A Review On Genetic Algorithm And Its Applications
Soft Computing- Dr. H.s. Hota 28.08.14.pdf
Ff meeting 25nov03
Ad

More from Bablu Shofi (7)

PPTX
Cyber security
PPT
Informed search (heuristics)
PPT
Uninformed search
PDF
computer-memory
PPT
Data linkcontrol
PPTX
PPTX
Inventory Management
Cyber security
Informed search (heuristics)
Uninformed search
computer-memory
Data linkcontrol
Inventory Management

Recently uploaded (20)

PPT
Mechanical Engineering MATERIALS Selection
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
web development for engineering and engineering
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
Project quality management in manufacturing
PPTX
additive manufacturing of ss316l using mig welding
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Sustainable Sites - Green Building Construction
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Mechanical Engineering MATERIALS Selection
Model Code of Practice - Construction Work - 21102022 .pdf
573137875-Attendance-Management-System-original
Lecture Notes Electrical Wiring System Components
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
web development for engineering and engineering
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Project quality management in manufacturing
additive manufacturing of ss316l using mig welding
OOP with Java - Java Introduction (Basics)
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Sustainable Sites - Green Building Construction
R24 SURVEYING LAB MANUAL for civil enggi
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT 4 Total Quality Management .pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Internet of Things (IOT) - A guide to understanding
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Genetic algorithm

  • 2. 40 states (often encoded as a string of 0s and 1s) better states. crossover, and mutation Genetic/ Evolutionary algorithms  Developed by John Holland in 1975  inspired by biological mutation & evolution  stochastic (means non-deterministic) search techniques based on the mechanism of natural selection and genetics  A successor state is generated by combining two parent  Start with k randomly generated states (population)  A state is represented as a string over a finite alphabet  Evaluation function (fitness function). Higher values for  Produce the next generation of states by selection, CSE, IUT
  • 3. 43 “Select The Best, Discard The Rest”  fitness function is upto user (problem specific)- means to evaluate the potential of a candidate in the population. e.g. for a binary representation fitness function could be:  f(i) = ∑i f(i) ;where i is from 1 to l (l=total length of the sequence)  And in the selection step, the probability of getting selection for a candidate is:  Prob i = f(i) / ∑i f(i) CSE, IUT
  • 4. 44 Encoding The process of representing the solution in the form of a string that conveys the necessary information.  Binary Encoding – Most common method of encoding. Chromosomes are strings of 1s and 0s and each position in the chromosome represents a particular characteristic of the problem. Permutation Encoding – Useful in ordering problems such as the Traveling Salesman Problem (TSP). Example. In TSP, every chromosome is a string of numbers, each of which represents a city to be visited.  Value Encoding – Used in problems where complicated values, such as real numbers, are used and where binary encoding would not suffice. CSE, IUT
  • 5. 45 e.g. n-queen  GA representation and encoding of the following arrangement can be written as: fitness of the chromosome v1 (24748552) is 28 – 4 = 24 (No. of non attacking pair of queens) • Encoding is given by the row no. of each column.  That is because only 4 pairs of queens attack each other:  The queens on 1st and 8th column  The queens on 2nd and 4th column  The queens on 6th and 7th column  The queens on 3rd and 8th column CSE, IUT
  • 6. 46 Genetic algorithms  Fitness function: number of non-attacking pairs of queens (min = 0, max = 8c2 excluding same pair = 28)  24/(24+23+20+11) = 31%   23/(24+23+20+11) = 29% etc  Here single point crossover & mutation occurred CSE, IUT
  • 7. 41 Genetic/ Evolutionary algorithms  Outline of the Basic Genetic Algorithm 1 [Start] Generate random population of n chromosomes (suitable solutions for the problem) 2 [Fitness] Evaluate the fitness f(x) of each chromosome x in the population 3 [New population] Create a new population by repeating following steps until the new population is complete  [Selection] Select two parent chromosomes from a population according to their fitness (the better fitness, the bigger chance to be selected)  [Crossover] With a crossover probability cross over the parents to form a new offspring (children). If no crossover was performed, offspring is an exact copy of parents.  [Mutation] With a mutation probability mutate new offspring at each locus (position in chromosome).  [Accepting] Place new offspring in a new population (keep population size constant) 4 [Replace] Use new generated population for a further run of algorithm 5 [Test] If the end condition is satisfied, stop, and return the best solution in current population  [Loop] Go to step 3 CSE, IUT
  • 9. 47 Genetic algorithms By doing this Crossover, it helps to accelerate the search at an early stage of evolution For detail about genetic algorithm refer to GA1.pdf in ftp://10.220.20.25/CSE 4701 CSE, IUT
  • 10. 48 Another Example (Assignment 1: Deadline 15 Feb, 2018)  Data population: RGB colours  Aim: to obtain darkest colour represented by (0, 0, 0)  This is a minimisation problem, i.e. a good colour is one that fits for (colour) --> 0.  We now tabulate our data as shown CSE, IUT
  • 11. 49  Start at a random pattern like this: Colour Red Green Blue C1 80 170 689 C2 130 690 15 C3 24 8 317 where Fitness for (C1) = 80 + 170 + 689 = 939 Fitness for (C2) = 130 + 690 + 15 = 835 Fitness for (C3) = 24 + 8 + 317 = 349 CSE, IUT
  • 12. 50 Fitness (C2) = 130 + 690 + 15 = 835 C1  Start at a random pattern like this: Colour Red Green Blue C1 80 170 689 C2 130 690 15 C3 24 8 317 FITTEST PLACED TOP C3 Fitness (C1) = 80 + 170 + 689 = 939 C2 Fitness (C3) = 24 + 8 + 317 = 349 CSE, IUT
  • 13. 51  After a Selection is done on the sample: ** Remember, this is a minimisation problem.. Colour Fitness C3 349 C2 835 C1 939 CSE, IUT
  • 14. 52 C4 24 8 15C4 is crossover(C3,C2)= (24, 8, 15) C6 is crossover(C2,C1)= (130, 690, 689) GA: Reproduction & Crossover  So far, we have this Colour Red Green Blue Colour Fitness C1 80 170 689 C3 349 C2 130 690 15 C2 835 C3 24 8 317 C1 939 Next step is to reproduce the pattern, like this, by crossing over: Colour Red Green Blue C5 is crossover(C3,C1)= (24, 8, 689) C5 24 8 689 C6 130 690 689 CSE, IUT
  • 15. 53  perform mutation, and we have C7 is obtained by mutating(4) =(24, 8, 13) C8 is obtained by mutating(5) =(25, 9, 689 ) C9 is obtained by mutating(6) =(128, 688, 689) Colour Red Green Blue New population of C7 24 8 13 3 chromosomes C8 25 9 689 C9 128 688 689 CSE, IUT
  • 16. 54 Conclusion (up to “mutation” to get a new data set)  Some solutions have improved (after first iteration): Getting better rather fast Slightly improved of the answer Fitness for C7 = (24 + 8 + 13) = 45 Fitness for C8 = (25 + 9 + 689) = 743 Fitness for C9 = (128 + 688 + 689 ) = 1505 If the process is iterated, population will converge to have fitness near to zero (colour) --> 0. Continue.............. CSE, IUT