SlideShare a Scribd company logo
Genetic Algorithms
Introduction
 After scientists became disillusioned with
classical and neo-classical attempts at
modeling intelligence, they looked in
other directions.
 Two prominent fields arose,
connectionism (neural networking,
parallel processing) and evolutionary
computing.
 It is the latter that this essay deals with -
genetic algorithms and genetic
programming.
What is GA
 A genetic algorithm (or GA) is a search
technique used in computing to find true or
approximate solutions to optimization and search
problems.
 Genetic algorithms are categorized as global search
heuristics.
 Genetic algorithms are a particular class of
evolutionary algorithms that use techniques inspired
by evolutionary biology such as inheritance, mutation,
selection, and crossover (also called recombination).
What is GA
 Genetic algorithms are implemented as a
computer simulation in which a population of
abstract representations (called chromosomes
or the genotype or the genome) of candidate
solutions (called individuals, creatures, or
phenotypes) to an optimization problem
evolves toward better solutions.
 Traditionally, solutions are represented in binary
as strings of 0s and 1s, but other encodings are
also possible.
What is GA
 The evolution usually starts from a population
of randomly generated individuals and happens
in generations.
 In each generation, the fitness of every
individual in the population is evaluated, multiple
individuals are selected from the current
population (based on their fitness), and modified
(recombined and possibly mutated) to form a
new population.
What is GA

The new population is then used in the next
iteration of the algorithm.

Commonly, the algorithm terminates when
either a maximum number of generations has
been produced, or a satisfactory fitness level
has been reached for the population.

If the algorithm has terminated due to a
maximum number of generations, a
satisfactory solution may or may not have
been reached.
Key terms

Individual - Any possible solution

Population - Group of all individuals

Search Space - All possible solutions to the
problem

Chromosome - Blueprint for an individual

Trait - Possible aspect (features) of an individual

Allele - Possible settings of trait (black, blond,
etc.)

Locus -The position of a gene on the
chromosome

Genome - Collection of all chromosomes for an
individual
Chromosome, Genes and
Genomes
Genotype and Phenotype
 Genotype:
– Particular set of genes in a genome
 Phenotype:
– Physical characteristic of the genotype
(smart, beautiful, healthy, etc.)
Genotype and Phenotype
GA Requirements
 A typical genetic algorithm requires two things to be defined:
 a genetic representation of the solution domain, and

a fitness function to evaluate the solution domain.
 A standard representation of the solution is as an array of
bits.Arrays of other types and structures can be used in
essentially the same way.
 The main property that makes these genetic representations
convenient is that their parts are easily aligned due to their
fixed size, that facilitates simple crossover operation.
 Variable length representations may also be used, but
crossover implementation is more complex in this case.
 Tree-like representations are explored in Genetic
programming.
Representation
Chromosomes could be:
◦
Bit strings (0101 ...
1100)
◦
Real numbers (43.2 -33.1 ... 0.0
89.2)
◦
Permutations of element (E11 E3 E7 ... E1 E15)
◦
Lists of rules (R1 R2 R3 ... R22
R23)
◦ Program elements (genetic programming)
◦
... any data structure ...
GA Requirements
 The fitness function is defined over the genetic representation
and measures the quality of the represented solution.

The fitness function is always problem dependent.
 For instance, in the knapsack problem we want to maximize
the total value of objects that we can put in a knapsack of
some fixed capacity.
 A representation of a solution might be an array of bits,
where each bit represents a different object, and the value of
the bit (0 or 1) represents whether or not the object is in the
knapsack.
 Not every such representation is valid, as the size of objects
may exceed the capacity of the knapsack.
 The fitness of the solution is the sum of values of all objects in
the knapsack if the representation is valid, or 0 otherwise. In
some problems, it is hard or even impossible to define the
fitness expression; in these cases, interactive genetic
algorithms are used.
A fitness function
Basics of GA

The most common type of genetic algorithm works like this:

a population is created with a group of individuals created
randomly.

