Introduction To Genetic Algorithms (GA)
Introduction To Genetic Algorithms (GA)
algorithms(GA)
Module 4
Introduction to genetic
Algorithms(GA)
• Genetic Algorithm (GA) is a search-based optimization technique
based on the principles of Genetics and Natural Selection.
• It is frequently used to find optimal or near-optimal solutions to
difficult problems which otherwise would take a lifetime to solve.
• It is frequently used to solve optimization problems, in research,
and in machine learning.
Optimisatio
n• Optimization is the process of making something better.
• In any process, we have a set of inputs and a set of outputs as shown
in the following figure.
Optimization refers to finding the values of inputs in such a way that we get the “best” output values.
“best” varies from problem to problem, but in mathematical terms, it refers to maximizing or
minimizing one or more objective functions, by varying the input parameters.
Genetic
algorithms(GAs)
• Genetic Algorithms (GAs) are search based algorithms based on the
concepts of natural selection and genetics.
• GAs are a subset of a much larger branch of computation known
as Evolutionary Computation.
• Genetic Algorithms are the heuristic search and optimization
techniques that mimic the process of natural evolution.
• GAs were developed by John Holland and his students and colleagues
at the University of Michigan, most notably David E. Goldberg and has
since been tried on various optimization problems with a high degree
of success.
Survival of the fittest- Charles
Darwin
• Many people assume that "the fittest" refers to the strongest, biggest, or
smartest and most cunning individuals.
• The fittest individuals are simply the ones who have the combination
of traits that allow them to survive and produce more offspring in
their particular environment.
• What makes an individual fit all depends on the environment at the
time and the combination of traits that are most suited to flourishing in
it.
• He believed that evolution was a random process, that it was just
chance that an organism was born into just the right environment with
just the right combination of genes to allow it to survive in that
particular environment.
Theory of natural selection-
Example
• Giraffes have long necks
• Giraffes with slightly longer necks could feed on leaves of higher
branches when all lower ones had been eaten off.
• They had a better chance of survival.
• Favorable characteristic propagated through generations of
giraffes.
• Now, evolved species has long necks.
Exampl
e
• This longer necks may have due to the effect of mutation initially.
However as it was favourable, this was propagated over the
generations
•Thus genetic algorithms implement the
optimization strategies by simulating evolution
of species through natural selection
Advantages of
GAs
• Does not require any derivative information (which may not be available
for many real-world problems).
• Is faster and more efficient as compared to the traditional methods.
• Has very good parallel capabilities.
• Optimizes both continuous and discrete functions and also multi-objective
problems.
• 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.
Limitations of
GAs
• GAs are not suited for all problems, especially problems which are
simple and for which derivative information is available.
• Fitness value is calculated repeatedly which might be computationally
expensive for some problems.
• Being stochastic, there are no guarantees on the optimality or the
quality of the solution.
• If not implemented properly, the GA may not converge to the optimal
solution.
Reasons for
GAs
• The reasons why GAs are needed are as follows −
• Solving difficult problems
• Failure of gradient based methods
• Getting a good solutions fast
Failure of gradient based methods
Traditional calculus based methods work
by starting at a random point and by
moving in the direction of the gradient, till
we reach the top of the hill. This
technique is efficient and works very well
for single-peaked objective functions like
the cost function in linear regression.
But, in most real-world situations, we
have a very complex problem called as
landscapes, which are made of many
peaks and many valleys, which causes
such methods to fail, as they suffer from
an inherent tendency of getting stuck at
the local optima as shown in the following
figure.
Simple genetic
algorithms
Simple genetic
algorithm
GA basic
terminology
• Population − It is a subset of all the possible (encoded) solutions to
the given problem. The population for a GA is analogous to the
population for human beings except that instead of human beings,
we have Candidate Solutions representing human beings.
• Chromosomes − A chromosome is one such solution to the given
problem.
• Gene − A gene is one element position of a chromosome.
• Allele − It is the value a gene takes for a particular chromosome.
GA basic
terminology…
• Genotype − Genotype is the population in the computation space. In the
computation space, the solutions are represented in a way which can
be easily understood and manipulated using a computing system.
• Phenotype − Phenotype is the population in the actual real world
solution
space in which solutions are represented in a way they are represented
in real world situations.
• Decoding and Encoding − For simple problems, the phenotype and
genotype spaces are the same. However, in most of the cases,
the phenotype and genotype spaces are different.
• Decoding is a process of transforming a solution from the genotype to the
phenotype space,
• while encoding is a process of transforming from the phenotype to
genotype space.
GA basic
terminology
• Fitness Function − A fitness function simply defined is a function
which takes the solution as input and produces the suitability of the
solution as the output. In some cases, the fitness function and the
objective function may be the same, while in others it might be
different based on the problem.
• Genetic Operators − These alter the genetic composition of the
offspring. These include crossover, mutation, selection, etc.
Basic structure of
GA
GA parameters
• Crossover
• Mutation
• Selection
CROSS OVER
Crossove
r
• Crossover takes two individuals, and cuts their chromosome strings at
some randomly chosen position, to produce two “head" segments,
and two “tail" segments.
• The tail segments are then swapped over to produce two new full
length chromosomes.
crossover
Types of crossover-4
types
• There are 4 types of crossover: single point, two-point, uniform and
arithmetic crossover.
• Single point crossover - one crossover point is selected, binary string
from beginning of chromosome to the crossover point is copied from
one parent, the rest is copied from the second parent
•
11001011+11011111 =
11001111
Two-point
•crossover
Two point crossover - two crossover point are selected, binary string
from beginning of chromosome to the first crossover point is copied
from one parent, the part from the first to the second crossover point
is copied from the second parent and the rest is copied from the first
parent.
11001011 + 11011111 =
11011111
Uniform Crossover and arithmetic
crossover
Uniform crossover - bits are randomly copied from the first or from the second
parent