Genetic algorithm

garima931 62,548 views 40 slides Aug 17, 2011
Slide 1
Slide 1 of 40
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40

About This Presentation

Presentation is about genetic algorithms. Also it includes introduction to soft computing and hard computing. Hope it serves the purpose and be useful for reference.


Slide Content

Genetic Algorithm
Made By
-Garima Singhal

Introduction
•One of the central challenges of computer science
is to get a computer to do what needs to be done,
without telling it how to do it.

•Before looking forward to what actually is
GENETIC PROGRAMMING we shall first get
acquainted with Soft Computing.

Soft Computing
•It is another field of computer science.
•It is the fusion of methodologies that were designed to model
and enable solutions to real world problems, which are not
modeled, or too difficult to model, mathematically.
•It is associated with fuzzy, complex and dynamic system with
uncertain parameters.
•Quality of Service Networking is an example of the class of
complex, fuzzy and dynamic systems with uncertain
parameters, which soft computing is intended to model and
compute.

Difference between Soft computing
And Conventional Computing
Hard
Computing(Conventional)
Soft Computing
Requires precisely stated analytical
model and a lot of computation time.
Tolerant of imprecision, uncertainty and
approximation.
Based on binary logic, numerical
analysis and crisp software.
Based on fuzzy logic, neural networks
and probabilistic reasoning.
Requires programs to be written. Can evolve its own programs.
Deterministic. Incorporates stochasticity.
Strictly sequential. Allows parallel computations.

Current Applications of Soft
Computing include
•Handwriting Recognition
•Image Processing and Data Compression
•Automotive Systems and Manufacturing
•Decision –Support Systems
•Neurofuzzy Systems
•Fuzzy Logic Control

Evolutionary Computation
•Evolutionary computation simulates evolution on a computer. The Evolutionary computation simulates evolution on a computer. The
result of such a simulation is a series of optimization algorithms, result of such a simulation is a series of optimization algorithms,
usually based on a simple set of rules. Optimizationusually based on a simple set of rules. Optimization iteratively iteratively
improves the quality of solutions until an optimal, or at improves the quality of solutions until an optimal, or at
least feasible, solution is found.least feasible, solution is found.

Contd…
•Evolutionary Computations can be studied under 2 categories:
Genetic Algorithm
Genetic programming

F i n o n a c c i N e w t o n
D i r e c t m e t h o d s I n d i r e c t m e t h o d s
C a l c u l u s - b a s e d t e c h n i q u e s
E v o l u t i o n a r y s t r a t e g i e s
C e n t r a l i z e d D i s t r i b u t e d
P a r a l l e l
S t e a d y - s t a t e G e n e r a t i o n a l
S e q u e n t i a l
G e n e t i c a l g o r i t h m s
E v o l u t i o n a r y a l g o r i t h m s S i m u l a t e d a n n e a l i n g
G u i d e d r a n d o m s e a r c h t e c h n i q u e s
D y n a m i c p r o g r a m m i n g
E n u m e r a t i v e t e c h n i q u e s
S e a r c h t e c h n i q u e s

Genetic Algorithm Terminologies
Now, before we start, we should understand some key terms :
Individual Any possible solution
Population Group of all individuals
Search
Space
All possible solutions to the problem
Chromosome Blueprint for an individual
Trait Possible aspect of an individual
Allele Possible settings for a trait
Locus The position of a gene on the chromosome
Genome Collection of all chromosomes for an individual

Premise
Evolution works biologically so maybe it will work with
simulated environments.
Here each possible solution (good or bad) is represented
by a chromosome (i.e. a pattern of bits which is sort of
synonymous to DNA)
Determine the better solutions
Mate these solutions to produce new solutions which are
(hopefully!) occasionally better than the parents.
Do this for many generations.

Outline of the Genetic Algorithm
•Randomly generate a set of possible solutions to a problem,
representing each as a fixed length character string
•Test each possible solution against the problem using a
fitness function to evaluate each solution
•Keep the best solutions, and use them to generate new
possible solutions
•Repeat the previous two steps until either an acceptable
solution is found, or until the algorithm has iterated through a
given number of cycles (generations)

Basic Operators of Genetic
Algorithm
•Reproduction: It is usually the first operator applied on
population. Chromosomes are selected from the population of
parents to cross over and produce offspring. It is based on
Darwin’s evolution theory of “Survival of the fittest”. Therefore,
this operator is also known as ‘Selection Operator’.
•Cross Over: After reproduction phase, population is
enriched with better individuals. It makes clones of good
strings but doesnot create new ones. Cross over operator is
applied to the mating pool with a hope that it would create
better strings.
•Mutation: After cross over, the strings are subjected to
mutation. Mutation of a bit involves flipping it,changing 0 to 1
and vice-versa.