The individuals in the population are then evaluated.

The evaluation function is provided by the programmer and
gives the individuals a score based on how well they perform
at the given task.

Two individuals are then selected based on their fitness, the
higher the fitness, the higher the chance of being selected.

These individuals then "reproduce" to create one or more
offspring, after which the offspring are mutated randomly.

This continues until a suitable solution has been found or a
certain number of generations have passed, depending on the
needs of the programmer.
General Algorithm for GA

Initialization
 Initially many individual solutions are randomly
generated to form an initial population.The
population size depends on the nature of the
problem, but typically contains several hundreds or
thousands of possible solutions.
 Traditionally, the population is generated randomly,
covering the entire range of possible solutions (the
search space).
 Occasionally, the solutions may be "seeded" in areas
where optimal solutions are likely to be found.
General Algorithm for GA

Selection
 During each successive generation, a proportion of the
existing population is selected to breed a new generation.

Individual solutions are selected through a fitness-based
process, where fitter solutions (as measured by a fitness
function) are typically more likely to be selected.
 Certain selection methods rate the fitness of each solution
and preferentially select the best solutions. Other methods
rate only a random sample of the population, as this process
may be very time-consuming.
 Most functions are stochastic and designed so that a small
proportion of less fit solutions are selected.This helps keep
the diversity of the population large, preventing premature
convergence on poor solutions. Popular and well-studied
selection methods include roulette wheel selection and
tournament selection.
General Algorithm for GA
 In roulette wheel selection, individuals are
given a probability of being selected that is
directly proportionate to their fitness.
 Two individuals are then chosen randomly
based on these probabilities and produce
offspring.
General Algorithm for GA
RouletteWheel’s Selection Pseudo Code:
for all members of population
sum += fitness of this individual
end for
for all members of population
probability = sum of probabilities + (fitness / sum)
sum of probabilities += probability
end for
loop until new population is full
do this twice
number = Random between 0 and 1
for all members of population
if number > probability but less than next probability then
you have been selected
end for
end
create offspring
end loop
General Algorithm for GA
 Reproduction
 The next step is to generate a second generation population
of solutions from those selected through genetic operators:
crossover (also called recombination), and/or mutation.
 For each new solution to be produced, a pair of "parent"
solutions is selected for breeding from the pool selected
previously.
 By producing a "child" solution using the above methods of
crossover and mutation, a new solution is created which
typically shares many of the characteristics of its "parents".
New parents are selected for each child, and the process
continues until a new population of solutions of appropriate
size is generated.
General Algorithm for GA
 These processes ultimately result in the next
generation population of chromosomes that is
different from the initial generation.
 Generally the average fitness will have
increased by this procedure for the
population, since only the best organisms from
the first generation are selected for breeding,
along with a small proportion of less fit
solutions, for reasons already mentioned
above.
Crossover
 the most common type is single point crossover. In single
point crossover, you choose a locus at which you swap the
remaining alleles from on parent to the other.This is complex
and is best understood visually.
 As you can see, the children take one section of the
chromosome from each parent.
 The point at which the chromosome is broken depends on
the randomly selected crossover point.
 This particular method is called single point crossover
because only one crossover point exists. Sometimes only child
1 or child 2 is created, but oftentimes both offspring are
created and put into the new population.
 Crossover does not always occur, however. Sometimes, based
on a set probability, no crossover occurs and the parents are
copied directly to the new population.The probability of
crossover occurring is usually 60% to 70%.
Crossover
Mutation
 After selection and crossover, you now have a new population
full of individuals.
 Some are directly copied, and others are produced by
crossover.
 In order to ensure that the individuals are not all exactly the
same, you allow for a small chance of mutation.
 You loop through all the alleles of all the individuals, and if that
allele is selected for mutation, you can either change it by a
small amount or replace it with a new value.The probability of
mutation is usually between 1 and 2 tenths of a percent.
 Mutation is fairly simple.You just change the selected alleles
