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

Genetic Algorithm

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

Genetic Algorithm

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

Genetic Algorithm

Genetic Algorithm
 Genetic Algorithms are the optimization techniques that
mimic the process of natural evolution.
 Professor John Holland of the University of Michigan,
envisaged the concept of these algorithms

“Select The Best, Discard


The Rest”
Terminology of GA
 Population. The set of design points at the current iteration
is called a population. It represents a group of designs as
potential solution points. Np=number of designs in a
population; this is also called the population size.
 Generation. An iteration of the genetic algorithm is called
a generation. A generation has a population of size N p that
is manipulated in a genetic algorithm.
 Chromosome. This term is used to represent a design
point. Thus a chromosome represents a design of the
system, whether feasible or infeasible. It contains values
for all the design variables of the system.
 Gene. This term is used for a scalar component of the
design vector; that is, it represents the value of a particular
design variable.
Coding
 In order to use GAs to solve the problem, variables xi’s are
first coded in some string structures.
 Most common method of encoding is binary coded.
 Chromosomes are strings of 1 and 0 and each position in the
chromosome represents a particular characteristic of the
problem
 The length of the string is usually determined according to the
desired solution accuracy.
 For example, if four bits are used to code each variable in a
two variable function optimization problem, the strings (0000
0000) and (1111 1111) would represent the points
Coding:
Linear Mapping Rule
u l
l ( x  xi)
xi  xi  l i
( si )
( x1u , x2u )T ( x1l , x2l )T 2 i 1
si  decoded value
Find decoded value and value of
variable x for below string
Xl=2, XU=5

S.No String

1 1 0 1 1 1

2 0 0 1 1 0

3 0 1 0 0 1

4 1 1 0 1 0

5 0 1 1 1 0
Fitness Function
 A fitness value can be assigned to evaluate the solutions
 A fitness function value quantifies the optimality of a
solution.
 The value is used to rank a particular solution against all
the other solutions
 GAs are naturally suitable for solving maximization
problems.
 Minimization problems are usually transformed into
maximization problems by some suitable transformation.
Fitness function
 For maximization problems, the fitness function can be
considered to be the same as the objective function or F(x)
= f(x).
 For minimization problems, the fitness function is an
equivalent maximization problem chosen such that the
optimum point remains unchanged.
 A number of such transformations are possible. The
following fitness function is often used: F(x)= 1/(1+f(x)).
This transformation does not alter the location of the
minimum, but converts a minimization problem to an
equivalent maximization problem.
 The fitness function value of a string is known as the
string’s fitness.
GA Operator

 Reproduction

 Crossover

 Mutation
Reproduction
 The process that determines which solutions are to be
preserved and allowed to reproduce and which ones
deserve to die out. (This is also called selection process)
 The primary objective of the reproduction operator is to
emphasize the good solutions
 Eliminate the bad solutions in a population while keeping
the population size constant by making multiple copies of
good solution.
Reproduction operator
 The commonly-used reproduction operator is the
proportionate reproduction operator where a string is
selected for the mating pool with a probability proportional
to its fitness.
 Thus, the i-th string in the population is selected with a
probability proportional to Fi.
 Since the population size is usually kept fixed in a simple
GA, the sum of the probability of each string being
selected for the mating pool must be one.
 Therefore, the probability for selecting the i-th string is
Fi
pi  n
 Fj
j 1
Roulette-Wheel
 One way to implement this selection scheme is a roulette-
wheel with it’s circumference marked for each string
proportionate to the string’s fitness.
 the circumference of the wheel is marked according to a
string’s fitness,
 This roulette-wheel mechanism is expected to make
copies of the i-th string in the mating pool.
F
 The average fitness of the population is calculated as i
F
n Fi
F
i 1 n
Reproduction operator
F
 The probability of selecting a string pi can be calculated. pi  n

 Thereafter, the cumulative probability (Pi) of each string j 1

being copied can be calculated by adding the individual


probabilities from the top of the list.
 Thus, the bottom-most string in the population should have
a cumulative probability (Pn) equal to 1.
 The roulette-wheel concept can be simulated by realizing
that the i-th string in the population represents the
cumulative probability values from Pi−1 to Pi.
 The first string represents the cumulative values from zero
to P1. Thus, the cumulative probability of any string lies
between 0 to 1.
Reproduction operator
 To choose n strings, n random numbers between zero to
one are created at random.
 Thus, a string that represents the chosen random number in
the cumulative probability range (calculated from the
fitness values) for the string is copied to the mating pool.
 The string with a higher fitness value will represent a