Basic genetic algorithmsBasic genetic algorithms
•Step 1Step 1: : Represent the problem variable domain as a chromosome of a Represent the problem variable domain as a chromosome of a
fixed length, choose the size of a chromosome population fixed length, choose the size of a chromosome population NN, the , the
crossover probability crossover probability pp
cc and the mutation probability and the mutation probability pp
mm..
•Step 2Step 2: : Define a fitness function to measure the performance, or Define a fitness function to measure the performance, or
fitness, of an individual chromosome in the problem domain. The fitness fitness, of an individual chromosome in the problem domain. The fitness
function establishes the basis for selecting chromosomes that will be function establishes the basis for selecting chromosomes that will be
mated during reproduction.mated during reproduction.
•Step 3Step 3: : Randomly generate an initial population of chromosomes of size Randomly generate an initial population of chromosomes of size
NN::
xx
11, , xx
22 , . . . , , . . . , xx
NN
•Step 4Step 4: : Calculate the fitness of each individual chromosome:Calculate the fitness of each individual chromosome:
f f ((xx
11), ), f f ((xx
22), . . . , ), . . . , f f ((xx
NN))

•Step 5Step 5: : Select a pair of chromosomes for mating from the current Select a pair of chromosomes for mating from the current
population. Parent`chromosomes are selected with a probability related population. Parent`chromosomes are selected with a probability related
to their fitness.to their fitness.
•Step 6Step 6:: Create a pair of offspring chromosomes by applying the genetic Create a pair of offspring chromosomes by applying the genetic
operators operators - - crossovercrossover and mand mutationutation..
•Step 7Step 7:: Place the created offspring chromosomes in the new Place the created offspring chromosomes in the new
population.population.
•Step 8Step 8:: RepeatRepeat Step 5 Step 5 until the size of the new chromosome population until the size of the new chromosome population
becomes equal to the size of the initial population, becomes equal to the size of the initial population, NN..
•Step 9Step 9:: Replace the initial (parent) chromosom population with the Replace the initial (parent) chromosom population with the
new (offspring) population.new (offspring) population.
•Step 10Step 10:: Go to Go to Step 4Step 4, and repeat the process until the termination , and repeat the process until the termination
criterion is satisfied.criterion is satisfied.

Working Principle of Genetic
Algorithm

Genetic Algorithms: Case StudyGenetic Algorithms: Case Study
•A simple example will help us to understand how a GA works. Let A simple example will help us to understand how a GA works. Let
us find the maximum value of the function (15us find the maximum value of the function (15x x - - xx
22) where ) where
parameter parameter xx varies between 0 and 15. For simplicity, we may varies between 0 and 15. For simplicity, we may
assume that assume that x x takes only integer values. Thus, chromosomes can be takes only integer values. Thus, chromosomes can be
built with only four genes:built with only four genes:
IntegerBinarycodeIntegerBinarycodeIntegerBinarycode
1 11
2 7 12
3 8 13
4 9 14
5 10 15
6 1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1

•Suppose that the size of the chromosome population NSuppose that the size of the chromosome population N is 6, the is 6, the
crossover probability crossover probability pp
cc equals 0.7, and the mutation probability equals 0.7, and the mutation probability pp
mm
equals 0.001. The fitness function in our example is definedequals 0.001. The fitness function in our example is defined byby
ff((xx) = ) = 15 15 x x – – xx
22

The fitness function and chromosome The fitness function and chromosome
locationslocations
Chromosome
label
Chromosome
string
Decoded
integer
Chromosome
fitness
Fitness
ratio, %
X1 110 0 12 36 16.5
X2 0100 4 44 20.2
X3 0001 1 14 6.4
X4 1110 14 14 6.4
X5 0111 7 56 25.7
X6 1001 9 54 24.8
x
50
40
30
20
60
10
0
0 5 10 15
f(x)
(a)Chromosomeinitiallocations.
x
50
40
30
20
60
10
0
0 5 10 1 5
(b)Chromosomefinallocations.

•The last column in Table shows the ratio of the individual The last column in Table shows the ratio of the individual
chromosome’s fitness to the population’s total fitness. This ratio chromosome’s fitness to the population’s total fitness. This ratio
determines the chromosome’s chance of being selected for mating. The determines the chromosome’s chance of being selected for mating. The
chromosome’s average fitness improves from one generation to the chromosome’s average fitness improves from one generation to the
next.next.

Roulette wheel selectionRoulette wheel selection
•The most commonly used chromosome selection techniques is the The most commonly used chromosome selection techniques is the
roulette wheel selectionroulette wheel selection..
1000
36.7
43.1
49.5
75.2
X1:16.5%
X2:20.2%
X3:6.4%
X4:6.4%
X5:25.3%
X6:24.8%

Crossover operatorCrossover operator
•In our example, we have an initial population of 6 chromosomes. In our example, we have an initial population of 6 chromosomes.
Thus, to establish the same population in the next generation, the Thus, to establish the same population in the next generation, the
roulette wheel would be spun six times.roulette wheel would be spun six times.
•Once a pair of parent chromosomes is selected, the Once a pair of parent chromosomes is selected, the crossovercrossover
operator is applied.operator is applied.
•First, the crossover operator randomly chooses a crossover point First, the crossover operator randomly chooses a crossover point
where two parent chromosomes “break”, and then exchanges the where two parent chromosomes “break”, and then exchanges the
chromosome parts after that point. As a result, two new offspring chromosome parts after that point. As a result, two new offspring
are created.are created.
•If a pair of chromosomes does not cross over, then the chromosome If a pair of chromosomes does not cross over, then the chromosome
cloning takes place, and the offspring are created as exact copies of cloning takes place, and the offspring are created as exact copies of
each parent.each parent.

