Genetic Algorithms

Download as pdf or txt
Download as pdf or txt
You are on page 1of 94

SOFT COMPUTING

Subject Code:PCP7H010
Credit:3-0-0
7th Semester
Branch:ETC
By
Dr. Sakuntala Mahapatra
Dean (R &D), Professor and HOD
Dept. of Electronics & Telecommunication Engg.
TRIDENT ACADEMY OF TECHNOLOGY
BHUBANESWAR, ODISHA

@ Dr. Sakuntala Mahapatra 23/11/2020


Contents

 Introduction to Genetic Algorithm


 Basic Concepts of GA
 Encoding Schemes in GA
 Genetic Algorithms - Fitness Function
 Reproduction (OR) Selection

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 2


PPT CONTENT
EVOLUTIONARY COMPUTING
GENETIC ALGORITHMS(GA)
CLASS-21
(MODULE-1V)
DATE:23/11/2020
TIME:12.15 PM-1.15 PM

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 3


Introduction to Genetic Algorithm
 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 4


Introduction to Optimization
 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 5


Introduction to Optimization
 Optimization refers to finding the values of inputs
in such a way that we get the “best” output values.
The definition of “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.
 The set of all possible solutions or values which the
inputs can take make up the search space. In this
search space, lies a point or a set of points which
gives the optimal solution. The aim of optimization
is to find that point or set of points in the search
space.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 6


Introduction to Genetic Algorithm
 Nature has always been a great source of
inspiration to all mankind. 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.
 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 7


Introduction to Genetic Algorithm
 In GAs, we have a pool or a population of
possible solutions to the given problem.
 These solutions then undergo recombination and
mutation (like in natural genetics), producing new
children, and the process is repeated over various
generations.
 Each individual (or candidate solution) is assigned
a fitness value (based on its objective function
value) and the fitter individuals are given a higher
chance to mate and yield more “fitter” individuals.
 This is in line with the Darwinian Theory of
“Survival of the Fittest”.
@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 8
Introduction to Genetic Algorithm
 In this way we keep “evolving” better individuals
or solutions over generations, till we reach a
stopping criterion.
 Genetic Algorithms are sufficiently randomized
in nature, but they perform much better than
random local search (in which we just try
various random solutions, keeping track of the
best so far), as they exploit historical
information as well.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 9


Advantages of GAs
GAs have various advantages which have made them immensely
popular.These include −
 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.
 GA 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 10


Limitations of GAs
Like any technique, GAs also suffer from a few
limitations.These include −
 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 11


Genetic Algorithm – Motivation
 Genetic Algorithms have the ability to deliver a
“good-enough” solution “fast-enough”. This makes
genetic algorithms attractive for use in solving
optimization problems. The reasons why GAs are
needed are as follows −
1. Solving Difficult Problems
 In computer science, there is a large set of problems,
which are NP-Hard. What this essentially means is
that, even the most powerful computing systems take
a very long time (even years!) to solve that problem.
In such a scenario, GAs prove to be an efficient tool
to provide usable near-optimal solutions in a
short amount of time.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 12


Genetic Algorithm – Motivation
2. 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 13


Genetic Algorithm – Motivation

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 14


Genetic Algorithm – Motivation
3. Getting a Good Solution Fast
 Some difficult problems like the Travelling
Salesperson Problem (TSP), have real-world
applications like path finding and VLSI Design.
Now imagine that you are using your GPS
Navigation system, and it takes a few minutes
(or even a few hours) to compute the “optimal”
path from the source to destination. Delay in
such real world applications is not acceptable
and therefore a “good-enough” solution, which
is delivered “fast” is what is required.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 15


Basic Concepts of GA
 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.
@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 16
Basic Concepts of GA
(Biological Inspiration)

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 17


Basic Concepts of GA
(Biological Inspiration)

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 18


Basic Concepts of GA

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 19


Basic Concepts of GA

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 20


Basic Concepts of GA
 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. Decoding should be fast as it is carried out
repeatedly in a GA during the fitness value calculation.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 21


Basic Concepts of GA

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 22


Basic Concepts of GA
 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 23


