Genetic Algorithm
Genetic Algorithm
CSE - 351
Genetic
Algorithm
Contents
❖ Evolution
❖ Natural Evolution
❖ Evolutionary Computation
❖ Genetic Algorithms
❖ Evolution Strategy
❖ Genetic Programming
❖ An Example Scenario
3
Evolution?
4
Natural Evolution
❖On 1st July 1858, Darwin Presented his theory of
evolution
❖Darwin’s classical theory of evolution, together
with Weisman’s theory of natural selection and
Mendel’s concept of genetics now represent the
Neo-Darwinian paradigm.
❖Neo-Darwinism is based on the process of
reproduction, mutation, competition and
selection.
5
Evolutionary Computation
6
Genetic Algorithms
❖A type of evolutionary computation inspired by
Darwin’s theory of evolution.
❖A genetic algorithm generates a population of
possible solutions encoded as chromosomes,
evaluates their fitness, and create a new population by
applying genetic operators-crossover and mutation.
❖By repeating this process over many generations, the
genetic algorithm breeds an optimal solution to the
problem.
7
Keywords Related to GA
❖Gene: A basic unit of chromosome that controls the
development of a particular feature of a living organism. In
Holland’s (Founder of GA) Chromosome a gene is represented
by either 0 or 1.
❖Chromosomes: A string of genes that represent an individual.
Each chromosome consists of a number of gene.
❖Fitness: The ability of a living organism to survive and
reproduce in a specific environment.
❖Crossover: A reproduction operator that creates a new
chromosome by exchanging parts of two existing chromosome.
❖Mutation: A genetic operator that randomly change the gene
value in a chromosome.
8
Keywords Related to GA (cont.)
❖Fitness Function: A mathematical function used for calculating
the fitness of a chromosome.
❖Crossover Probability: A number between zero and one that
indicates the probability of two chromosomes crossing over.
❖Mutation Probability: A number between zero and one that
indicates the probability of mutation occurring in a single gene.
❖Offspring: An individual that was produced through
reproduction. It also referred to as child.
❖Population: A group of individuals that breed together.
9
Evolution Strategy
❖Evolution strategy is a numerical optimization procedure.
❖Unlike the genetic algorithms, evolution strategies use only a
mutation operator, and do not require a problem to be represented
in coded form.
❖Evolution strategies are used for solving technical optimization
problems when no analytical objective function is available, and no
conventional optimization method exists.
10
Genetic Programming
11
Genetic Algorithm Flowchart
13
Example Problem & Solution
Step 1: GA creates an initial population of
chromosomes by filling six 4-bit string with
randomly generated ones and zeros
14
Example Problem & Solution
15
Fitness Function and Chromosome
Locations
. .
.
.
. .
16
Example Problem & Solution
Step 3: The fitness ratio determines the chromosome’s chance
of being selected for mating.
❖X5 & X6 have fair chance; X3 & X4 have less chance.
17
Fitness Function in Roulette
Wheel Distribution
1100 (12)=36
0100 (4)=44
0001 (1)=14
1110 (14)=14
0111 (7)=56
1001 (9)=54
18
Example Problem & Solution
(Mating)
Step 4: Select chromosome for mating.
❖First X6 & X2 become parents, 2nd X1 & X5, then X2 &
X5.
Generation i Crossover
Chromoso Chromosome
me Label String
X1i 1100 X6i 10-01 X2i 01-00
X2i 0100
X3i 0001 X1i 11-00 X5i 01-11
X4i 1110
X5i 0111 X2i 01-00 X5i 01-11
X6i 1001
19
Example Problem & Solution
(Crossover)
Step 5: Crossover Operator randomly chooses a crossover point
where two parent chromosomes ‘Break’ and then exchange the
chromosomes after that point.
Generation i Crossover
Chromoso Chromosome
me Label String
X1i 1100 X6i 10-01 X2i 01-00
X2i 0100
X3i 0001 X1i 11-00 X5i 01-11
X4i 1110
X5i 0111 X2i 01-00 X5i 01-11
X6i 1001
20
Example Problem & Solution
(Crossover)
Step 5: If a pair of chromosomes does not cross over then
chromosome cloning take places and the offspring are exact
copies of each parent.
Generation i Crossover
Chromoso Chromoso
me Label me String
X1i 1100 X6i 10-01 X2i 01-00 X6`i 1000
X2i 0100 X2`i 0101
X3i 0001 X1i 11-00 X5i 01-11 X1`i 1111
X4i 1110 X5`i 0100
X5i 0111 X2i 01-00 X5i 01-11 X5`i 0100
X6i 1001 X2`i 0111
21
Example Problem & Solution
(Mutation)
Step 6: The mutation operator flips a randomly selected gene in a
chromosome.
22
Example Problem & Solution
Step 7: The fitness ratio determines the chromosome’s chance
of being selected for mating.
❖X5 & X6 have fair chance; X3 & X4 have less chance.
23
Fitness Function and Chromosome
Locations
. .
24
Applications of Genetic Algorithm
• Links:
• https://www.quora.com/What-are-some-real-world-applications-of-
genetic-algorithms
. .
• http://brainz.org/15-real-world-applications-genetic-algorithms/
• https://en.wikipedia.org/wiki/List_of_genetic_algorithm_applications
25
Recommended Textbooks
❖ [Negnevitsky, 2001] M. Negnevitsky “ Artificial Intelligence:
A guide to Intelligent Systems”, Pearson Education Limited,
England, 2002.
❖ [Russell, 2003] S. Russell and P. Norvig Artificial
Intelligence: A Modern Approach Prentice Hall, 2003,
Second Edition
❖ [Patterson, 1990] D. W. Patterson, “Introduction to Artificial
Intelligence and Expert Systems”, Prentice-Hall Inc.,
Englewood Cliffs, N.J, USA, 1990.
❖ [Lindsay, 1997] P. H. Lindsay and D. A. Norman, Human
Information Processing: An Introduction to Psychology,
Academic Press, 1977.
26