0% found this document useful (0 votes)
682 views

Genetic Algorithm

Lecture 1 Brief about Genetic Algorithm Lecture 2 GA Terminology GA Encoding Schemes Lecture 3 Selection Techniques Lecture 4 Crossover Techniques

Uploaded by

Aprna Tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
682 views

Genetic Algorithm

Lecture 1 Brief about Genetic Algorithm Lecture 2 GA Terminology GA Encoding Schemes Lecture 3 Selection Techniques Lecture 4 Crossover Techniques

Uploaded by

Aprna Tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 144

Genetic Algorithm

Module -3
Soft computing (CSE-6004)
Lecture # 1
Index
• Lecture 1
– Brief about Genetic Algorithm
• Lecture 2
– GA Terminology
– GA Encoding Schemes
• Lecture 3
– Selection Techniques
• Lecture 4
– Crossover Techniques
• Lecture 5
– Bit Wise Operator

CSE-6004 2
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).
CSE-6004 Dr. Aprna Tripathi3
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.

CSE-6004 Dr. Aprna Tripathi4


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.

CSE-6004 Dr. Aprna Tripathi5


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.
CSE-6004 Dr. Aprna Tripathi6
Limitations of the Traditional
Optimization Approach

CSE-6004 Dr. Aprna Tripathi7


Evolutionary Algorithm

CSE-6004 Dr. Aprna Tripathi8


Genetic Algorithm

CSE-6004 Dr. Aprna Tripathi9


Background of GA

CSE-6004 Dr. Aprna Tripathi10


A Brief account of genetics:Gene

CSE-6004 Dr. Aprna Tripathi11


A Brief account of genetics: Genetic
Code

CSE-6004 Dr. Aprna Tripathi12


A Brief account of genetics:
Reproduction

CSE-6004 Dr. Aprna Tripathi13


A Brief account of genetics: crossover

CSE-6004 Dr. Aprna Tripathi14


A Brief account of genetics:Evolution

CSE-6004 Dr. Aprna Tripathi15


A Brief account of genetics: Mutation
• To make the process forcefully dynamic when
variations in population going to stable.

CSE-6004 Dr. Aprna Tripathi16


Biological process: A quick Overview

CSE-6004 Dr. Aprna Tripathi17


Genetic Algorithm: Definition
• Genetic algorithm is a population based
probabilistic search and optimization
techniques, which works based on the
mechanisms of natural genetics and natural
evaluation

CSE-6004 Dr. Aprna Tripathi18


Framework of GA

CSE-6004 Dr. Aprna Tripathi19


Working of GA
• GA is an iterative
process
• It is a searching
technique
• Working cycle with/
without convergence
• Solution is not
necessarily guaranteed,
usually terminated with
a local optima.
CSE-6004 Dr. Aprna Tripathi20
Framework of GA: A detail view

CSE-6004 Dr. Aprna Tripathi21


Optimization problem solving with GA
• For the optimization problem, identify the
following:
– Objective function(s)
– Constraint(s)
– Input parameters
– Fitness Evaluation
– Encoding
– Decoding

CSE-6004 Dr. Aprna Tripathi22


Genetic Algorithm

Lecture # 2
Index
• Lecture 1
– Brief about Genetic Algorithm
• Lecture 2
– GA Terminology
– GA Encoding Schemes
• Lecture 3
– Selection Techniques
• Lecture 4
– Crossover Techniques
• Lecture 5
– Bit Wise Operator
CSE-6004 24
Search Space
• If we are solving some problem, we are usually looking
for some solution, which will be the best among others.
• The space of all feasible solutions (it means objects
among those the desired solution is) is called search
space (also state space).
• Each point in the search space represent one feasible
solution.
• Each feasible solution can be "marked" by its value or
fitness for the problem.
• We are looking for our solution, which is one point (or
more) among feasible solutions - that is one point in the
search space.

CSE-6004 Dr. Aprna Tripathi25


Search Space

Example of a search space

CSE-6004 Dr. Aprna Tripathi26


Individuals
• An individual is a single solution while the
population is the set of individuals currently
involved in the search process.
• Each individual in the population is called a
string or chromosome, in analogy to
chromosomes in natural systems.
• The chromosome, which is the raw ‘genetic’
information that the GA deals.