Basic Structure of GA
 The basic structure of a GA is as follows −
 We start with an initial population (which may
be generated at random or seeded by other
heuristics), select parents from this population
for mating. Apply crossover and mutation
operators on the parents to generate new off-
springs. And finally these off-springs replace the
existing individuals in the population and the
process repeats. In this way genetic algorithms
actually try to mimic the human evolution to
some extent.
@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 24
Basic Structure of GA

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 25


Basic Structure of GA
1. Firstly, we defined our initial population as our countrymen.
2. We defined a function to classify whether is a person is good
or bad.
3. Then we selected good people for mating to produce their
off-springs.
4. 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.

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 26


Basic Structure of GA

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 27


GA Basic Program

@ Dr. Sakuntala Mahapatra 23/11/2020 Genetic Algorithms 28


PPT CONTENT
EVOLUTIONARY COMPUTING
GENETIC ALGORITHMS(GA)
CLASS-22
(MODULE-1V)
DATE:24/11/2020
TIME:12.15 PM-1.15 PM

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 29


Genotype Representation
 One of the most important decisions to make
while implementing a genetic algorithm is
deciding the representation that we will use to
represent our solutions. It has been observed
that improper representation can lead to poor
performance of the GA.
 Therefore, choosing a proper representation,
having a proper definition of the mappings
between the phenotype and genotype spaces is
essential for the success of a GA.
 However, representation is highly problem
specific.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 30


Encoding Schemes in GA
 Genetic Algorithm uses metaphor
consisting of two distinct elements :
1. Individual
2. Population
 An individual is a single solution while a
population is a set of individuals at an
instant of searching process.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 31


Individual Representation :Phenotype
and Genotype

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 32


Individual Representation :Phenotype
and Genotype

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 33


Different Encoding Schemes
 Binary encoding
 Real value encoding
 Order encoding
 Tree encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 34


Different Encoding Schemes
 Often, GAs are specified according to the encoding
scheme it follows.
For example:
 Encoding Scheme
 Binary encoding –> Binary Coded GA or simply Binary
GA
 Real value encoding –> Real Coded GA or simply Real
GA
 Order encoding –> Order GA (also called as
Permuted GA)
 Tree encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 35


Encoding techniques

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 36


Binary Encoding

 This is one of the simplest and most widely used


representation in GAs. In this type of representation the
genotype consists of bit strings.
 For some problems when the solution space consists of
Boolean decision variables – yes or no, the binary
representation is natural.
 For problems, specifically those dealing with numbers,
we can represent the numbers with their binary
representation.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 37


Binary Encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 38


Binary Encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 39


Binary Encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 40


Pros and cons of Binary encoding
scheme

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 41


Real value encoding
 For problems where we want to define the genes using
continuous rather than discrete variables, the real
valued representation is the most natural.
 The precision of these real valued or floating point
numbers is however limited to the computer.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 42


Real value encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 43


Real value encoding with binary codes

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 44


Real value encoding with binary codes

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 45


Real value encoding with binary codes

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 46


Real value encoding with binary codes

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 47


Integer Encoding

 For discrete valued genes, we cannot always limit the


solution space to binary „yes‟ or „no‟. For example, if we
want to encode the four distances – North, South, East
and West, we can encode them as {0,1,2,3}. In such
cases, integer representation is desirable.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 48


Order Encoding (Permutation Encoding)
 In many problems, the solution is represented by an order of
elements. In such cases permutation representation is the most
suited.
 A classic example of this representation is the travelling salesman
problem (TSP). In this the salesman has to take a tour of all the
cities, visiting each city exactly once and come back to the starting
city. The total distance of the tour has to be minimized. The
solution to this TSP is naturally an ordering or permutation of all
the cities and therefore using a permutation representation makes
sense for this problem.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 49


TSP

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 50


Tree encoding
 In this encoding scheme, a solution is encoded
in the form of a binary tree.

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 51


Tree encoding

@ Dr. Sakuntala Mahapatra 24/11/2020 Genetic Algorithms 52


PPT CONTENT
EVOLUTIONARY COMPUTING
GENETIC ALGORITHMS(GA)
CLASS-23
(MODULE-1V)
DATE:25/11/2020
TIME:12.15 PM-1.15 PM

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 53