X6
i
100 0010X2
i
0010X2
i
0111X5
i
0X1
i
0111X5
i
1010
01
00
111
010

Mutation operatorMutation operator
•Mutation represents a change inMutation represents a change in the gene.the gene.
•Mutation is a background operator. Its role is to provide a guarantee Mutation is a background operator. Its role is to provide a guarantee
that the search algorithm is not trapped on a local optimum.that the search algorithm is not trapped on a local optimum.
•The mutation operator flips a randomly selected gene in a The mutation operator flips a randomly selected gene in a
chromosome.chromosome.
•The mutation probability is quite small in nature, and is kept low for The mutation probability is quite small in nature, and is kept low for
GAs, typically in the range between 0.001 and 0.01.GAs, typically in the range between 0.001 and 0.01.

0111X5'
i
010
X6'
i
100
0010X2'
i
01
00
01111X5
i
111X1"
i
11
X2"
i010
0X1'
i
111
010X2
i

1010X1
i
Generationi
0010X2
i
0001X3i
1110X4i
0111X5
i f = 56
1001X6
i f = 54
f = 36
f = 44
f = 14
f = 14
1000X1
i+1
Generation(i + 1)
0011X2
i+1
1101X3
i+1
0010X4i+1
0110X5i+1 f = 54
0111X6
i+1 f = 56
f = 56
f = 50
f = 44
f = 44
Crossover
X6i100 0010X2i
0010X2i 0111X5i
0X1
i 0111X5
i1010
01
00
111
010
Mutation
0111X5'i 010
X6'
i100
0010X2'
i
01
00
01111X5
i
111X1"
i11
X2"
i010
0X1'
i111
010X2
i

Example Checkboard
• We are given an n by n checkboard in which every field can
have a different colour from a set of four colours.
• Goal is to achieve a checkboard in a way that there are no
neighbours with the same colour (not diagonal).
1 2 3 4 5 6 7 8 9 1 0
1
2
3
4
5
6
7
8
9
1 0
1 2 3 4 5 6 7 8 9 1 0
1
2
3
4
5
6
7
8
9
1 0

•Chromosomes represent the way the checkboard is coloured.
• Chromosomes are not represented by bitstrings but by bitmatrices
• The bits in the bitmatrix can have one of the four values 0, 1, 2 or
3, depending on the colour
• Crossing-over involves matrix manipulation instead of point wise
operating. Crossing-over can be combining the parential matrices in
a horizontal, vertical, triangular or square way
• Mutation remains bitwise changing bits in either one of the other
numbers

• Fitness curve for the checkboard example
•This problem can be seen as a graph with n nodes and (n-1) edges,
so the fitness f(x) is easily defined as: f(x) = 2 · (n-1) ·n
0 100 200 300 400 500 600
130
135
140
145
150
155
160
165
170
175
180
Generations
Fitness
Best Fitness
Mean Fitness

0 100200300400500
130
140
150
160
170
180
Fitness
Lower-Triangular Crossing Over
0 200 400 600 800
130
140
150
160
170
180
Square Crossing Over
0 200 400 600 800
130
140
150
160
170
180
Generations
Fitness
Horizontal Cutting Crossing Over
0 500 1000 1500
130
140
150
160
170
180
Generations
Verical Cutting Crossing Over
Fitnesscurves for different cross-over
rules

The GA Cycle of Reproduction
Population
Fitness EvaluationGenetic Operators
Selection(Mating Pool)
Parents
Offspring
New
Generation
Manipulation
Reproduction
Decoded Strings

Issues for Genetic Algorithm
practitioners
•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.

Benefits Of Genetic Algorithms
•Easy to understand
•Supports multi-objective optimisation
•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

Genetic Algorithm Applications
Domains Application Types
Control Gas pipeline, pole balancing, missile evasion, pursuit
Robotics Trajectory planning
Signal Processing Filter design
Game Playing Poker, checker, prisoner’s dilemma
Scheduling Manufacturing facility, scheduling, resource allocation
Design Semiconductor layout, aircraft design, keyboard
configuration, communication networks
Combinatorial
Optimisation
Set covering, travelling salesmen, routing, bin packing,
graph coloring and partitioning

Any Questions

Bibliography
•www.softcomputing.net/gpsystems.pdf
•http://cs.mwsu.edu/~simpson/
•http://geneticalgorithms.ai-depot.com/Tutorial/Overview.html
•Neural Networks, Fuzzy Logic, And Genetic Algorithm:Synthesis And
Application
•S.Rajasekaran
•G.A.Vijayalakshmi Pai
•http://c2.com/cgi/wiki?GeneticAlgorithm
Tags