CSE-6004 Dr. Aprna Tripathi27


Genes
• Genes are the basic “instructions” for building
a Generic Algorithms.
• A chromosome is a sequence of genes.
• Genes may describe a possible solution to a
problem, without actually being the solution.
• A gene is a bit string of arbitrary lengths.
• The location of gene in a chromosome is called
locus.
CSE-6004 Dr. Aprna Tripathi28
Fitness
• The fitness function is the evaluation function that
is used to determine the fitness of each
chromosome.
• The fitness function is problem specific and user
defined.
• For calculating fitness, the chromosome has to be
first decoded and the objective function has to be
evaluated.
• The fitness not only indicates how good the
solution is, but also corresponds to how close the
chromosome is to the optimal one.
CSE-6004 Dr. Aprna Tripathi29
Populations
• The population is the set of individuals
currently involved in the search.
• The two important aspects of population used
in Genetic Algorithms are:
• 1. The initial population generation.
• 2. The population size.

CSE-6004 Dr. Aprna Tripathi30


Population
• For each and every problem, the population
size will depend on the complexity of the
problem.
• It is often a random initialization of population
is carried.
• Ideally, the first population should have a gene
pool as large as possible in order to be able to
explore the whole search space.

CSE-6004 Dr. Aprna Tripathi31


Operators of GA
• The crossover and mutation are the most
important part of the genetic algorithm.
• The performance is influenced mainly by these
two operators.

CSE-6004 Dr. Aprna Tripathi32


Encoding of a Chromosome
• The chromosome should in some way contain
information about solution which it represents.
The most used way of encoding is a binary string.

• Each chromosome has one binary string.


• Each bit in this string can represent some
characteristic of the solution.
• There are many other ways of encoding. This
depends mainly on the solved problem.

CSE-6004 Dr. Aprna Tripathi33


Crossover
• After we have decided what encoding we will use,
we can make a step to crossover.
• Crossover selects genes from parent
chromosomes and creates a new offspring.
• The simplest way how to do this is to choose
randomly some crossover point and everything
before this point copy from a first parent and then
everything after a crossover point copy from the
second parent.
• Crossover can then look like this ( | is the
crossover point):
CSE-6004 Dr. Aprna Tripathi34
Crossover

• There are other ways how to make crossover, for


example we can choose more crossover points.
• Crossover can be rather complicated and very depends
on encoding of the encoding of chromosome.
• Specific crossover made for a specific problem can
improve performance of the genetic algorithm.

CSE-6004 Dr. Aprna Tripathi35


Mutation
• After a crossover is performed, mutation take place.
• This is to prevent falling all solutions in population
into a local optimum of solved problem.
• Mutation changes randomly the new offspring. For
binary encoding we can switch a few randomly
chosen bits from 1 to 0 or from 0 to 1.
• For Example:

CSE-6004 Dr. Aprna Tripathi36


Encoding
• Encoding is a process of representing
individual genes.
• The process can be performed using bits,
numbers, trees, arrays, lists or any other
objects.
• The encoding depends mainly on solving the
problem.

CSE-6004 Dr. Aprna Tripathi37


Binary Encoding
• Binary encoding is the most common, mainly
because first works about GA used this type of
encoding.
• In binary encoding every chromosome is a
string of bits, 0 or 1.
• For Example:

CSE-6004 Dr. Aprna Tripathi38


• Binary encoding gives many possible chromosomes
even with a small number of alleles.
• On the other hand, this encoding is often not natural for
many problems and sometimes corrections must be
made after crossover and/or mutation.
• Example of Problem: Knapsack problem
The problem: There are things with given value and
size. The knapsack has given capacity. Select things to
maximize the value of things in knapsack, but do not
extend knapsack capacity.
Encoding: Each bit says, if the corresponding thing is
in knapsack.

CSE-6004 Dr. Aprna Tripathi39


Octal Encoding
• In this encoding chromosome is represented
using octal numbers (0-7).
• For Example

CSE-6004 Dr. Aprna Tripathi40


Hexadecimal Encoding
• In this encoding chromosome is represented
using Hexadecimal numbers (0-9, A-F).
• For Example:

CSE-6004 Dr. Aprna Tripathi41


Permutation Encoding
• Permutation encoding can be used in ordering
problems, such as travelling salesman problem
or task ordering problem.
• In permutation encoding, every chromosome
is a string of numbers, which represents
number in a sequence.
• For Example:

