Fundamentals of Genetic Algorithm
Fundamentals of Genetic Algorithm
,w ty or ab kr ha C
fo .in rs de ea yr Fundamentals of Genetic Algorithms : AI Course Lecture 39 40, notes, slides .m w w www.myreaders.info/ , RC Chakraborty, e-mail [email protected] , June 01, 2010
www.myreaders.info/html/artificial_intelligence.html
www.myreaders.info
Return to Website
algorithm; Evolutionary algorithm (EAs); Genetic Algorithms (GAs) : biological background, search space, working principles, basic genetic algorithm, flow chart for Genetic programming; Encoding : binary encoding, value encoding, permutation encoding, and tree
encoding; Operators of genetic algorithm : reproduction or selection - roulette wheel selection, Boltzmann selection; fitness function; Crossover one point crossover, two Point crossover, uniform crossover, arithmetic, heuristic; Mutation - flip bit, boundary, nonuniform, uniform, Gaussian; Basic genetic algorithm solved
C R
,w ty or ab kr ha C
fo .in rs de ea yr .m w w
1. Introduction
Why genetic algorithms, Optimization, Search optimization algorithm; Evolutionary algorithm (EAs); Genetic Algorithms (GAs) : Biological background, Search space, Working principles, Basic genetic algorithm, Flow chart for Genetic programming.
2. Encoding
16-21
Reproduction or selection : Roulette wheel selection, Boltzmann selection; fitness function; Crossover: one-Point crossover, two-Point crossover, uniform crossover, arithmetic, heuristic; Mutation : flip bit, boundary, non-uniform, uniform, Gaussian.
4. Basic Genetic Algorithm
36-41
42
C R
,w ty or What are GAs ? ab kr ha Genetic Algorithms (GAs) are adaptive heuristic search algorithm based C
fo .in rs de ea yr .m w w
C R
,w ty or ab kr ha C
GA - Introduction
Solving others.
problems
mean
looking
for
solutions,
which
is
best
among
possible solutions. The set of possible solutions defines the search space (also called state space) for a given problem. Solutions or partial solutions are viewed as points in the search space.
In
problems are first formulated as mathematical models expressed in terms of functions and then to find a solution, discover the parameters that optimize the model or the function components that provide optimal system performance.
04
C R
,w ty or ab kr ha C
SC GA - Introduction
- It is better than conventional AI ; It is more robust. - Unlike older AI systems, the GA's do not break easily even if the inputs changed slightly, or in the presence of reasonable noise. - While performing search in large state-space, or multi-modal
state-space, or n-dimensional surface, a genetic algorithms offer significant benefits over many other typical search optimization techniques breath-first. "Genetic Algorithms are good at taking large, potentially huge search spaces and navigating them, looking for optimal combinations of things, the solutions one might not otherwise find in a lifetime.
(Salvatore Mangano Computer Design, May 1995)
05
like
linear
programming,
heuristic,
depth-first,
C R
,w ty or ab kr ha C
SC GA - Introduction
Optimization is a process that finds a best, or optimal, solution for a problem. The Optimization problems are centered around three factors : 1. An objective function which is to be minimized or maximized; Examples In manufacturing, we want to maximize the profit or minimize the cost . In designing an automobile panel, we want to maximize the strength. 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. 3. A set of constraints values but exclude others; Examples In manufacturing, one constrain is, that be non-negative. In the panel design, we want to limit the weight and put constrain on its shape. An optimization problem is defined as : that minimize or maximize the Finding values of the variables objective function while satisfying all "time" variables to that allow the unknowns to take on certain
the constraints.
06
C R
,w ty or ab kr ha C
SC GA Introduction
Enumerative Techniques
Uninformed Search
Informed Search
Newton
Finonacci
Tabu Search
Hill Climbing
Simulated Annealing
Evolutionary Algorithms
Genetic Programming
Genetic Algorithms
We are interested in evolutionary search 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, - the different search strategies The Evolutionary Algorithms include : - Genetic Algorithms - Genetic Programming
07
and
and
C R
,w ty or ab kr ha C
SC GA - Introduction
Evolutionary Algorithm (EA) is a subset of Evolutionary Computation (EC) which is a subfield of Artificial Intelligence (AI).
Evolutionary Computation (EC)
is
general
term
for
several
computational techniques. Evolutionary Computation represents powerful search and optimization paradigm influenced by biological mechanisms of evolution : that of natural selection and genetic.
Evolutionary Algorithms (EAs)
refers to
models using randomness and genetic inspired operations. involve selection, recombination, random variation and competition of the individuals in a population of adequately represented potential solutions. The candidate solutions are referred as chromosomes or individuals.
Genetic Algorithms (GAs) represent the main paradigm of
Evolutionary
Computation.
-
GAs simulate natural evolution, mimicking processes the nature uses : Selection, Crosses over, Mutation and Accepting.
GAs
EC
Evolutionary Computing
GP
Genetic Programming
ES
Evolution Strategies
EP
Evolutionary Programming
GA
Genetic Algorithms
Rechenberg 1960
08
Koza 1992
Rechenberg 1965
Fogel 1962
Holland 1970
C R
,w ty or ab kr ha C
SC GA - Introduction
Genetic
algorithms
(GAs)
are
the
main
paradigm
of
evolutionary
computing.
"survival of the fittest". In nature, competition among individuals for scanty resources results in the fittest individuals dominating over the weaker ones.
GAs
uses; ie., Selection, Crosses over, Mutation and Accepting, to evolve a solution to a problem.
GAs
are
problems.
GAs,
search into the region of better performance within the search space. The biological background (basic genetics), the scheme of evolutionary processes, the working principles and the steps involved in GAs are illustrated in next few slides.
09
C R
fo .in rs de SC GA - Introduction ea yr Biological Background Basic Genetics .m w w Every organism has a set of rules, describing how that organism ,w ty or is built. All living organisms consist of cells. ab kr ha In each cell there is same set of chromosomes. Chromosomes are C
birth) is called the phenotype, its physical and mental characteristics, such as eye color, intelligence etc.
When two organisms mate they share their genes; the resultant
offspring may end up having half the genes from one parent and half from the other. This process is called recombination (cross over) .
The new created offspring can then be mutated. Mutation means,
that the elements of DNA are a bit changed. This changes are mainly caused by errors in copying genes from parents.
The fitness of an organism is measured by success of the organism
C R
ty or ab kr ha C
fo .in rs de SC GA - Introduction ea [ continued from previous slide - Biological background ] yr .m w w Below shown, the general scheme of evolutionary process in genetic ,w
Parents
Initialization Recombination
Population
Mutation Termination Survivor Fig. General Scheme of Evolutionary process
Offspring
each candidate;
1. SELECT parents; 2. RECOMBINE pairs of parents; 3. MUTATE the resulting offspring; 4. SELECT individuals or the next generation;
END.
11
C R
,w ty or ab kr ha C
SC GA - Introduction
In solving problems, some solution will be the best among others. The space of all feasible solutions (among which the desired solution resides) is called search space (also called state space).
Each Each
point in the search space represents one possible solution. possible solution can be "marked" by its value (or fitness) for
the problem.
The
times the search space may be well defined, but usually only a few
points in the search space are known. In using GA, the process of finding solutions generates other points (possible solutions) as evolution proceeds.
12
C R
,w ty or ab kr ha C
SC GA - Introduction
form of genes.
Gene
a part of chromosome; a gene contains a part of solution. It e.g. 16743 is a chromosome and 1, 6, 7, 4
: same as number
Population:
chromosome.
Fitness
based
on how far or
close a individual is from the solution; greater the fitness value better the solution it contains.
Fitness
It is problem specific.
Breeding
Working principles : Genetic algorithm begins with a set of solutions (represented by chromosomes) called the population.
Solutions
population. This is motivated by the possibility that the new population will be better than the old one.
Solutions
(offspring); more suitable they are, more chances they have to reproduce.
This
C R
ty or ab kr ha C
fo .in rs de SC GA - Introduction ea yr Outline of the Basic Genetic Algorithm .m w w 1. [Start] Generate random population of n chromosomes (i.e. suitable ,w
3.
steps until the new population is complete. (a) [Selection] Select two parent chromosomes from a population according to their fitness (better the fitness, bigger the chance to be selected) (b) [Crossover] With a crossover probability, cross over the parents to form new offspring (children). If no crossover was performed, offspring is the exact copy of parents. (c) [Mutation] With a mutation probability, mutate new offspring at each locus (position in chromosome). (d) [Accepting] Place new offspring in the new population
4.
[Replace] Use new generated population for a further run of the algorithm
5.
[Test] If the end condition is satisfied, stop, and return the best solution in current population
6.
operators called crossover and mutation. These two operators are the most important parts of GA.
14
C R
,w ty or ab kr ha C
SC GA Introduction
Start
Natural Selection
No
Reproduction Recombination
Use crossover operator to produce off- springs
Crossover
Crossover Finished?
Survival of Fittest
Apply replacement operator to incorporate new individual into population
Yes Yes No
Natural Selection Select one off-spring
Mutation
No
Terminate?
Yes
Finish
Mutation Finished?
C R
fo .in rs de SC GA Encoding ea 2. Encoding yr .m w w Before a genetic algorithm can be put to work on any problem, a method is ,w ty needed to encode potential solutions to that problem in a form so that a or ab kr computer can process. ha C
One
of 1's and 0's, where the digit at each position represents some aspect of the solution.
Example :
the
value of
A Gene represents some data (eye color, hair color, sight, etc.). A chromosome is an array of genes. In binary form a Gene looks like : a Chromosome looks like: Gene1
(11100010) Gene2 Gene3 Gene4
A chromosome should in some way contain information about solution which it represents; it thus requires encoding. The most popular way of encoding is a binary string like :
Chromosome 1 : 1101100100110110 Chromosome 2 : 1101111000011110
16
C R
,w ty or ab kr ha C
SC GA - Encoding
Binary encoding is the most common to represent information contained. In genetic algorithms, it was first used because of its relative simplicity.
In
Binary
say
0 to 15
Numeric value 6 7 8 9 10 11
Numeric value 12 13 14 15
C R
,w ty or ab kr ha C
SC GA Encoding
Two variable function represented by 4 bit string for each variable. Let two variables X1 , X2 as
(1011 0110) .
Every variable will have both upper and lower limits as X iL Because 4-bit string can represent integers from 0 to 15, so (0000 0000) and (1111 1111) represent the points for X1 , X2 as
( X1 ,L X2
L
Xi
Xi
and
( X1
, X2
respectively.
Equivalent integer
0 1 0 0x 2 1x 2 0x 2 1x 2
0 1 2 3
k 2
Sk
(0111),
Knowing X i
and X iU
corresponding to
and
(1111) ,
Xi =X
Xi (X i + --------------( 2ni 1 )
L
) x
(decoded value of string)
For
=2,
and X i
4-bit string Xi =
The accuracy obtained with a 4-bit code is 1/16 of search space. By increasing the string length by 1-bit , accuracy increases to 1/32.
18
C R
,w ty or ab kr ha C
SC GA 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. 2.
In value encoding, every chromosome is a sequence of some values. The Values can be anything connected to the problem, such as : real numbers, characters or objects. Examples :
Chromosome A Chromosome B Chromosome C 1.2324 5.3243 0.4556 2.3293 2.4545 ABDJEIFJDHDIERJFDLDFLFEGT (back), (back), (right), (forward), (left)
3.
C R
,w ty or ab kr ha C
SC GA Encoding
Permutation encoding can be used in ordering problems, such as traveling salesman problem or task ordering problem. 1. In permutation encoding, every chromosome is a string of numbers that represent a position in a sequence.
Chromosome A Chromosome B 153264798 856723149
2. Permutation encoding is useful for ordering problems. For some problems, crossover and mutation corrections must be made to leave the chromosome consistent.
Examples :
1. The Traveling Salesman problem: There are cities and given distances between them. Traveling salesman has to visit all of them, but he does not want to travel more than necessary. Find a sequence of cities with a minimal traveled distance. Here, encoded chromosomes describe the order of cities the salesman visits. 2. The Eight Queens problem : There are eight queens. Find a way to place them on a chess board so that no two queens attack each other. Here, encoding
C R
,w ty or ab kr ha C
SC GA - Encoding
Tree encoding is used mainly for evolving programs or expressions. For genetic programming :
In
5 (+ x(/ 5y))
Note : Tree encoding is good for evolving programs. The programming language LISP is often used. Programs in LISP can be easily parsed as a tree, so the crossover and mutation is relatively easy.
21
C R
fo .in rs de SC GA - Operators ea 3. Operators of Genetic Algorithm yr .m w w ,w Genetic operators used in genetic algorithms maintain genetic diversity. ty or Genetic diversity or variation is a necessity for the process of evolution. ab kr ha Genetic operators are analogous to those which occur in the natural world: C
Reproduction Crossover Mutation.
(or Selection) ;
In addition to these operators, there are some parameters of GA. One important parameter is Population size.
Population
generation).
If
there are many chromosomes, then GA slows down. shows that after some limit, it is not useful to increase population
Research
size, because it does not help in solving the problem faster. The population size depends on the type of encoding and the problem.
22
C R
,w ty or ab kr ha C
SC GA Operators
Reproduction
is
usually
the population, the chromosomes are selected to be parents to crossover and produce offspring.
The problem is how to select these chromosomes ?
According to Darwin's evolution theory "survival of the fittest" the best ones should survive and create new offspring.
The
Reproduction operators are also called Selection operators. means extract a subset of genes from an existing population,
Selection
according to any definition of quality. Every gene has a meaning, so one can derive from the gene a kind of quality measurement called
fitness function. Following this quality (fitness value), selection can be
performed.
Fitness
that a particular solution may be ranked against all the other solutions. The function depicts the closeness of a given solution to the desired result. Many reproduction operators exists and they all essentially do same thing. They pick from current population the strings of above average and insert their multiple copies in the mating pool in a probabilistic manner. The most commonly used methods of selecting chromosomes for parents to crossover are :
Roulette
Rank
Boltzmann
Steady
Tournament
The Roulette wheel and Boltzmann selections methods are illustrated next.
23
C R
,w ty or ab kr ha C
SC GA Operators
Evolutionary Algorithms is to maximize the function f(x) = x2 with x in the integer interval [0 , 31], i.e., x = 0, 1, . . . 30, 31.
for integers; 5-bits are used to represent integers up to 31. 2. Assume that the population size is 4.
3. Generate
initial population at random. They are chromosomes or e.g., 01101, 11000, 01000, 10011.
genotypes;
5. Select parents (two individuals) for crossover based on their fitness in pi. Out of many methods for selecting the best chromosomes, if
roulette-wheel selection is used, then the probability of the i
th
in the population is
pi = F i / (
string
Fj ) ,
j=1
where
is probability of the string i being selected, is no of individuals in the population, is population size, n=4
n * pi is expected count
String No 1 2 3 4 Sum Average Max Initial Population 01101 11000 01000 10011 X value 13 24 8 19 Fitness Fi f(x) = x2 169 576 64 361 1170 293 576 pi 0.14 0.49 0.06 0.31 1.00 0.25 0.49 Expected count N * Prob i 0.58 1.97 0.22 1.23 4.00 1.00 1.97
C R
,w ty or ab kr ha C
SC GA Operators
Roulette-wheel selection, also known as Fitness Proportionate Selection, is a genetic operator, used for selecting potentially useful solutions for recombination. In fitness-proportionate selection :
the
1 8
20% 5%
simulates values
8 Fi,
individuals
individual
has
higher
7
8%
13%
fitness than others, so the wheel would choose the 5th individual
6
8% 17%
fitness
of
the
individuals wheel is
is spun
4
20%
the
5
Fig. Roulette-wheel Shows 8 individual with fitness
Probability of
th
string is pi = F i / (
F j ) , where
n = no of individuals, called population size; pi = probability of ith string being selected; Fi = fitness for ith string Because a string's
F F
in the population.
the circumference of the wheel is marked according to fitness, the Roulette-wheel mechanism is expected to
make
Average fitness =
Cumulative Probability5 =
Expected count = (n =8 ) x pi
i=1
25
pi
C R
,w ty or ab kr ha C
SC GA Operators
cooling
expression suggests
almost uniform probability at any energy state, but at temperature it has a small probability of being at a higher energy state.
Thus,
process follows Boltzmann probability distribution, the convergence of the algorithm is controlled.
26
C R
,w ty or ab kr ha C
SC GA Operators
Crossover is a genetic operator that combines (mates) two chromosomes (parents) to produce a new chromosome (offspring). The idea behind crossover is that the new chromosome may be better than both of the parents if it takes the best characteristics from each of the parents. Crossover occurs during evolution according to a user-definable crossover probability. Crossover selects genes from parent chromosomes and creates a new offspring. The Crossover operators are of many types.
one the
simple way is, One-Point crossover. others are Two Point, Uniform, Arithmetic, and Heuristic crossovers.
The operators are selected based on the way chromosomes are encoded.
27
C R
,w ty or ab kr ha C
SC GA Operators
One-Point crossover operator randomly selects one crossover point and then copy everything before this point from the first parent and then everything after the crossover point copy from the second parent. The
Crossover would then look as shown below. Consider the two parents selected for crossover.
Parent 1 Parent 2 11011|00100110110 11011|11000011110
Interchanging the parents chromosomes after the crossover points The Offspring produced are :
Offspring 1 Offspring 2 11011|11000011110 11011|00100110110
28
C R
,w ty or ab kr ha C
SC GA Operators
Two-Point crossover operator randomly selects two crossover points within a chromosome then interchanges the two parent chromosomes between these points to produce two new offspring. Consider the two parents selected for crossover :
Parent 1 Parent 2 11011|0010011|0110 11011|1100001|1110
Interchanging the parents chromosomes between the crossover points The Offspring produced are :
Offspring 1 Offspring 2
29
11011|0010011|0110 11011|0010011|0110
C R
,w ty or ab kr ha C
SC GA Operators
Uniform crossover operator decides (with some probability know as the mixing ratio) which parent will contribute how the gene values in the offspring chromosomes. The crossover operator allows the parent
chromosomes to be mixed at the gene level rather than the segment level (as with one and two point crossover). Consider the two parents selected for crossover.
Parent 1 Parent 2 1101100100110110 1101111000011110
If the mixing ratio is 0.5 approximately, then half of the genes in the offspring will come from parent 1 and other half will come from parent 2. The possible set of offspring after uniform crossover would be:
Offspring 1 Offspring 2 11120 1
2 2 1
1 1
1 2
1 1
1 2
12 12 0 01 01 1
2 1
0 0
1 2
0 0
1 2
0 1
2 1
1 1
1 2
1 0
2 1
1 1
1 2
1 1
1 2
02 01
Note: The subscripts indicate which parent the gene came from.
30
C R
,w ty or ab kr ha C
fo .in rs de ea yr Arithmetic .m w w
SC GA Operators
Arithmetic crossover operator linearly combines two parent chromosome vectors to produce two new offspring according to the equations:
Offspring1 = a * Parent1 + (1- a) * Parent2 Offspring2 = (1 a) * Parent1 + a * Parent2
where a is a random weighting factor chosen before each crossover operation. Consider two parents (each of 4 float genes) selected for crossover:
Parent 1 Parent 2 (0.3) (0.5) (1.4) (4.5) (0.2) (0.1) (7.4) (5.6)
Applying
the
above
two
equations
and
assuming
the
weighting
factor a = 0.7, applying above equations, we get two resulting offspring. The possible set of offspring after arithmetic crossover would be:
Offspring 1 Offspring 2
31
(0.36)
(2.33)
(0.17)
(6.87)
C R
,w ty or ab kr ha C
fo .in rs de ea yr Heuristic .m w w
SC GA Operators
Heuristic crossover operator uses the fitness values of the two parent chromosomes to determine the direction of the search. The offspring are created according to the equations:
Offspring1 = BestParent + r * (BestParent WorstParent) Offspring2 = BestParent
where r is a random number between 0 and 1. It is possible that offspring1 will not be feasible. It can happen if chosen such that one or more of its genes fall outside of the allowable upper or lower bounds. For this reason, heuristic crossover has a user defined parameter n for the number of times to try and find an r that results in a feasible chromosome. If a feasible chromosome is not produced after n tries, the worst parent is returned as offspring1.
32
is
C R
,w ty or ab kr ha C
SC GA Operators
After a crossover is performed, mutation takes place. Mutation is a genetic operator used to maintain genetic diversity from one generation of a population of chromosomes to the next. Mutation occurs during evolution according to a user-definable mutation probability, usually set to fairly low value, say
0.01
Mutation alters one or more gene values in a chromosome from its initial state. This can result in entirely new gene values being added to the gene pool. With the new gene values, the genetic algorithm may be able to arrive at better solution than was previously possible. Mutation is an important part of the genetic search, helps to prevent the population from stagnating at any local optima. Mutation is intended to prevent the search falling into a local optimum of the state space. The Mutation operators are of many type.
one the
simple way is, Flip Bit. others are Boundary, Non-Uniform, Uniform, and Gaussian. selected based on the way chromosomes are
C R
,w ty or ab kr ha C
SC GA - Operators
The mutation operator simply inverts the value of the chosen gene. i.e. 0 goes to 1 and
1 goes to 0.
This mutation operator can only be used for binary genes. Consider the two original off-springs selected for mutation.
Original offspring 1 Original offspring 2 1101111000011110 1101100100110110
Invert the value of the chosen gene as 0 to 1 The Mutated Off-spring produced are :
Mutated offspring 1 Mutated offspring 2
34
and
1 to 0
1100111000011110 1101101100110100
C R
,w ty or ab kr ha C
fo .in rs de SC GA - Operators ea yr Boundary .m w The mutation operator replaces the value of the chosen gene with either w
the upper or lower bound for that gene (chosen randomly). This mutation operator can only be used for integer and float genes.
Non-Uniform
The mutation operator increases the probability such that the amount of the mutation will be close to 0 as the generation number increases. This mutation operator prevents the population from stagnating in the early stages of the evolution then allows the genetic algorithm to fine tune the solution in the later stages of evolution. This mutation operator can only be used for integer and float genes.
Uniform
The mutation operator replaces the value of the chosen gene with a uniform random value selected between the user-specified upper and lower bounds for that gene. This mutation operator can only be used for integer and float genes.
Gaussian
The mutation operator adds a unit Gaussian distributed random value to the chosen gene. The new gene value is clipped if it falls outside of the user-specified lower or upper bounds for that gene. This mutation operator can only be used for integer and float genes.
35
C R
fo .in rs de SC GA Examples ea 4. Basic Genetic Algorithm : yr .m w w ,w Examples to demonstrate and explain : Random population, Fitness, Selection, ty or Crossover, Mutation, and Accepting. ab kr ha C Example 1 :
Maximize the function f(x) = x2 over the range of integers from 0 . . . 31. Note : This function could be solved by a variety of traditional methods such as a hill-climbing algorithm which uses the derivative.
One way is to :
Start
from any integer x in the domain of f at this point x the derivative f that the derivative is +ve, pick a new x which is at a small
Evaluate
Observing
until x = 31
C R
,w ty or ab kr ha C
fo .in rs de SC GA Examples ea [ continued from previous slide ] yr .m w w Genetic Algorithm Approach to problem - Maximize the function f(x) = x2
1.
2.
4.
5.
8 64;
, where
individuals in the population called population size, here N = 4. Thus the evaluation of the initial population summarized in table below .
String No i 1 2 3 4 Total (sum) Average Max Initial X value Fitness Prob i 2 Population (Pheno f(x) = x (fraction (chromosome) types) of total) 01101 13 169 0.14 11000 24 576 0.49 01000 8 64 0.06 10011 19 361 0.31 1170 1.00 293 0.25 576 0.49 Expected count N * Prob i 0.58 1.97 0.22 1.23 4.00 1.00 1.97
C R
,w ty or ab kr ha C
fo .in rs de SC GA Examples ea yr 6. Produce a new generation of solutions by picking from the existing .m w pool of solutions with a preference for solutions which are better w
By generating 4 uniform (0, 1) random values and seeing which bin they fall into we pick the four strings that will form the basis for the next generation.
Random No 0.08 0.24 0.52 0.87 7. Falls into bin 0.0 0.14 0.14 0.69 . . . . . . . . . . . . 0.14 0.63 0.63 1.00 Chosen string 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1
8.
Within each pair swap parts of the members solutions to create offspring which are a mixture of the parents :
For the first pair of strings:
01101 , 11000
11000
1 1 |0 0 0 1 0 |0 1 1
11011 10000
C R
,w ty or ab kr ha C
fo .in rs de SC GA Examples ea yr 9. Randomly mutate a very small fraction of genes in the population : .m w With a typical mutation probability of per bit it happens that none of the bits w
Observe that :
1. Initial populations :
01101, 11000,
2. The total fitness has gone from 1170 to 1754 in a single generation. 3. The algorithm has already come up with the string 11011 (i.e x = 27) as a possible solution.
39
C R
,w ty or ab kr ha C
SC GA Examples
Two uniform bars are connected by pins at A and B and supported at A. Let a horizontal force P acts at C.
A
Given : Force P = 2, Length of bars 1 = 2 ,
1
B
2
W1
fiction at all joints are neglected ? C P Solution : Since there are two unknowns and 1 , we use 4 bit binary for each unknown. 2
XU - XL Accuracy = ----------- = --------- = 60 24 - 1 90 - 0 15
W2
Hence, the binary coding and the corresponding angles Xi are given as
XiU - XiL Xi = XiL + ----------- Si
4
chromosome. 2 -1 e.g. the 6th chromosome binary code (0 1 0 1) would have the corresponding angle given by Si = 0 1 0 1 = 23 x 0 + 22 x 1 + 21 x 0 + 20 x 1 = 5
90 - 0 Xi = 0 + ----------- x 5 15 = 30
th
The binary coding and the angles are given in the table below.
S. No. Binary code Angle S. No. Binary code Si Xi 0000 0 1 9 0001 6 2 10 0010 12 3 11 0011 18 4 12 0100 24 5 13 0101 30 6 14 0110 36 7 15 0111 42 8 16 Angle Xi 48 54 60 66 72 78 84 90
P,
W1 ,
W2
1 , 2
all as 2 , we get ,
(Eq. 2) ie 0 , 90 (Eq. 3) 1 2
Equilibrium configuration is the one which makes a minimum . Since the objective function is ve , instead of minimizing the function f let us maximize -f = f . The maximum value of f = 8 when and 1 2
F= f7= f 7
are zero.
(Eq. 4)
C R
,w ty or ab kr ha C
fo .in rs de SC GA - Examples ea [ continued from previous slide ] yr .m w First randomly generate 8 population with 8 bit strings as shown in table below. w
Population Population of 8 bit strings Corresponding Angles No. (Randomly generated) (from table above) , 1 2 0000 0000 0 0 1 0010 0000 12 6 2 0001 0000 6 30 3 0010 1000 12 48 4 0110 1010 36 60 5 1110 1000 84 48 6 1110 1101 84 78 7 0111 1100 42 72 8 F=f7
These angles and the corresponding to fitness function are shown below.
F=1 F=2.1 F=3.11 F=3.11
=0 1
=12 1
=6 1
=12 1
=0 2
=6 2
=30 2
=48 2
F=4.6
F=1.91
F=1.93
F=4.55
=36 1
=84 1
=84 1
=42 1
=60 2
=48 2
=78 2
=72 2
Fig.
The above Table and the Fig. illustrates that : GA begins with a population of random strings. Then, each string is evaluated to find the fitness value. The population is then operated by three operators
by the three operators and evaluated until the termination criteria are met.
One cycle of these
C R
,w ty or ab kr ha C
Sc GA References
4. "Genetic algorithms and engineering design", by Mitsuo Gen, and Runwei Cheng,
(1997), John Wiley & Sons Inc, chapter 1- 10, page 1-411.
5. "Practical genetic algorithms", by Randy L. Haupt, (2004), John Wiley & Sons
Inc, Chapter 1- 7, page 1- 251. 6. Related documents from open source, mainly internet. being prepared for inclusion at a later date.
42
An exhaustive list is