Genetic Algorithms - 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 −
1. The diversity of the population should be maintained
otherwise it might lead to premature convergence.
2. 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.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 54


Population Initialization
 There are two primary methods to
initialize a population in a GA.
1.Random Initialization − Populate the
initial population with completely random
solutions.
2.Heuristic initialization − Populate the
initial population using a known heuristic
for the problem.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 55


Population Initialization
 It has been observed that the entire population
should not be initialized using a heuristic, as it can
result in the population having similar solutions and
very little diversity. It has been experimentally
observed that the random solutions are the ones to
drive the population to optimality. Therefore, with
heuristic initialization, we just seed the population
with a couple of good solutions, filling up the rest
with random solutions rather than filling the entire
population with heuristic based solutions.
 It has also been observed that heuristic initialization
in some cases, only effects the initial fitness of the
population, but in the end, it is the diversity of the
solutions which lead to optimality.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 56


Population Models
 There are two population models widely in use.
1. Steady State
 In steady state GA, we generate one or two off-
springs in each iteration and they replace one or
two individuals from the population. A steady
state GA is also known as Incremental GA.
2. Generational
 In a generational model, we generate „n‟ off-
springs, where n is the population size, and the
entire population is replaced by the new one at
the end of the iteration.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 57


Genetic Algorithms - 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” or 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.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 58


Genetic Algorithms - Fitness Function
 Fitness Function (also known as
the Evaluation Function) evaluates how
close a given solution is to the optimum
solution of the desired problem. It determines
how fit a solution is.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 59


Genetic Algorithms - Fitness Function
 A Fitness Function should possess the following
characteristics −
1. The Fitness Function should be sufficiently fast
to compute.
2. It must quantitatively measure how fit a given
solution is or how fit individuals can be
produced from the given solution.
3. 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.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 60


Generic Requirements of a Fitness Function

The following requirements should be satisfied by any


fitness function.
 The fitness function should be clearly defined. The
reader should be able to clearly understand how the
fitness score is calculated.
 The fitness function should be implemented
efficiently. If the fitness function becomes the
bottleneck of the algorithm, then the overall
efficiency of the genetic algorithm will be reduced.
 The fitness function should quantitatively measure
how fit a given solution is in solving the problem.
 The fitness function should generate intuitive results.
The best/worst candidates should have best/worst
score values.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 61


How to come up with a Fitness
Function for a given Problem?
 Each problem has its own fitness function. The fitness
function that should be used depends on the given problem.
Coming up with a fitness function for the given problem is
the hardest part when it comes to formulating a problem
using genetic algorithms.
 There is no hard and fast rule that a particular function
should be used in a particular problem. However, certain
functions have been adopted by data scientists regarding
certain types of problems.
 Typically, for classification tasks where supervised learning is
used, error measures such as Euclidean distance
and Manhattan distance have been widely used as the fitness
function.
 For optimization problems, basic functions such as sum of a
set of calculated parameters related to the problem domain
can be used as the fitness function.

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 62


Genetic Algorithms - Fitness Function

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 63


Genetic Algorithms - Fitness Function

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 64


Genetic Algorithms - Fitness Function

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 65


Genetic Algorithms - Fitness Function

 The Fitness Function F(x) is evaluated as


follows.
 F(x)=f(x) for Maximizing Problem.
 F(x)=1/f(x) for Minimizing Problem for
f(x) is not equal to zero.
 F(x)=1/(1+f(x)) if f(x)=0

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 66


Genetic Algorithms - Fitness Function
Example 1
 F(x) = {MAX(x2): 0 <= x <= 32 }
 Encode Solution: Just use 5 bits (1 or 0).
 Generate initial population.
A 0 1 1 0 1
B 1 1 0 0 0
C 0 1 0 0 0
D 1 0 0 1 1

 Evaluate each solution against objective.


Sol. String Fitness % of Total
A 01101 169 14.4
B 11000 576 49.2
C 01000 64 5.5
D 10011 361 30.9

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 67


Genetic Algorithms - Fitness Function
Example 2
 Let the Fitness Function is to maximum value of the