CSE-6004 Dr. Aprna Tripathi42


• Permutation encoding is only useful for ordering problems.
• Even for this problems for some types of crossover and
mutation corrections must be made to leave the
chromosome consistent (i.e. have real sequence in it).

Example of Problem: Travelling salesman problem (TSP)
The problem: There are cities and given distances between
them. Travelling salesman has to visit all of them, but he
does not to travel very much. Find a sequence of cities to
minimize travelled distance.
Encoding: Chromosome says order of cities, in which
salesman will visit them.

CSE-6004 Dr. Aprna Tripathi43


Value Encoding
• Direct value encoding can be used in problems,
where some complicated value, such as real
numbers, are used. Use of binary encoding for
this type of problems would be very difficult.
• In value encoding, every chromosome is a string
of some values. Values can be anything connected
to problem, form numbers, real numbers or chars
to some complicated objects.
• Example:
CSE-6004 Dr. Aprna Tripathi44
• Value encoding is very good for some special problems.
• On the other hand, for this encoding is often necessary to
develop some new crossover and mutation specific for the
problem.
• Example of Problem: Finding weights for neural network
The problem: There is some neural network with given
architecture. Find weights for inputs of neurons to train the
network for wanted output.
Encoding: Real values in chromosomes represent
corresponding weights for inputs.

CSE-6004 Dr. Aprna Tripathi45


Tree Encoding
• Tree encoding is used mainly for evolving programs
or expressions, for genetic programming.
• In tree encoding every chromosome is a tree of some
objects, such as functions or commands in
programming language.

CSE-6004 Dr. Aprna Tripathi46


• Tree encoding is good for evolving programs.
Programing language LISP is often used to this,
because programs in it are represented in this form and
can be easily parsed as a tree, so the crossover and
mutation can be done relatively easily.
• Example of Problem: Finding a function from given
values
• The problem: Some input and output values are given.
Task is to find a function, which will give the best
(closest to wanted) output to all inputs.
Encoding: Chromosome are functions represented in a
tree.

CSE-6004 Dr. Aprna Tripathi47


Genetic Algorithms Requirements
• In order to apply a genetic algorithm, there are
several questions that need to be answered:
– How is an individual represented?
– How is an individual’s fitness calculated?
– How are individuals selected for breeding?
– How are individuals crossed-over?
– How are individuals mutated?
– How big should the population be?
– What are the “termination conditions”?

CSE-6004 Dr. Aprna Tripathi48


Genetic Algorithm Selection

Lecture # 3
Index
• Lecture 1
– Brief about Genetic Algorithm
• Lecture 2
– GA Terminology
– GA Encoding Schemes
• Lecture 3
– Selection Techniques
• Lecture 4
– Crossover Techniques
• Lecture 5
– Bit Wise Operator
CSE-6004 50
GA Selection

CSE-6004 Dr. Aprna Tripathi51


Selection operation in GAs
• Selection is the process for creating the
population for next generation
• from the current generation
• To generate new population: Breeding in GA
– Create a mating pool
– Select a pair
– Reproduce

CSE-6004 Dr. Aprna Tripathi52


Fitness evaluation

CSE-6004 Dr. Aprna Tripathi53


Fitness evaluation

CSE-6004 Dr. Aprna Tripathi54


Fitness function

• Genetic operators requires that fitness function


be non-negative
• F(X)= f(X) for maximization problem
• F(X)= 1/f(X) for minimization problem if F(X)
not equal to zero
• F(X)=1/ (1+ f(X)), if F(X)=0
• The fitness function value of the string is also
known as string’s fitness.
CSE-6004 Dr. Aprna Tripathi55
An example

CSE-6004 Dr. Aprna Tripathi56


Selection Schemes in GAs

CSE-6004 Dr. Aprna Tripathi57


Canonical selection

CSE-6004 Dr. Aprna Tripathi58


Canonical selection

CSE-6004 Dr. Aprna Tripathi59


Roulette-Wheel selection

CSE-6004 Dr. Aprna Tripathi60


Roulette-Wheel selection mechanism

CSE-6004 Dr. Aprna Tripathi61


Roulette-Wheel selection mechanism