larger range in the cumulative probability values and
therefore has a higher probability of being copied into the
mating pool.
 A string with a smaller fitness value represents a smaller
range in cumulative probability values and has a smaller
probability of being copied into the mating pool.
Reproduction
Minimize f(x)=ex-x3+15
xl=2, xu=5
S.No String
Random number
1 1 0 1 1 1 D

2 0 0 1 1 0 0.2
0.3
3 0 1 0 0 1
0.6
4 1 1 0 1 0
0.8
5 0 1 1 1 0 0.9
Crossover
 In reproduction, good strings in a population are
probabilistically assigned a larger number of copies and
a mating pool is formed. No new strings are formed in
the reproduction phase.
 In the crossover operator, new strings are created by
exchanging information among strings of the mating
pool.
 In crossover operators, two strings are picked from the
mating pool at random and some portions of the strings
are exchanged between the strings.
 A single point crossover operator is performed by
randomly choosing a crossing site along the string and
by exchanging all bits on the right side of the crossing
site
 The two strings participating in the crossover operation are
known as parent strings and the resulting strings are known
as children strings.
 If an appropriate site is chosen good substrings are formed
 With random site, the children strings produced may or may
not have a combination of good substrings from parent
strings, depending on whether or not the crossing site falls in
the appropriate place.
 if good strings are created by crossover, there will be more
copies of them in the next mating pool generated by the
reproduction operator.
 But if good strings are not created by crossover, they
will not survive too long, because reproduction will
select against those strings in subsequent generations.
 The effect of crossover may be detrimental or beneficial.
 Thus, in order to preserve some of the good strings that
are already present in the mating pool, not all strings in
the mating pool are used in crossover.
 When a crossover probability of pc is used, only 100pc
per cent strings in the population are used in the
crossover operation and 100(1−pc) per cent of the
population remains as they are in the current population.
Mutation
 A crossover operator is mainly responsible for the search
of new strings, even though a mutation operator is also
used for this purpose sparingly.
 The mutation operator changes 1 to 0 and vice versa with a
small mutation probability, pm.
 The bit-wise mutation is performed by choosing a random
no between 0 and 1.
 If random no is below pm then the bit is altered; otherwise
the bit is kept unchanged.
 The need for mutation is to create a point in the
neighbourhood of the current point, thereby achieving a
local search around the current solution.
Before mutation
After mutation
1 0 1 0 1 0 1 1
0 1 1 0 1 1 1 0
0 1 1 1 0 1 0 1
Summary of GA Operators
 The reproduction operator selects good strings.
 Crossover operator recombines good substrings from
good strings together to hopefully create a better substring.
 The mutation operator alters a string locally to hopefully
create a better string.
 Even though none of these claims are guaranteed and/or
tested while creating a string.
 If bad strings are created they will be eliminated by the
reproduction operator in the next generation
 If good strings are created, they will be increasingly
emphasized.
Differences between GAs and
Traditional Methods
GAs work with a string-coding of variables
instead of the variables.
The most striking difference between GAs and
many traditional optimization methods is that
GAs work with a population of points instead of
a single point.
Because there are more than one string being
processed simultaneously, it is very likely that
the expected GA solution may be a global
solution
GA doesn’t require gradient information
x1 x2 l n
L 0 0 2 6
U 6 6
Random
S.No Substing -1 Substring-2 number

1 1 1 1 1
D
2 0 0 0 0 0.4
3 0 1 1 0 0.1
0.5
4 1 0 1 0
0.7
5 1 0 1 1 0.5
6 0 0 0 0 0.9

Perform Crossover on gene 1 for chromosome 3 and 4 after


reproduction
Perform mutation on bit 1 of gene 2 for chromosome 5 and
bit 2 of gene 1 for chromosome 3
 A rectangular cantilever beam of 10 m
length is subjected to a point force of 10
kN at free end. Yield stress is 50 MPa.
0≤b≤0.3
0≤h≤0.3
Design a beam with minimum weight
Cantilever beam GA Rectangular Cross-section with minimum
problem weight
P 10KN b x1
σ 50Mpa h x2
f(x) x1 x2 phi (x) x1x2+r(6M/x1x22-σ)^2 F(x) 1/(1+phi(x))

x1 x2 l n r
L 0 0 3 5 1
U 0.3 0.3

S.No Substring -1 Substring-2


1 1 1 0 1 1 1
2 0 0 1 0 1 0
3 1 0 1 0 1 1
4 1 1 1 1 1 0
5 0 1 0 1 0 1

You might also like