function (15x - x2), where parameter x varies between
0 and 15.
 F(x)={Maximize (15x - x2), for 0 <= x <=15}
 For simplicity, we may assume that x takes only integer
values.
 Thus, chromosomes can be built with only four genes:
Integer Binary code Integer Binary code Integer Binary code
1 0001 6 0110 11 1011
2 0010 7 0111 12 1100
3 0011 8 1000 13 1101
4 0100 9 1001 14 1110
5 0101 10 1010 15 1111
@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 68
Genetic Algorithms - Fitness Function
Example 2

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 69


Roulette Wheel Representation of Fitness
Ratio
Example 2

100 0
X1: 16.5%
X2: 20.2%
75.2 X3: 6.4%
X4: 6.4%
X5: 25.3%
36.7 X6: 24.8%
49.5 43.1

@ Dr. Sakuntala Mahapatra 25/11/2020 Genetic Algorithms 70


PPT CONTENT
EVOLUTIONARY COMPUTING
GENETIC ALGORITHMS(GA)
CLASS-24
(MODULE-1V)
DATE:26/11/2020
TIME:12.15 PM-1.15 PM

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 71


Genetic Algorithms - Fitness Function
Example 3
• Suppose it is desired to find the maximum of the “peak”
function of two variables:
2  x 2 ( y 1) 2  x2  y 2
f ( x, y)  (1  x) e  (x  x  y ) e3 3

where parameters x and y vary between -3 and 3.


• The first step is to represent the problem variables
as a chromosome - parameters x and y as a
concatenated binary string:

1 0 0 0 1 0 1 0 0 0 1 1 1 0 1 1

x y
@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 72
Genetic Algorithms - Fitness Function
Example 3
 The next step is to calculate the fitness of each
chromosome. This is done in two stages.
 First, a chromosome, that is a string of 16 bits, is
partitioned into two 8-bit strings.

1 0 0 0 1 0 1 0 and 0 0 1 1 1 0 1 1
 Then these strings are converted from binary
(base 2) to decimal (base 10).
(10001010 ) 2  1 27  0  26  0  2 5  0  2 4  1  23  0  2 2  1  21  0  2 0  (138)10
and
(00111011) 2  0  2 7  0  2 6  1  25  1  2 4  1  2 3  0  2 2  1 21  1  2 0  (59)10
@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 73
Genetic Algorithms - Fitness Function
Example 3
 Now the range of integers that can be handled by
8-bits, that is the range from 0 to (28 - 1), is
mapped to the actual range of parameters x and y,
that is the range from -3 to 3.
6
 0.0235294
256  1
 To obtain the actual values of x and y, we use the
Formula
x  (138)10  0.0235294 3  0.2470588
and
y  (59)10  0.0235294 3  1.6117647
@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 74
Genetic Algorithms - Fitness Function
Example 3

 Using decoded values of x and y as inputs in the


mathematical function, the GA calculates the
fitness of each chromosome.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 75


Genetic Algorithms - Parent Selection
 Parent Selection is the process of selecting parents which
mate and recombine to create off-springs for the next
generation. Parent selection is very crucial to the
convergence rate of the GA as good parents drive individuals
to a better and fitter solutions.
 However, care should be taken to prevent one extremely fit
solution from taking over the entire population in a few
generations, as this leads to the solutions being close to one
another in the solution space thereby leading to a loss of
diversity.
 Maintaining good diversity in the population is extremely
crucial for the success of a GA. This taking up of the entire
population by one extremely fit solution is known
as premature convergence and is an undesirable
condition in a GA.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 76


Fitness Proportionate Selection
 Fitness Proportionate Selection is one of the most
popular ways of parent selection. In this every
individual can become a parent with a probability
which is proportional to its fitness. Therefore, fitter
individuals have a higher chance of mating and
propagating their features to the next generation.
 Therefore, such a selection strategy applies a
selection pressure to the more fit individuals in the
population, evolving better individuals over time.
 Consider a circular wheel. The wheel is divided into n
pies, where n is the number of individuals in the
population. Each individual gets a portion of the circle
which is proportional to its fitness value.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 77


Genetic Algorithms
Reproduction (OR) Selection
 Reproduction is the First operator
applied on Population.
 Chromosomes are selected from