CSE-6004 Dr. Aprna Tripathi62


Roulette-Wheel selection mechanism:
An Example

CSE-6004 Dr. Aprna Tripathi63


Roulette-Wheel selection :
Implementation

CSE-6004 Dr. Aprna Tripathi64


Roulette-Wheel selection: Example

CSE-6004 Dr. Aprna Tripathi65


Roulette-Wheel selection

CSE-6004 Dr. Aprna Tripathi66


Drawback in Roulette-Wheel selection

CSE-6004 Dr. Aprna Tripathi67


Problem with Roulette-Wheel selection
scheme

CSE-6004 Dr. Aprna Tripathi68


Rank-based selection

CSE-6004 Dr. Aprna Tripathi69


Rank-based selection: Example

CSE-6004 Dr. Aprna Tripathi70


Rank-based selection: Implementation

CSE-6004 Dr. Aprna Tripathi71


Comparing Rank-based selection with
Roulette-Wheel selection

CSE-6004 Dr. Aprna Tripathi72


Basic concept of tournament selection

CSE-6004 Dr. Aprna Tripathi73


Tournament selection

CSE-6004 Dr. Aprna Tripathi74


Tournament selection : Implementation

CSE-6004 Dr. Aprna Tripathi75


Tournament selection : Implementation

CSE-6004 Dr. Aprna Tripathi76


Tournament selection : Implementation

CSE-6004 Dr. Aprna Tripathi77


Steady-State selection algorithm

CSE-6004 Dr. Aprna Tripathi78


Boltzmann Selection
• Simulated Annealing is a method of functional
minimization or maximization
• P(E)= exp(-E/kT)
• Where
• K is Boltzmann constant

CSE-6004 Dr. Aprna Tripathi79


Generation Gap
• Generation gap is defined as the proportion of
individuals in the population which are
replaced in each generation.
• Generation Gap can be classified as
Gp= p/ Np
Where Np is the population size and p is the
number of individuals that will be replaced.

CSE-6004 Dr. Aprna Tripathi80


Mating Pool: Prior to crossover
operation
• A mating pair (each pair consists of two strings)
are selected at random. Thus, if the size of mating
pool is N, then N/2 mating pairs are to be formed.
[Random Mating]
• The pairs are checked, whether they will
participate in reproduction or not by tossing a
coin, whose probability being Pc. If Pc is head,
then the parent will participate in reproduction.
Otherwise, they will remain intact in the
population.

CSE-6004 Dr. Aprna Tripathi81


Genetic Algorithm Selection

Lecture # 4
Index
• Lecture 1
– Brief about Genetic Algorithm
• Lecture 2
– GA Terminology
– GA Encoding Schemes
• Lecture 3
– Selection Techniques
• Lecture 4
– Crossover Techniques
• Lecture 5
– Bit Wise Operator

CSE-6004 83
Crossover operation
• Once, a pool of mating pair are selected, they
undergo through crossover operations.
• In crossover, there is an exchange of properties
between two parents and as a result of which two
offspring solutions are produced.
• The crossover point(s) (also called k‐point(s))
is(are) decided using a random number
generator generating integer(s) in between 1 and
L, where L is the length of the chromosome.
• Then we perform exchange of gene values with
respect to the k‐point(s)
CSE-6004 Dr. Aprna Tripathi84
Crossover operations in Binary-coded
GAs
• There exists a large number of crossover
schemes, few important of them are listed in
the following.
– Single point crossover
– Two‐point crossover
– Multi‐point crossover (also called n‐point
crossover)
– Uniform crossover (UX)
– Matrix crossover (Tow‐dimensional crossover)

CSE-6004 Dr. Aprna Tripathi85


Single-Point Crossover
1) Here, we select the K‐point lying between 1 and L. Let it be k.
2) A single crossover point at k on both parent’s strings is
selected.
3) All data beyond that point in either string is swapped between
the two parents.
4) The resulting strings are the chromosomes of the offspring
produced.

CSE-6004 Dr. Aprna Tripathi86


Single-Point Crossover
• Example:
– Parent 1: XX|XXXXX
– Parent 2: YY| YYYYY
– Offspring 1: X XYYYYY
– Offspring 2: YYX X X X X

CSE-6004 Dr. Aprna Tripathi87


Single Point Cross over

