Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
26 views15 pages

Genetic Algorithms

Uploaded by

aaryan6105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views15 pages

Genetic Algorithms

Uploaded by

aaryan6105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

MATH F212 (Optimization)

Gaurav Dwivedi
Department of Mathematics
BITS Pilani, Pilani Campus.
Genetic Algorithm
Recall
(L) (U )
Maximize of minimize f (x), xi ≤ xi ≤ xi .
Any string can be found to represent a point in the
search space by following linear map:
(U ) (L)
(L) xi − xi
xi = xi + × decoded value of string
2ℓi − 1
Here ℓi is string of length i.
The obtainable accuracy in variable xi is
approximately
(U ) (L)
xi − xi
2ℓi
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 3 / 15
Fitness Function
Fitness function F is defined as follows:
(
f (x) for maximization
F= 1
1+f (x) for minimization

The probability for selecting the ith string is


Fi
pi = Pn
j=1 Fj

The expected number of copies of each string in the


mating pool is Ai = npi .
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 4 / 15
Crossover
A crossover probability pc is used so that 100pc %
strings are used in crossover operations and
100(1 − pc )% of the population remain as they are
in the current population.
For selecting the string for crossover from mating
pool flip a coin with probability pc , if outcome is
true then chosen strings are used in the crossover
operation, otherwise the strings are directly placed
in the intermediate population for subsequent
genetic operation.
The expected number of crossover in a population
of size n is pc × (n/2).
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 5 / 15
Mutation

Expected no. of a mutations in an individual are


p m × ℓi
Expected no. of a mutation in whole family are
n × pm × ℓi

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 6 / 15
Notations

Column Description
A Expected no. of copies of a string
B Probability of selecting a string
C CDF
D Random No.
E String no.
F Actual count of string
G Crossover, Yes or No
H Crossover Site

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 7 / 15
Question 1

Perform one iteration of GA to maximize f (x) = x2 , over


the interval [0, 31].
(1) Use the initial population
01101, 11000, 01000, 10011
(2) Use random numbers .100, .234, .500, .879 for
forming the mating pool.
(3) Use single point crossover with pc = 0.85.
(4) Random numbers .23 and 0.64 for crossover.
(5) Assume single point crossover using random
numbers 4 and 2.

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 8 / 15
Question 1 continued

(6) Probability of mutation 0.05.


(7) Use the following random numbers for mutation:
0.01, 0.08, 0.35, 0.69, 0.09, 0.05, 0.03, 0.43, 0.56, 0.01,
0.67, 0.09, 0.06, 0.64, 0.12, 0.03, 0.02, 0.46, 0.02, 0.73.

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 9 / 15
Question 2
Perform one iteration of GA to minimize 4x21 + 3x22 −
4x1 x2 + x1 , 1 ≤ x1 , x2 ≤ 5. Use the following table:
Sr. No. x1 x2 R. No.
1 11101 00111 0.295
2 11111 10001 0.210
3 01000 10010 0.495
4 11110 11111 0.550
5 01010 11001 0.698
6 10101 10011 0.510

(1) Write down the standard fitness function and


calculate the fitness of each population member.
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 10 / 15
Question 2 Continued
(2) Use the random numbers in the table to obtain the
mating pool in binary form.
(3) pc = 0.85, pm = 0.05
(4) Random numbers for cross over 0.64, 0.75, 0.92
random numbers for crossover site 09, 02, 04.
(5) Random numbers for mutation:
0.01,0.24,0.25,0.65,0.07,0.09,0.89,0.20.0.58,0.24
0.21,0.98,0.87,0.25,0.11,0.02,0.55,0.23,0.34,0.99
0.25,0.14,0.28,0.88,0.77,0.45,0.36,0.25,0.18,0.58,
0.69,0.25,0.47,0.87,0.08,0.28,0.47,0.87,0.99,0.06,
0.14,0.58,0.74,0.01, 0.45,0.08,0.09,0.52,0.64,0.66,
0.47,0.58,0.24,0.59,0.66,0.06,0.05,0.07,0.09,0.02.
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 11 / 15
Question 3
Perform one iteration of GA to maximize f (x1 , x2 ) =
2x21 + 5x1 x2 + x32 , 0 ≤ x1 , x2 ≤ 8. Use the following
information:
Sr. No. x1 x2 R. No.
1 11101 00111 0.295
2 11111 10001 0.311
3 01000 10010 0.752
4 11110 11111 0.789
5 01010 11001 0.698
6 10101 10011 0.721

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 12 / 15
Question 3 Continued

(1) pc = 0.8, pm = 0.06


(2) Random numbers for cross over in generation 1
are 0.512, 0.241, 0.932.
(3) Assume single point crossover sites as 9, 1, 13 for
respective crossover operations.

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 13 / 15
Question 3 Continued
(4) Random numbers for mutation
0.01, 0.08, 0.35, 0.67, 0.09, 0.05, 0.03, 0.43, 0.21, 0.52,
0.12, 0.01, 0.46, 0.81, 0.64, 0.18, 0.32, 0.81, 0.31, 0.95,
0.73, 0.47, 0.83, 0.52, 0.14, 0.64, 0.82, 0.56, 0.03, 0.78,
0.06, 0.81, 0.64, 0.18, 0.01, 0.08, 0.35, 0.67, 0.09, 0.01,
0.46, 0.81, 0.64, 0.18, 0.02, 0.21, 0.52, 0.12, 0.04, 0.13,
0.78, 0.06, 0.81, 0.64, 0.18, 0.01, 0.08, 0.35, 0.67, 0.09.
(5) Find the approximate obtainable accuracy of x1 .
Please ensure that you show all the calculations for the
first generation using linearly mapped initial populations,
fitness function, mating pool, crossover, mutation and the
next generation population. (Calculations should be cor-
rect upto three decimal places.)
Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 14 / 15
Question 4

Genetic algorithm has to be utilized to find an optimal


solution of the problem: Min f (x) = x21 − x22 + x1 x2 such
that 0 ≤ x1 ≤ 5, 4 ≤ x2 ≤ 9. The user uses 6 bits to
represent the population member. If the decoded values
of one of the randomly generated population member is
x1 = 4.2857 and x2 = 8.365, then obtain the binary
numbers which will be useful for GA.

Gaurav Dwivedi (BITS Pilani) MATH F212 (Optimization) November 27, 2024 15 / 15

You might also like