Unit 5
Unit 5
Unit -5
Unit 5
• Unit V: Genetic algorithm :
Genetic Algorithm: An Overview, GA in problem
solving, Implementation of GA fundamentals,
basic concepts, working principle, encoding,
fitness function, reproduction, Genetic modelling:
Inheritance operator, cross over, inversion &
deletion, mutation operator, Bitwise operator,
Generational Cycle, Convergence of GA,
Applications & advances in GA, Differences &
similarities between GA & other traditional
method
Introduction to Genetic Algorithms
• Let’s start with the famous quote by Charles
Darwin:
– It is not the strongest of the species that survives,
nor the most intelligent , but the one most
responsive to change.
• Actually, the entire concept of a genetic
algorithm is based on the above line.
Basic concept of GA
• Let us understand with a basic concept of GA with
example:
• Let’s take a hypothetical situation where, you are head of a
country, and in order to keep your city safe from bad things,
you implement a policy like this.
– You select all the good people, and ask them to extend their
generation by having their children.
– This repeats for a few generations.
– You will notice that now you have an entire population of good
people.
• Now, that may not be entirely possible, but this example
was just to help you understand the concept.So the basic
idea was that we changed the input (i.e. population) such
that we get better output (i.e. better country).
Basic concept of GA
• Concept of a genetic algorithm is somewhat related to
biology. So let’s us quickly grasp some little concepts,
so that we can draw a parallel line between them.
• Cells are the basic building block of all living things.
• Therefore in each cell, there is the same set of
chromosomes. Chromosome are basically the strings of
DNA.
• Traditionally, these chromosomes are represented in
binary as strings of 0’s and 1’s.
• A chromosome consists of genes, commonly referred
as blocks of DNA, where each gene encodes a specific
trait, for example hair color or eye color.
Basic concept of GA
What is a Genetic Algorithm?
• Let’s get back to the example we discussed above and
summarize what we did.
– Firstly, we defined our initial population as our countrymen.
– We defined a function to classify whether is a person is good or
bad.
– Then we selected good people for mating to produce their off-
springs.
– And finally, these off-springs replace the bad people from the
population and this process repeats.
• This is how genetic algorithm actually works, which
basically tries to mimic the human evolution to some
extent.
• So to formalize a definition of a genetic algorithm, we can
say that it is an optimization technique, which tries to find
out such values of input so that we get the best output
values or results.
Genetic algorithm
• 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.
Genetic algorithm
• 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.
working of a genetic algorithm
• The working
of a genetic
algorithm is
also derived
from biology,
which is as
shown in the
image below.
Components of a GA
A problem to solve, and ...
• Encoding technique (gene, chromosome)
• Initialization procedure (creation)
• Evaluation function (environment)
• Selection of parents (reproduction)
• Genetic operators (mutation, recombination)
• Parameter settings (practice and art)
GA in problem solving
• If you haven’t come across this problem, let me
introduce my version of this problem.
• Let’s say, you are going to spend a month in the
wilderness. Only thing you are carrying is the
backpack which can hold a maximum weight
of 30 kg. Now you have different survival items,
each having its own “Survival Points” (which are
given for each item in the table). So, your
objective is maximise the survival points.
GA in problem solving
• Here is the table giving details about each
item.
Some important terms
Principle of GA
Basic outline of GA (Working)
Encoding
Population
• Population is a subset of solutions in the current generation. It can also be defined
as a set of chromosomes. There are several things to be kept in mind when dealing
with GA population −
• The diversity of the population should be maintained otherwise it might lead to
premature convergence.
• The population size should not be kept very large as it can cause a GA to slow
down, while a smaller population might not be enough for a good mating pool.
Therefore, an optimal population size needs to be decided by trial and error.
• The population is usually defined as a two dimensional array of – size population,
size x, chromosome size.
• Population Initialization
• There are two primary methods to initialize a population in a GA. They are −
• Random Initialization − Populate the initial population with completely random
solutions.
• Heuristic initialization − Populate the initial population using a known heuristic for
the problem.
Fitness function
• The fitness function simply defined is a function which takes a candidate
solution to the problem as input and produces as output how “fit” our
how “good” the solution is with respect to the problem in consideration.
• Calculation of fitness value is done repeatedly in a GA and therefore it
should be sufficiently fast. A slow computation of the fitness value can
adversely affect a GA and make it exceptionally slow.
• In most cases the fitness function and the objective function are the same
as the objective is to either maximize or minimize the given objective
function. However, for more complex problems with multiple objectives
and constraints, an Algorithm Designer might choose to have a different
fitness function.
• A fitness function should possess the following characteristics −
• The fitness function should be sufficiently fast to compute.
• It must quantitatively measure how fit a given solution is or how fit
individuals can be produced from the given solution.
• In some cases, calculating the fitness function directly might not be
possible due to the inherent complexities of the problem at hand. In such
cases, we do fitness approximation to suit our needs.
Genetic Operators
Methods of selection