CSE-6004 Dr. Aprna Tripathi88


Two-Point Crossover
• Two-Point crossover is very similar to single-point
crossover except that two cut-points are generated
instead of one.
– In this scheme, we select two different crossover points K1
and K2 lying between 1 and L at random such that K1 is
not equal to K2.
– The middle parts are swapped between the two strings.
– Alternatively, left and right parts also can be swapped.

CSE-6004 Dr. Aprna Tripathi89


Two-Point Crossover
• Example:
– Parent 1: XX|XXX|XX
– Parent 2: YY| YYY|YY
– Offspring 1: X XYYYX X
– Offspring 2: YYX X XYY

CSE-6004 Dr. Aprna Tripathi90


Two-Point Crossover

CSE-6004 Dr. Aprna Tripathi91


Multi-point crossover
• 1) In case of multi‐point crossover, a number
of crossover points are selected along the
length of the string, at random.
• 2) The bits lying between alternate pairs of
sites are then swapped.

CSE-6004 Dr. Aprna Tripathi92


Uniform Crossover
• In Uniform Crossover, a value of the first parent’s gene is assigned
to the first offspring and the value of the second parent’s gene is to
the second offspring with probability 0.5.
• With probability 0.5 the value of the first parent’s gene is assigned
to the second offspring and the value of the second parent’s gene is
assigned to the first offspring.
• Uniform crossover is a more general version of the multi‐point
crossover.
• In this scheme, at each bit position of the parent string, we toss a
coin (with a certain probability Ps) to determine whether there will
be swap of the bits or not.
• The two bits are then swapped or remain unaltered, accordingly.

CSE-6004 Dr. Aprna Tripathi93


Uniform Crossover
• Example:
– Parent 1: XXXXXXX
– Parent 2: YYYYYYY
– Offspring 1: XYXYYXY
– Offspring 2: YXYXXYX

CSE-6004 Dr. Aprna Tripathi94


Uniform Crossover

CSE-6004 Dr. Aprna Tripathi95


Uniform crossover with crossover
mask
• Here, each gene is created in the offspring by
copying the corresponding gene from one or the
other parent chosen according to a random
generated binary crossover mask of the same
length as the chromosome.
• Where there is a 1 in the mask, the gene is copied
from the first parent.
• Where there is a 0 in the mask, the gene is copied
from the second parent.
• The reverse is followed to create another
offspring.
CSE-6004 Dr. Aprna Tripathi96
Uniform crossover with crossover
mask

CSE-6004 Dr. Aprna Tripathi97


Matrix crossover

CSE-6004 Dr. Aprna Tripathi98


Three Parent Cross over
• In this crossover technique, three parents are
randomly chosen.
• Each bit of the first parent is compared with
the bit of the second parent.
• If both are the same, the bit is taken for the
offspring otherwise; the bit from the third
parent is taken for the offspring.

CSE-6004 Dr. Aprna Tripathi99


Three Parent Crossover: Example

CSE-6004 Dr. Aprna Tripathi100


Crossover Probability
• Crossover probability is a parameter to describe how often
crossover will be performed.
• If there is no crossover, offspring are exact copies of parents.
• If there is crossover, offspring are made from parts of both
parent’s chromosome.
• If crossover probability is 100%, then all offspring are made
by crossover. If it is 0%, whole new generation is made from
exact copies of chromosomes from old population.
• Crossover is made in hope that new chromosomes will contain
good parts of old chromosomes and therefore the new
chromosomes will be better.
• However, it is good to leave some part of old population
survive to next generation. CSE-6004 101
Inversion
• A string from the population is selected and the
bits between two random sites are inverted
1 2 3 4 5 6 7
0 1 1 1 0 0 1

1 2 3 4 5 6 7
1 0 0 0 1 1 0

CSE-6004 102
Linear + end - inversion
• Linear + end inversion performs linear inversion
with a specified probability.
• If linear inversion is not performed, end inversion
would be performed with equal probability at
either the left or right end of the string.
• Under end inversion, the left or right end of the
string is picked as one inversion point and a
second inversion point is picked uniformly at
random from points no farther away than one-half
of the string length
CSE-6004 103
Continuous & Mass Inversion
• In continuous inversion mode, inversion is
applied with a specified inversion probability
to each new individual.
• In mass inversion mode, no inversion takes
place until a new population is created.
• One-half of the population undergoes identical
inversion using the same two point inversion.