based on what you feel is necessary and move on. Mutation is,
however, vital to ensuring genetic diversity within the
population.
Mutation
General Algorithm for GA
 Termination
 This generational process is repeated until a
termination condition has been reached.
 Common terminating conditions are:
◦ A solution is found that satisfies minimum criteria
◦ Fixed number of generations reached
◦ Allocated budget (computation time/money) reached
◦ The highest ranking solution's fitness is reaching or has
reached a plateau such that successive iterations no longer
produce better results
◦ Manual inspection
◦ Any Combinations of the above
GA Pseudo-code
Choose initial population
Evaluate the fitness of each individual in the population
Repeat
Select best-ranking individuals to reproduce
Breed new generation through crossover and mutation (genetic
operations) and give birth to offspring
Evaluate the individual fitnesses of the offspring
Replace worst ranked part of population with offspring
Until <terminating condition>

More Related Content

Similar to Genetic Algorithms in Artificial Intelligence (20)

PPTX
introduction of genetic algorithm
ritambharaaatre
 
PPTX
GA.pptx
ShujatHussainGadi
 
PPTX
Genetic Algorithm
Pratheeban Rajendran
 
PPT
Genetic-Algorithms SDSDa SDD dfsAFF fsaf
dipesh257290
 
PPT
Genetic algorithms
Amna Saeed
 
PPT
Genetic algorithms full lecture
sadiacs
 
PPT
Genetic-Algorithms for engineering appl.ppt
prabhadasila2
 
PPTX
GA of a Paper 2012.pptx
waqasjavaid26
 
PPT
Genetic algorithms
Pradeep Kumar
 
PPTX
Genetic algorithm optimization technique.pptx
sridharece1
 
PPTX
Genetic Algorithm
Fatemeh Karimi
 
PDF
Introduction to Genetic Algorithms 2014
Aleksander Stensby
 
PPTX
Genetic Algorithms : A class of Evolutionary Algorithms
Kavya Barnadhya Hazarika
 
PPT
0101.genetic algorithm
Ahmad Almubarrok
 
PPT
Genetic algorithm
DurgeshPratapSIngh8
 
PPTX
Genetic Algorithm
SEKHARREDDYAMBATI
 
PPT
Ga
venki249
 
PPTX
Genetic algorithm
Megha V
 
PPT
Evolutionary algorithms
M S Prasad
 
PDF
A Review On Genetic Algorithm And Its Applications
Karen Gomez
 
introduction of genetic algorithm
ritambharaaatre
 
Genetic Algorithm
Pratheeban Rajendran
 
Genetic-Algorithms SDSDa SDD dfsAFF fsaf
dipesh257290
 
Genetic algorithms
Amna Saeed
 
Genetic algorithms full lecture
sadiacs
 
Genetic-Algorithms for engineering appl.ppt
prabhadasila2
 
GA of a Paper 2012.pptx
waqasjavaid26
 
Genetic algorithms
Pradeep Kumar
 
Genetic algorithm optimization technique.pptx
sridharece1
 
Genetic Algorithm
Fatemeh Karimi
 
Introduction to Genetic Algorithms 2014
Aleksander Stensby
 
Genetic Algorithms : A class of Evolutionary Algorithms
Kavya Barnadhya Hazarika
 
0101.genetic algorithm
Ahmad Almubarrok
 
Genetic algorithm
DurgeshPratapSIngh8
 
Genetic Algorithm
SEKHARREDDYAMBATI
 
Genetic algorithm
Megha V
 
Evolutionary algorithms
M S Prasad
 
A Review On Genetic Algorithm And Its Applications
Karen Gomez
 

Recently uploaded (20)

PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Ad

