Genetic Algorithms
Genetic Algorithms
UNIT-3
MODULE—III
Genetic Algorithms
• Fundamentals of genetic algorithms
• Encoding
• Fitness functions, Reproduction
• Genetic Modeling: Cross cover, Inversion and
deletion, Mutation operator, Bit-wise operators &
its uses in GA
• Convergence of Genetic algorithm, Applications
• Real life Problems
Fundamentals of genetic algorithms
Examples:-
In
or manufacturing, we .want to maximize the profit
minimize the cost
In designing an automobile panel, we want to
maximize the strength.
Basic Concepts
2) A set of unknowns or variables that affect
the objective function.
Examples:
• In manufacturing, the variables are amount of
resources used or the time spent.
• In panel design problem, the variables are
shape and dimensions of the panel.
Basic Concepts
3) A set of constraints that allow the unknowns
to take on certain values but exclude others.
• Examples:
• In manufacturing, one constrain is, that all
"time" variables to be non-negative.
• In the panel design, we want to limit the
weight and put constrain on its shape.
Search Optimization Algorithms
Search Optimization Algorithms
Our main concern is to understand
the evolutionary algorithms :
how to describe the process of
search,
how to implement and carry out
search,
what are the elements required
to carry out search, and
the different search strategies
Biological Background – Basic Genetics
Chromosome
Other Cell bodies
• Possible settings for a trait (e.g. blue, brown) are called alleles
• Each gene has its own position in the chromosome called its locus.
4 0100 10 1010
5 0101 11 1011
Value Encoding
• The value encoding can be used in
problems where values such as real
numbers are used. Use of binary
encoding for this type of problems would
be difficult.
1. In value encoding, every chromosome is
a sequence of some values.
2. The values can be anything connected to
the problem, such as : real numbers,
characters or objects.
Value Encoding
• Examples :
Chromosome A 1.2324 5.3243 0.4556 2.3293 2.4545
Chromosome B ABDJEIFJDHDIERJFDLDFLFEGT
Chromosome B
Chromosome A
pi = F i / ( F j ),
j=1
pi = Fi /( F j ) ,where
j=1
n = no of individuals, called population
size; pi = probability of i string being
th
80
%
10
% 6% 4%
The observation is that the individual with higher fitness values will
guard the other to be selected for mating. This leads to a lesser
diversity and hence fewer scope toward exploring the alternative
solution and also premature convergence or early convergence
with local optimal solution.
Debasis Samanta (IIT Kharagpur)
Rank-based selection
To overcome the problem with Roulette-Wheel selection, a
rank-based selection scheme has been proposed.
The process of ranking selection consists of two steps.
1 Individuals are arranged in an ascending order of their fitness
values. The individual, which has the lowest value of fitness
is assigned rank 1, and other individuals are ranked
2
accordingly.
The proportionate based selection scheme is then followed
based on the assigned rank.
Note:
The % area to be occupied by a particular individual i, is given by
Σ Nri ×
r
100i =1 i
where ri indicates the rank of i − th individual.
Two or more individuals with the same fitness values should have
the same rank.
Debasis Samanta (IIT Kharagpur)
Rank-based selection: Example
Continuing with the population of 4 individuals with fitness values:
f1 = 0.40, f2 = 0.05, f3 = 0.03 and f4 = 0.02.
Their proportionate area on the wheel are: 80%, 10%, 6% and 4%
Their ranks are shown in the following figure.
80%
30%
40%
20%
10% 10%
6% 4%
40 %
80 %
1 1
2
2 10 %
3 30 %
4 4 3
7%
10 % 20 %
3%
Winner
?
?
? ? ? ?
India New Zealand England Sri Lanka S. Africa Australia Pakistan Zimbabwe
Output :
Trial I ndividuals Selected
1 2, 4 4
2 3, 8 8
3 1, 3 3
4 4, 5 5
5 1, 6 6
6 1, 2 2
7 4, 2 4
8 8, 3 8
If the fitness values of two individuals are same, than there is a tie
in the match!! So, what to do????
Debasis Samanta (IIT Kharagpur)
Tournament selection
Note :
There are different twists can be made into the basic Tournament
selection scheme:
Steps :
1
NU individuals with highest fitness values are selected.
2
NU individuals with worst fitness values are removed and NU
individuals selected in Step 1 are added into the mating pool.
This completes the selection procedure for one iteration. Repeat
the iteration until the mating pool of desired size is obtained.
• Crossover
• Mutation
Mating Pool: Prior to crossover operation
Note :
Generally, pc = 1.0, so that almost all the parents can participate in
production.
Before
Crossover
Parent 0 1 1 0 0 0 1 0 Two
1: diploid
Parent 1 0 1 0 1 1 0 0 from a
2: mating
pair
Crossover Point -
k
1
In this scheme, we select two different crossover points k1 and k2
lying between 1 and L at random such that k1 ƒ= k2.
2
The middle parts are swapped between the two
3
strings. Alternatively, left and right parts also can be
swapped.
Before Crossover
Parent 1 : 0 1 1 0 0 0 1 0
Parent 2 : 1 0 1 0 1 1 0 0
Offspring 1: 0 1 1 0 1 0 1 0
Offspring 2: 1 0 1 0 0 1 0 0
After Crossver
k1 k2 k3
Parent 1 Offspring 1
Parent 2 Offspring 2
Swap 1 Swap 2
Before crossover
Parent 1 : 1 1 0 0 0 1 0 1 1 0 0 1
Parent 2 : 0 1 1 0 0 1 1 1 0 1 0 1
Coin tossing: 1 0 0 1 1 0 1 1 0 0 1
1
After crossover
Offspring 1: 1 1 1 0 0 1 1 1 1 1 0 1
Offspring 2: 0 1 0 0 0 1 0 1 0 0 0 1
Before Crossover
Parent 1 : 1 1 0 0 0 1 0 1
Parent 2 : 0 1 1 0 0 1 1 1
Mask 1 0 0 1 1 1 0 1
After Crossver
Before crossover
Parent 1 : 1 1 0 0 0 0 1 0
Here, Hamming
distance is 4
Parent 2 : 1 0 0 1 1 0 1 1
Tossing: 1 0 1 1
If toss is 1, then swap the
bits else remain as it is
Offspring 1: 1 0 0 0 1 0 1 1
Offspring 2: 1 1 0 1 0 0 1 0
After crossver
P1 : 1 1 0 0 0 1 1 0
P2 : 1 0 0 1 1 0 1 1
K-point
P1' : 0 0 1 0 1 1 0 1
After shuffing bits
P2' : 0 1 1 1 0 1 0 1
Offspring 1: 0 0 1 0 1 1 0 1
Single point
Offspring 2: crossover
0 1 1 1 0 1 0 1
After crossver