CSE-6004 104
Deletion and duplication
• Duplication and deletion are low level
operators suggested for artificial search.
• Any two or three bits at random in order are
selected and the previous bits are duplicated.
0 0 1 1 0 0 1 0 1 0

0 0 1 1 0 - - - 1 0

0 0 1 1 0 1 1 0 1 0

CSE-6004 105
Duplication and Regeneration
• Genes between two cross sites are deleted and
regenerated randomly.

0 0 1 1 0 0 1 0 1 0

0 0 - - - - - - 1 0

0 0 1 1 0 1 1 0 1 0

CSE-6004 106
Segregation
• The bits of the parents are segregated and then
cross over to produce offspring.

CSE-6004 107
Crossover and Inversion
• Crossover and inversion operator is the
combination of both.
• In this two random sites are selected, the
content enclosed in boundary( included) is
exchanged between two parents and the end
points of these are exchanged.

CSE-6004 108
Crossover and Inversion- Example

CSE-6004 109
Mutation
• After crossover, the strings are subjected to
mutation.
• Mutation prevents the algorithm to be trapped
in a local minimum.
• Mutation plays the role of recovering the lost
genetic materials as well as for randomly
disturbing genetic information. Mutation of a
bit involves flipping a bit, changing 0 to 1 and
vice-versa.

CSE-6004 110
Flipping
• Flipping of a bit involves changing 0 to 1 and
1 to 0 based on a mutation chromosome
generated.

CSE-6004 111
Interchanging
• Two random positions of the string are chosen
and the bits corresponding to those positions
are interchanged

CSE-6004 112
Mutation Probability
• The important parameter in the mutation technique is the
mutation probability (Pm).
• The mutation probability decides how often parts of
chromosome will be mutated.
• If there is no mutation, offspring are generated immediately
after crossover (or directly copied) without any change.
• If mutation is performed, one or more parts of a
chromosome are changed.
• If mutation probability is 100%, whole chromosome is
changed, if it is 0%, nothing is changed.
• Mutation should not occur very often, because then GA will
in fact change to random search.

CSE-6004 113
Reversing
• A random position is chosen and the bits next
to that position are reversed and child
chromosome is produced.

CSE-6004 114
Replacement
• Replacement is the last stage of any breeding cycle.
• Two parents are drawn from a fixed size population,
they breed two children, but not all four can return to
the population, so two must be replaced i.e., once off
springs are produced,
• The technique used to decide which individual stay in a
population and which are replaced in on a par with the
selection in influencing convergence .
• Basically, there are two kinds of methods for
maintaining the population; generational updates and
steady state updates.

CSE-6004 115
• In a steady state update, new individuals are
inserted in the population as soon as they are
created, as opposed to the generational update
where an entire new generation is produced at
each time step.
• The insertion of a new individual usually
necessitates the replacement of another
population member.

CSE-6004 116
Random Replacement

• The children replace two randomly chosen


individuals in the population.
• The parents are also candidates for selection.
• This can be useful for continuing the search in
small populations, since weak individuals can
be introduced into the population.

CSE-6004 117
Weak Parent Replacement

• In weak parent replacement, a weaker parent is


replaced by a strong child.
• With the four individuals only the fittest two,
parent or child, return to population.
• This process improves the overall fitness of the
population when paired with a selection technique
that selects both fit and weak parents for crossing,
but if weak individuals and discriminated against
in selection the opportunity will never raise to
replace them.
CSE-6004 118
Both Parents

• Both parents replacement is simple. The child


replaces the parent.
• In this case, each individual only gets to breed
once.
• As a result, the population and genetic material
moves around but leads to a problem when
combined with a selection technique that
strongly favors fit parents: the fit breed and
then are disposed of.

CSE-6004 119
Index
• Lecture 1
– Brief about Genetic Algorithm
• Lecture 2
– GA Terminology
– GA Encoding Schemes
• Lecture 3
– Selection Techniques
• Lecture 4
– Crossover Techniques
• Lecture 5
– Bit Wise Operator

CSE-6004 120
Genetic Algorithm

Lecture # 5
One's Complement Operator
• This Operator is Known as unary operator(~).
• It causes the bits of its operand to be inverted.

