By Mr. Ubaid Ur Rahman
A genetic algorithm is a search heuristic that is inspired
by Charles Darwin’s theory of natural evolution. This
algorithm reflects the process of natural selection where
the fittest individuals are selected for reproduction in
order to produce offspring of the next generation.
The process of natural selection starts with the selection of
fittest individuals from a population.
They produce offspring which inherit the characteristics of
the parents and will be added to the next generation.
If parents have better fitness, their offspring will be better
than parents and have a better chance at surviving.
This process keeps on iterating and at the end, a generation
with the fittest individuals will be found.
This notion can be applied for a search problem. We consider
a set of solutions for a problem and select the set of best ones
out of them.
 Initial population
 Fitness function
 Selection
 Crossover
 Mutation
The process begins with a set of individuals which is called
a Population. Each individual is a solution to the problem
you want to solve.
An individual is characterized by a set of parameters
(variables) known as Genes. Genes are joined into a string
to form a Chromosome (solution).
The fitness function determines how fit an
individual is (the ability of an individual to
compete with other individuals).
It gives a fitness score to each individual. The
probability that an individual will be selected for
reproduction is based on its fitness score.
The idea of selection phase is to select the fittest
individuals and let them pass their genes to the next
generation.
Two pairs of individuals (parents) are selected based on
their fitness scores. Individuals with high fitness have
more chance to be selected for reproduction.
 Crossover is the most significant phase in
a genetic algorithm. For each pair of
parents to be mated, a crossover point is
chosen at random from within the genes.
 For example, consider the crossover point
to be 3 as shown below.
 Offspring are created by exchanging the
genes of parents among themselves until
the crossover point is reached.
 The new offspring are added to the
population.
 In certain new offspring formed,
some of their genes can be
subjected to a mutation with a
low random probability. This
implies that some of the bits in
the bit string can be flipped.
 Mutation occurs to maintain
diversity within the population.
The algorithm terminates if the population has converged
(does not produce offspring which are significantly different
from the previous generation).
Then it is said that the genetic algorithm has provided a set
of solutions to our problem.
The population has a fixed size. As new generations are
formed, individuals with least fitness die, providing space
for new offspring.
The sequence of phases is repeated to produce individuals in
each new generation which are better than the previous
generation.
WORKFLO
W OF A
SIMPLE
GENETIC
ALGORIT
HM
Is faster and more efficient as compared to the traditional
methods.
Provides a list of “good” solutions and not just a single
solution.
Always gets an answer to the problem, which gets better
over the time.
Useful when the search space is very large and there are a
large number of parameters involved.
GAs are not suited for all problems.
Fitness value is calculated repeatedly which might be
computationally expensive for some problems.
If not implemented properly, the GA may not converge to
the optimal solution.
 A search space is a set of all possible solutions to the problem.
Traditional Algorithms maintain only one set in a search space
whereas Genetic Algorithms use several sets in a search space.
 Traditional Algorithms require more information to perform a
search whereas Genetic Algorithms just require one objective
function to calculate the fitness of an individual.
 Traditional Algorithms can only produce one solution in the end
whereas in Genetic Algorithms multiple optimal solutions can be
obtained from different generations.
Real-world problems are multi-modal (contains multiple
locally optimal solutions), the traditional algorithms don’t
handle well these problems whereas Genetic Algorithms,
with the right parameter setting, can handle these problems
very well because of the large solution space.
Explanation and example of genetic algorithm

Explanation and example of genetic algorithm

  • 1.
    By Mr. UbaidUr Rahman
  • 2.
    A genetic algorithmis a search heuristic that is inspired by Charles Darwin’s theory of natural evolution. This algorithm reflects the process of natural selection where the fittest individuals are selected for reproduction in order to produce offspring of the next generation.
  • 3.
    The process ofnatural selection starts with the selection of fittest individuals from a population. They produce offspring which inherit the characteristics of the parents and will be added to the next generation. If parents have better fitness, their offspring will be better than parents and have a better chance at surviving. This process keeps on iterating and at the end, a generation with the fittest individuals will be found. This notion can be applied for a search problem. We consider a set of solutions for a problem and select the set of best ones out of them.
  • 4.
     Initial population Fitness function  Selection  Crossover  Mutation
  • 5.
    The process beginswith a set of individuals which is called a Population. Each individual is a solution to the problem you want to solve. An individual is characterized by a set of parameters (variables) known as Genes. Genes are joined into a string to form a Chromosome (solution).
  • 6.
    The fitness functiondetermines how fit an individual is (the ability of an individual to compete with other individuals). It gives a fitness score to each individual. The probability that an individual will be selected for reproduction is based on its fitness score.
  • 7.
    The idea ofselection phase is to select the fittest individuals and let them pass their genes to the next generation. Two pairs of individuals (parents) are selected based on their fitness scores. Individuals with high fitness have more chance to be selected for reproduction.
  • 8.
     Crossover isthe most significant phase in a genetic algorithm. For each pair of parents to be mated, a crossover point is chosen at random from within the genes.  For example, consider the crossover point to be 3 as shown below.  Offspring are created by exchanging the genes of parents among themselves until the crossover point is reached.  The new offspring are added to the population.
  • 9.
     In certainnew offspring formed, some of their genes can be subjected to a mutation with a low random probability. This implies that some of the bits in the bit string can be flipped.  Mutation occurs to maintain diversity within the population.
  • 10.
    The algorithm terminatesif the population has converged (does not produce offspring which are significantly different from the previous generation). Then it is said that the genetic algorithm has provided a set of solutions to our problem. The population has a fixed size. As new generations are formed, individuals with least fitness die, providing space for new offspring. The sequence of phases is repeated to produce individuals in each new generation which are better than the previous generation.
  • 11.
  • 12.
    Is faster andmore efficient as compared to the traditional methods. Provides a list of “good” solutions and not just a single solution. Always gets an answer to the problem, which gets better over the time. Useful when the search space is very large and there are a large number of parameters involved.
  • 13.
    GAs are notsuited for all problems. Fitness value is calculated repeatedly which might be computationally expensive for some problems. If not implemented properly, the GA may not converge to the optimal solution.
  • 15.
     A searchspace is a set of all possible solutions to the problem. Traditional Algorithms maintain only one set in a search space whereas Genetic Algorithms use several sets in a search space.  Traditional Algorithms require more information to perform a search whereas Genetic Algorithms just require one objective function to calculate the fitness of an individual.  Traditional Algorithms can only produce one solution in the end whereas in Genetic Algorithms multiple optimal solutions can be obtained from different generations.
  • 16.
    Real-world problems aremulti-modal (contains multiple locally optimal solutions), the traditional algorithms don’t handle well these problems whereas Genetic Algorithms, with the right parameter setting, can handle these problems very well because of the large solution space.