SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
GENETIC ALGORITHM EXAMPLE
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
(TOTAL MARKS = 30)
Suppose we want to maximize the number of ones in a string of 10 binary digits.
a) What is the best possible string? (5 marks)
1111111111 (5 marks)
b) How much number of strings can be generated for this problem? (5 marks)
210
= 1024 (5 marks)
Now we are going to apply genetic algorithms to solve this problem. We toss a fair coin 60 times
and get the following initial population.
s1 = 1111010101
s2 = 0111000101
s3 = 1110110101
s4 = 0100010011
s5 = 1110111101
s6 = 0100110000
c) Suggest an appropriate fitness function (5 marks)
F (s) = Number of 1s in the binary string s (5 marks)
d) Evaluate the fitness of each individual (6 marks)
F (s1) = 7 (1 marks)
F (s2) = 5 (1 marks)
F (s3) = 7 (1 marks)
F (s4) = 4 (1 marks)
F (s5) = 8 (1 marks)
F (s6) = 3 (1 marks)
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)
e) Apply single point cross over for the couples (s1`, s3`) and (s2`, s6`) at the points 3 and 6
respectively (6 marks)
For couple (s1`, s3`):
s1`` = 1110111101 (1.5 marks)
s3`` = 1111010101 (1.5 marks)
For couple (s2`, s6`):
s2`` = 1110111101 (1.5 marks)
s6`` = 1110110101 (1.5 marks)
f) Mutate the derived population with 0.1 probability (3 marks)
Derived population,
s1`` = 1110111101
s2`` = 1110111101
s3`` = 1111010101
s4`` = 0111000101
s5`` = 0100010011
s6`` = 1110110101
Note: Select 6 (= 10 * 6 * 0.1) random digits and perturb. (0.5 * 6 marks). Following is just
an example.
s1``` = 1111111101
s2``` = 1100111101
s3``` = 1111000101
s4``` = 0111000001
s5``` = 0000010011
s6``` = 1110100101

Más contenido relacionado

Destacado

Linked List Implementation of Stack in C
Linked List Implementation of Stack in CLinked List Implementation of Stack in C
Linked List Implementation of Stack in C
Kasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in CDigital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in C
Kasun Ranga Wijeweera
 
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in C
Kasun Ranga Wijeweera
 
Himanshu Arora_Nurse Scheduling using GA
Himanshu Arora_Nurse Scheduling using GAHimanshu Arora_Nurse Scheduling using GA
Himanshu Arora_Nurse Scheduling using GA
HIMANSHU ARORA
 
Dominance-Based Pareto-Surrogate for Multi-Objective Optimization
Dominance-Based Pareto-Surrogate for Multi-Objective OptimizationDominance-Based Pareto-Surrogate for Multi-Objective Optimization
Dominance-Based Pareto-Surrogate for Multi-Objective Optimization
Ilya Loshchilov
 
Complexity in Ambiguous Problem Solution Search: Group Dynamics, Search Tac...
Complexity in Ambiguous Problem Solution Search:   Group Dynamics, Search Tac...Complexity in Ambiguous Problem Solution Search:   Group Dynamics, Search Tac...
Complexity in Ambiguous Problem Solution Search: Group Dynamics, Search Tac...
Dr. Elliot Bendoly
 

Destacado (19)

Wave ECG
Wave ECGWave ECG
Wave ECG
 
Flood Filling Algorithm in C
Flood Filling Algorithm in CFlood Filling Algorithm in C
Flood Filling Algorithm in C
 
Linked List Implementation of Stack in C
Linked List Implementation of Stack in CLinked List Implementation of Stack in C
Linked List Implementation of Stack in C
 
Exercises for Two Dimensional Geometric Transformations
Exercises for Two Dimensional Geometric TransformationsExercises for Two Dimensional Geometric Transformations
Exercises for Two Dimensional Geometric Transformations
 
Computing the Area of a Polygon
Computing the Area of a PolygonComputing the Area of a Polygon
Computing the Area of a Polygon
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Optimisation and Tradeoff Analysis Tool for Asset Management Planning and Pro...
Optimisation and Tradeoff Analysis Tool for Asset Management Planning and Pro...Optimisation and Tradeoff Analysis Tool for Asset Management Planning and Pro...
Optimisation and Tradeoff Analysis Tool for Asset Management Planning and Pro...
 