CSE-6004 122
Logical bitwise operator
• This operator can further classified in to
– bitwise AND
– bitwise exclusive(X)-OR
– bitwise OR.

CSE-6004 123
Logical bitwise operator

CSE-6004 124
Shift Operator
• There are two types of Shift operator 2:
– Shift Left(<<) operator.
– Shift Right(>>) operator.

CSE-6004 125
Shift Operator
• Left Shift

• Right Shift

CSE-6004 126
Masking Operator
• Transform a given bit pattern in to another
form with the help of Logical bitwse operation.
There is a mask operand is used.

CSE-6004 127
Elitism
• The first best chromosome or the few best
chromosomes are copied to the new
population.
• The rest is done in a classical way. Such
individuals can be lost if they are not selected
to reproduce or if crossover or mutation
destroys them.
• This significantly improves the GA’s
performance.

CSE-6004 128
Effectiveness of any selection scheme
• There are two issues to decide the
effectiveness of any selection scheme.
– Population diversity
– Selection pressure

CSE-6004 129
Population Diversity
• This is similar to the concept of exploration.
• The population diversity means that the genes
from the already discovered good individuals
are exploited while permitting the new area of
search space continue to be explored.

CSE-6004 130
Selective Pressure
• This is similar to the concept of exploitation.
• It is defined as the degree to which the better
individuals are favored.

CSE-6004 131
If selection pressure is HIGH
1. The search focuses only on good individuals
(in terms of fitness) at the moment.
2. It loses the population diversity.
3. Higher rate of convergence. Often leads to
pre‐mature convergence of the solution to a
sub‐optimal solution.

CSE-6004 132
If the selection pressure is LOW
1. 1. May not be able to drive the search
properly and consequently the stagnation may
occurs.
2. The convergence rate is low and GA takes
unnecessary long time to find optimal
solution.
3. Accuracy of solution increases (as more
genes are usually explored in the search).

CSE-6004 133
Analysis of different selection
strategies

CSE-6004 134
Hamming cliff problem
• There is a issue with binary coding
• A one‐bit change can make a large (or a small)
jump.
• A multi‐bits can make a small (or a large gap).
• For example, 1000 ⇒ 0111
(Here, Hamming distance = 4, but distance
between phenotype is 1)
• Similarly, 0000 ⇒ 1000
(Here, Hamming distance = 1, but distance
between phenotype is 8)

CSE-6004 135
Convergence of GA
• The termination condition of a Genetic Algorithm is important in
determining when a GA run will end.
• It has been observed that initially, the GA progresses very fast with
better solutions coming in every few iterations, but this tends to
saturate in the later stages where the improvements are very small.
• We usually want a termination condition such that our solution is
close to the optimal, at the end of the run.
• Usually, we keep one of the following termination conditions −
– When there has been no improvement in the population for X
iterations.
– When we reach an absolute number of generations.
– When the objective function value has reached a certain pre-defined
value.

CSE-6004 136
GA Cycle

CSE-6004 137
Applications of Genetic Algorithms
• Traveling Salesman Problem
• Decoding A Secret Message
• Robot Trajectory Planning
• Optimizing Artificial Neural Nets

CSE-6004 138
Domain-wise GA Applications

CSE-6004 139
Issues for Genetic Algorithm
• Choosing basic implementation issues such as
– Representation
– Population size and mutation rate
– Selection, deletion policies
– Cross over and mutation operators
• Termination criterion
• Performance and scalability
• Solution is only as good as evaluation
functions.
CSE-6004 140
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.
– 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.

CSE-6004 141
Benefits of Genetic Algorithms
• Easy to understand
• Supports multi-objective optimization
• Good for noisy environment
• We always get answer and answer gets better with
time
• Inherently parallel and easily distributed
• Easy to exploit for precious or alternate solutions
• Flexible in forming building blocks for hybrid
applications
• Has substantial history and range of use
CSE-6004 142
Limitations of GA
• 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.

CSE-6004 143
References
• https://www.tutorialspoint.com/genetic_algorit
hms
• http://shodhganga.inflibnet.ac.in
• http://www.nid.iitkgp.ernet.in/DSamanta
• http://www.ics.uci.edu/~kibler/ics171/RNLect
ures/GAs.pdf

CSE-6004 144

You might also like