Genetic Algorithms in Artificial Intelligence

  • 2. Introduction  After scientists became disillusioned with classical and neo-classical attempts at modeling intelligence, they looked in other directions.  Two prominent fields arose, connectionism (neural networking, parallel processing) and evolutionary computing.  It is the latter that this essay deals with - genetic algorithms and genetic programming.
  • 3. What is GA  A genetic algorithm (or GA) is a search technique used in computing to find true or approximate solutions to optimization and search problems.  Genetic algorithms are categorized as global search heuristics.  Genetic algorithms are a particular class of evolutionary algorithms that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover (also called recombination).
  • 4. What is GA  Genetic algorithms are implemented as a computer simulation in which a population of abstract representations (called chromosomes or the genotype or the genome) of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem evolves toward better solutions.  Traditionally, solutions are represented in binary as strings of 0s and 1s, but other encodings are also possible.
  • 5. What is GA  The evolution usually starts from a population of randomly generated individuals and happens in generations.  In each generation, the fitness of every individual in the population is evaluated, multiple individuals are selected from the current population (based on their fitness), and modified (recombined and possibly mutated) to form a new population.
  • 6. What is GA  The new population is then used in the next iteration of the algorithm.  Commonly, the algorithm terminates when either a maximum number of generations has been produced, or a satisfactory fitness level has been reached for the population.  If the algorithm has terminated due to a maximum number of generations, a satisfactory solution may or may not have been reached.
  • 7. Key terms  Individual - Any possible solution  Population - Group of all individuals  Search Space - All possible solutions to the problem  Chromosome - Blueprint for an individual  Trait - Possible aspect (features) of an individual  Allele - Possible settings of trait (black, blond, etc.)  Locus -The position of a gene on the chromosome  Genome - Collection of all chromosomes for an individual
  • 9. Genotype and Phenotype  Genotype: – Particular set of genes in a genome  Phenotype: – Physical characteristic of the genotype (smart, beautiful, healthy, etc.)
  • 11. GA Requirements  A typical genetic algorithm requires two things to be defined:  a genetic representation of the solution domain, and  a fitness function to evaluate the solution domain.  A standard representation of the solution is as an array of bits.Arrays of other types and structures can be used in essentially the same way.  The main property that makes these genetic representations convenient is that their parts are easily aligned due to their fixed size, that facilitates simple crossover operation.  Variable length representations may also be used, but crossover implementation is more complex in this case.  Tree-like representations are explored in Genetic programming.
  • 12. Representation Chromosomes could be: ◦ Bit strings (0101 ... 1100) ◦ Real numbers (43.2 -33.1 ... 0.0 89.2) ◦ Permutations of element (E11 E3 E7 ... E1 E15) ◦ Lists of rules (R1 R2 R3 ... R22 R23) ◦ Program elements (genetic programming) ◦ ... any data structure ...
  • 13. GA Requirements  The fitness function is defined over the genetic representation and measures the quality of the represented solution.  The fitness function is always problem dependent.  For instance, in the knapsack problem we want to maximize the total value of objects that we can put in a knapsack of some fixed capacity.  A representation of a solution might be an array of bits, where each bit represents a different object, and the value of the bit (0 or 1) represents whether or not the object is in the knapsack.  Not every such representation is valid, as the size of objects may exceed the capacity of the knapsack.  The fitness of the solution is the sum of values of all objects in the knapsack if the representation is valid, or 0 otherwise. In some problems, it is hard or even impossible to define the fitness expression; in these cases, interactive genetic algorithms are used.
  • 15. Basics of GA  The most common type of genetic algorithm works like this:  a population is created with a group of individuals created randomly.  The individuals in the population are then evaluated.  The evaluation function is provided by the programmer and gives the individuals a score based on how well they perform at the given task.  Two individuals are then selected based on their fitness, the higher the fitness, the higher the chance of being selected.  These individuals then "reproduce" to create one or more offspring, after which the offspring are mutated randomly.  This continues until a suitable solution has been found or a certain number of generations have passed, depending on the needs of the programmer.
  • 16. General Algorithm for GA  Initialization  Initially many individual solutions are randomly generated to form an initial population.The population size depends on the nature of the problem, but typically contains several hundreds or thousands of possible solutions.  Traditionally, the population is generated randomly, covering the entire range of possible solutions (the search space).  Occasionally, the solutions may be "seeded" in areas where optimal solutions are likely to be found.
  • 17. General Algorithm for GA  Selection  During each successive generation, a proportion of the existing population is selected to breed a new generation.  Individual solutions are selected through a fitness-based process, where fitter solutions (as measured by a fitness function) are typically more likely to be selected.  Certain selection methods rate the fitness of each solution and preferentially select the best solutions. Other methods rate only a random sample of the population, as this process may be very time-consuming.  Most functions are stochastic and designed so that a small proportion of less fit solutions are selected.This helps keep the diversity of the population large, preventing premature convergence on poor solutions. Popular and well-studied selection methods include roulette wheel selection and tournament selection.
  • 18. General Algorithm for GA  In roulette wheel selection, individuals are given a probability of being selected that is directly proportionate to their fitness.  Two individuals are then chosen randomly based on these probabilities and produce offspring.
  • 19. General Algorithm for GA RouletteWheel’s Selection Pseudo Code: for all members of population sum += fitness of this individual end for for all members of population probability = sum of probabilities + (fitness / sum) sum of probabilities += probability end for loop until new population is full do this twice number = Random between 0 and 1 for all members of population if number > probability but less than next probability then you have been selected end for end create offspring end loop
  • 20. General Algorithm for GA  Reproduction  The next step is to generate a second generation population of solutions from those selected through genetic operators: crossover (also called recombination), and/or mutation.  For each new solution to be produced, a pair of "parent" solutions is selected for breeding from the pool selected previously.  By producing a "child" solution using the above methods of crossover and mutation, a new solution is created which typically shares many of the characteristics of its "parents". New parents are selected for each child, and the process continues until a new population of solutions of appropriate size is generated.
  • 21. General Algorithm for GA  These processes ultimately result in the next generation population of chromosomes that is different from the initial generation.  Generally the average fitness will have increased by this procedure for the population, since only the best organisms from the first generation are selected for breeding, along with a small proportion of less fit solutions, for reasons already mentioned above.
  • 22. Crossover  the most common type is single point crossover. In single point crossover, you choose a locus at which you swap the remaining alleles from on parent to the other.This is complex and is best understood visually.  As you can see, the children take one section of the chromosome from each parent.  The point at which the chromosome is broken depends on the randomly selected crossover point.  This particular method is called single point crossover because only one crossover point exists. Sometimes only child 1 or child 2 is created, but oftentimes both offspring are created and put into the new population.  Crossover does not always occur, however. Sometimes, based on a set probability, no crossover occurs and the parents are copied directly to the new population.The probability of crossover occurring is usually 60% to 70%.
  • 24. Mutation  After selection and crossover, you now have a new population full of individuals.  Some are directly copied, and others are produced by crossover.  In order to ensure that the individuals are not all exactly the same, you allow for a small chance of mutation.  You loop through all the alleles of all the individuals, and if that allele is selected for mutation, you can either change it by a small amount or replace it with a new value.The probability of mutation is usually between 1 and 2 tenths of a percent.  Mutation is fairly simple.You just change the selected alleles based on what you feel is necessary and move on. Mutation is, however, vital to ensuring genetic diversity within the population.
  • 26. General Algorithm for GA  Termination  This generational process is repeated until a termination condition has been reached.  Common terminating conditions are: ◦ A solution is found that satisfies minimum criteria ◦ Fixed number of generations reached ◦ Allocated budget (computation time/money) reached ◦ The highest ranking solution's fitness is reaching or has reached a plateau such that successive iterations no longer produce better results ◦ Manual inspection ◦ Any Combinations of the above
  • 27. GA Pseudo-code Choose initial population Evaluate the fitness of each individual in the population Repeat Select best-ranking individuals to reproduce Breed new generation through crossover and mutation (genetic operations) and give birth to offspring Evaluate the individual fitnesses of the offspring Replace worst ranked part of population with offspring Until <terminating condition>