Digital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in CDigital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in C
 
Exercises for Convexity of Polygons
Exercises for Convexity of PolygonsExercises for Convexity of Polygons
Exercises for Convexity of Polygons
 
Multi-objective Optimisation of a Water Distribution Network with a Sequence-...
Multi-objective Optimisation of a Water Distribution Network with a Sequence-...Multi-objective Optimisation of a Water Distribution Network with a Sequence-...
Multi-objective Optimisation of a Water Distribution Network with a Sequence-...
 
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in C
 
Himanshu Arora_Nurse Scheduling using GA
Himanshu Arora_Nurse Scheduling using GAHimanshu Arora_Nurse Scheduling using GA
Himanshu Arora_Nurse Scheduling using GA
 
Logix2017
Logix2017Logix2017
Logix2017
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Principles of Object Oriented Programming
Principles of Object Oriented ProgrammingPrinciples of Object Oriented Programming
Principles of Object Oriented Programming
 
Dominance-Based Pareto-Surrogate for Multi-Objective Optimization
Dominance-Based Pareto-Surrogate for Multi-Objective OptimizationDominance-Based Pareto-Surrogate for Multi-Objective Optimization
Dominance-Based Pareto-Surrogate for Multi-Objective Optimization
 
Multi-Objective Optimization Algorithms for Finite Element Model Updating. Nt...
Multi-Objective Optimization Algorithms for Finite Element Model Updating. Nt...Multi-Objective Optimization Algorithms for Finite Element Model Updating. Nt...
Multi-Objective Optimization Algorithms for Finite Element Model Updating. Nt...
 
Complexity in Ambiguous Problem Solution Search: Group Dynamics, Search Tac...
Complexity in Ambiguous Problem Solution Search:   Group Dynamics, Search Tac...Complexity in Ambiguous Problem Solution Search:   Group Dynamics, Search Tac...
Complexity in Ambiguous Problem Solution Search: Group Dynamics, Search Tac...
 

Más de Kasun Ranga Wijeweera

Más de Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Genetic Algorithm Example

  • 1. GENETIC ALGORITHM EXAMPLE Author: Kasun Ranga Wijeweera Email: krw19870829@gmail.com (TOTAL MARKS = 30) Suppose we want to maximize the number of ones in a string of 10 binary digits. a) What is the best possible string? (5 marks) 1111111111 (5 marks) b) How much number of strings can be generated for this problem? (5 marks) 210 = 1024 (5 marks) Now we are going to apply genetic algorithms to solve this problem. We toss a fair coin 60 times and get the following initial population. s1 = 1111010101 s2 = 0111000101 s3 = 1110110101 s4 = 0100010011 s5 = 1110111101 s6 = 0100110000 c) Suggest an appropriate fitness function (5 marks) F (s) = Number of 1s in the binary string s (5 marks) d) Evaluate the fitness of each individual (6 marks) F (s1) = 7 (1 marks) F (s2) = 5 (1 marks) F (s3) = 7 (1 marks) F (s4) = 4 (1 marks) F (s5) = 8 (1 marks) F (s6) = 3 (1 marks)
  • 2. 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) e) Apply single point cross over for the couples (s1`, s3`) and (s2`, s6`) at the points 3 and 6 respectively (6 marks) For couple (s1`, s3`): s1`` = 1110111101 (1.5 marks) s3`` = 1111010101 (1.5 marks) For couple (s2`, s6`): s2`` = 1110111101 (1.5 marks) s6`` = 1110110101 (1.5 marks) f) Mutate the derived population with 0.1 probability (3 marks) Derived population, s1`` = 1110111101 s2`` = 1110111101 s3`` = 1111010101 s4`` = 0111000101 s5`` = 0100010011 s6`` = 1110110101 Note: Select 6 (= 10 * 6 * 0.1) random digits and perturb. (0.5 * 6 marks). Following is just an example.
  • 3. s1``` = 1111111101 s2``` = 1100111101 s3``` = 1111000101 s4``` = 0111000001 s5``` = 0000010011 s6``` = 1110100101