Population to be parents to crossover and
produce offspring/children.
 The Reproduction operator is also known
as the Selection operator.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 78


Genetic Algorithms
Reproduction (OR) Parent Selection
 The different methods of selecting
Chromosomes to be Parents to Crossover
are as follows.
1. Roulette Wheel Selection
2. Stochastic Universal Sampling (SUS)
3. Tournament Selection
4. Rank Selection
5. Boltzmann Selection
6. Steady State Selection
7. Random Selection
@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 79
Roulette Wheel Selection
 In a roulette wheel selection, the circular wheel is divided as
described before. A fixed point is chosen on the wheel
circumference as shown and the wheel is rotated.
 The region of the wheel which comes in front of the fixed point is
chosen as the parent. For the second parent, the same process is
repeated.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 80


Roulette Wheel Selection
 It is clear that a fitter individual has a greater
pie on the wheel and therefore a greater
chance of landing in front of the fixed point
when the wheel is rotated. Therefore, the
probability of choosing an individual depends
directly on its fitness.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 81


Steps in Roulette Wheel Selection

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 82


Steps in Roulette Wheel Selection

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 83


Roulette Wheel‟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

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 84


Stochastic Universal Sampling (SUS)
 Stochastic Universal Sampling is quite similar to Roulette wheel selection,
however instead of having just one fixed point, we have multiple fixed
points as shown in the following image. Therefore, all the parents are
chosen in just one spin of the wheel. Also, such a setup encourages the
highly fit individuals to be chosen at least once. It is to be noted that fitness
proportionate selection methods don‟t work for cases where the fitness
can take a negative value.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 85


Tournament Selection
 In K-Way tournament selection, we select K individuals from the
population at random and select the best out of these to become a
parent. The same process is repeated for selecting the next parent.
Tournament Selection is also extremely popular in literature as it
can even work with negative fitness values.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 86


Rank Selection
 Rank Selection also works with negative fitness values
and is mostly used when the individuals in the
population have very close fitness values (this happens
usually at the end of the run).
 This leads to each individual having an almost equal
share of the pie (like in case of fitness proportionate
selection) as shown in the image of next slide and hence
each individual no matter how fit relative to each other
has an approximately same probability of getting
selected as a parent.
 This in turn leads to a loss in the selection pressure
towards fitter individuals, making the GA to make poor
parent selections in such situations.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 87


Rank Selection

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 88


Rank Selection
 In this, we remove the concept of a fitness value while selecting a
parent. However, every individual in the population is ranked
according to their fitness. The selection of the parents depends on
the rank of each individual and not the fitness. The higher ranked
individuals are preferred more than the lower ranked ones.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 89


Boltzmann Selection
 In Boltzmann selection a continuously varying
temperature controls the rate of selection
according to a preset schedule.
 Initially the temperature is high and selection
pressure is inversely proportional to temperature.
So selection pressure is low initially.
 The temperature is gradually lowered, which
gradually increases the selection pressure, thereby
allowing the GA to narrow in more closely to the
best part of the search space while maintaining
the appropriate degree of diversity in population.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 90


Boltzmann Selection
 The selection of an individual is done with
Boltzmann probability which is given by,

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 91


Boltzmann Selection
 In Boltzmann selection, the probability of
selecting best string for mating is very
high.
 Execution time of this technique is also
very less.
 However by using this technique, certain
information may be lost during mutation
stage.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 92


Steady State Selection
 In this method, a few good chromosomes are used
for creating new offspring in every iteration.
 Then some bad chromosomes are removed and the
new offspring is placed in their places.
 The rest of population migrates to the next
generation without going through selection process.
 Main idea of this selection is that big part of
chromosomes should survive to next generation.
 In every generation is selected a few (good - with
high fitness) chromosomes for creating a new
offspring. Then some (bad - with low fitness)
chromosomes are removed and the new offspring is
placed in their place. The rest of population survives
to new generation.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 93


Random Selection
 In this strategy we randomly select
parents from the existing population.
 There is no selection pressure towards
fitter individuals and therefore this
strategy is usually avoided.

@ Dr. Sakuntala Mahapatra 26/11/2020 Genetic Algorithms 94

You might also like