SC - GA - 7th Sem
SC - GA - 7th Sem
21-11-2023 1
Introduction to Evolutionary Computation
• Evolutionary Computation is the field of study
devoted to the design, development, and analysis
as problem solvers for solving complex problems
having multiple solutions based on natural
selection (simulated evolution).
• A nature inspired approach to optimization.
Process of getting the most out of something to get a better result. During this
process we are in search for best optimal solution. We are not finding a solution as
in other algorithms where input is given and output solution is obtained. Here, we
already have a set of solution but we have to get best solution out of it. During this
process, we are in search for best or optimal solution
• Abstraction of Real Biological Evolution.
• Evolution has proven to be a powerful search
process
Introduction to Evolutionary Computation
• Inspired by the Notion
• Natural Evolution: Survival of fittest from
Darwinian Evolution
• Mendel’s Modern genetics
11/21/2023 4
The behavior of an individual organism is an
inductive inference about some yet unknown
aspects of its environment.
11/21/2023 5
How is a population with increasing
fitness generated?
Let us consider a population of rabbits. Some
rabbits are faster than others, and we may say that
these rabbits possess superior fitness, because they
have a greater chance of avoiding foxes, surviving
and then breeding.
11/21/2023 7
Introduction to Evolutionary Computation
Basic operations
Why?
• Easy to code
• Gives many solutions (can
avoid local extrema)
• Can be parallelized)
Genetic Algorithms
In the early 1970s, John Holland introduced the
concept of genetic algorithms.
His aim was to make computers do what nature does.
Holland was concerned with algorithms that
manipulate strings of binary digits.
1 0 1 1 0 1 0 0 0 0 0 1 0 1 0 1
11/21/2023 11
The GA uses a measure of fitness of individual
chromosomes to carry out reproduction. As
reproduction takes place, the crossover operator
exchanges parts of two single chromosomes, and the
mutation operator changes the gene value in
some randomly chosen location of the chromosome.
11/21/2023 12
Basic genetic algorithms
Step 1: Represent the problem variable domain as
a chromosome of a fixed length, choose the size
of a chromosome population N, the crossover
probability pc and the mutation probability pm.
11/21/2023 15
Genetic algorithms
GA represents an iterative process. Each iteration is
called a generation. A typical number of generations
for a simple GA can range from 50 to over 500. The
entire set of generations is called a run.
Because GAs use a stochastic search method, the
fitness of a population may remain stable for a number
of generations before a superior chromosome appears.
A common practice is to terminate a GA after a
specified number of generations and then examine the
best chromosomes in the population. If no satisfactory
solution is found, the GA is restarted.
11/21/2023 17
Suppose that the size of the chromosome population
N is 6, the crossover probability pc equals 0.7, and
the mutation probability pm equals 0.001. The
fitness function in our example is defined by
f(x) = 15 x – x2
40 40
30 30
20 20
10 10
0 0
0 5 10 15 0 5 10 15
x x
(a) Chromosome initial locations. (b) Chromosome final locations.
11/21/2023 19
In natural selection, only the fittest species can
survive, breed, and thereby pass their genes on to
the next generation. GAs use a similar approach,
but unlike nature, the size of the chromosome
population remains unchanged from one
generation to the next.
The last column in Table shows the ratio of the
individual chromosome’s fitness to the population’s
total fitness. This ratio determines the chromosome’s
chance of being selected for mating. The
chromosome’s average fitness improves from one
generation to the next.
11/21/2023 20
Roulette wheel selection
The most commonly used chromosome selection
techniques is the roulette wheel selection.
100 0
X1: 16.5%
X2: 20.2%
75.2 X3: 6.4%
X4: 6.4%
X5: 25.3%
36.7 X6: 24.8%
49.5 43.1
11/21/2023 21
Crossover operator
In our example, we have an initial population of 6
chromosomes. Thus, to establish the same
population in the next generation, the roulette
wheel would be spun six times.
11/21/2023 22
First, the crossover operator randomly chooses a
crossover point where two parent chromosomes
“break”, and then exchanges the chromosome
parts after that point. As a result, two new
offspring are created.
11/21/2023 23
Crossover
X6i 1 0 00 1 0 1 00 00 X2i
X1i 10 11 00 00 0 11 11 11 X5i
X2i 0 1 0 0 0 1 1 1 X5i
11/21/2023 24
Mutation operator
Mutation represents a change in the gene.
11/21/2023 25
Mutation
X6'i 1 0 0 0
X2'i 0 1 0 1
0
X1'i 1
0 1 1 1 1 1 X1"i
X5'i 0 1 0
1 0
1
X2i 0 1 0 0 1 0 X2"i
X5i 0 1 1 1
11/21/2023 26
The genetic algorithm cycle
C rossover
Generation i
X1i 1 1 0 0 f = 36 X6i 1 0 00 1 0 1 00 00 X2i
X2i 0 1 0 0 f = 44
X3i 0 0 0 1 f = 14
X4i 1 1 1 0 f = 14 X1i 0 11 00 00
1 0 11 11 11 X5i
X5i 0 1 1 1 f = 56
X6i 1 0 0 1 f = 54
X2i 0 1 0 0 0 1 1 1 X5i
Generation (i + 1)
X1i+1 1 0 0 0 f = 56 Mutation
X2i+1 0 1 0 1 f = 50 X6'i 1 0 0 0
X3i+1 1 0 1 1 f = 44
X2'i 0 1 0 1
0
X4i+1 0 1 0 0 f = 44
X1'i 0
1 1 1 1 1 1 X1"i
X5i+1 0 1 1 0 f = 54
X6i+1 0 1 1 1 f = 56 X5'i 0 1 0
1 0
1
X2i 0 1 0 0 1 0 X2"i
X5i 0 1 1 1
11/21/2023 27
Genetic algorithms: case study
Suppose it is desired to find the maximum of the
“peak” function of two variables:
2 x 2 ( y 1) 2 x2 y 2
f ( x, y) (1 x) e (x x y ) e
3 3
1 0 0 0 1 0 1 0 0 0 1 1 1 0 1 1
x y
11/21/2023 28
We also choose the size of the chromosome
population, for instance 6, and randomly generate
an initial population.
The next step is to calculate the fitness of each
chromosome. This is done in two stages.
First, a chromosome, that is a string of 16 bits, is
partitioned into two 8-bit strings:
1 0 0 0 1 0 1 0 and 0 0 1 1 1 0 1 1
Then these strings are converted from binary
(base 2) to decimal (base 10):
(10001010) 2 1 27 0 26 0 2 5 0 2 4 1 23 0 2 2 1 21 0 2 0 (138)10
and
(00111011) 2 0 2 7 0 2 6 1 25 1 2 4 1 2 3 0 2 2 1 21 1 2 0 (59)10
11/21/2023 29
Now the range of integers that can be handled by
8-bits, that is the range from 0 to (28 - 1), is
mapped to the actual range of parameters x and y,
that is the range from -3 to 3:
6
0.0235294
256 1
11/21/2023 31
Chromosome locations on the surface of the
“peak” function: initial population
11/21/2023 32
Chromosome locations on the surface of the
“peak” function: first generation
11/21/2023 33
Chromosome locations on the surface of the
“peak” function: local maximum
11/21/2023 34
Chromosome locations on the surface of the
“peak” function: global maximum
11/21/2023 35
Performance graphs for 100 generations of 6
chromosomes: local maximum
pc = 0.7, pm = 0.001
0. 7
0. 6
0. 5
0. 4
Fitness
0. 3
0. 2
0. 1
Best
0 Average
-0.1
0 10 20 30 40 50 60 70 80 90 100
Generations
11/21/2023 36
Performance graphs for 100 generations of 6
chromosomes: global maximum
pc = 0.7, pm = 0.01
1.8
1.6
1.4
1.2
Fitness
1.0
0.8
0.6
Best
0.4 Average
0.2
0 10 20 30 40 50 60 70 80 90 100
Generations
11/21/2023 37
Performance graphs for 20 generations of
60 chromosomes
pc = 0.7, pm = 0.001
1.8
1.6
1.4
1. 2
Fitness
1.0
0.8
0.6
Best
0.4 Average
0.2
0 2 46 8 10 12 14 16 18 20
Generations
11/21/2023 38
String x Initial pop. Actual
No. Value (randomly generated) Count
from
Roulette
Wheel
1 13 01101 168 0.16 0.64 1
11/21/2023 42
Applications Of GA
• Optimization − Genetic Algorithms are most commonly used in optimization
problems wherein we have to maximize or minimize a given objective function
value under a given set of constraints.
• Neural Networks − GAs are also used to train neural networks, particularly
recurrent neural networks.
• Image Processing − GAs are used for various digital image processing (DIP) tasks
as well like dense pixel matching.
• Vehicle routing problems − With multiple soft time windows, multiple depots and
a heterogeneous fleet.
• Machine Learning − as already discussed, genetics based machine learning
(GBML) is a niche area in machine learning.
• DNA Analysis − GAs have been used to determine the structure of DNA using
spectrometric data about the sample.
• Multimodal Optimization − GAs are obviously very good approaches for
multimodal optimization in which we have to find multiple optimum solutions.
• Travelling salesman problem and its applications − GAs have been used to solve
the TSP, which is a well-known combinatorial problem using novel crossover and
packing strategies.
11/21/2023
Exercise (Knapsack Problem)
There are 4 items, each item is associated with some weight (W) and value at
item (v)
ITEM WEIGHT (Kg) VALUE ($)
A 5 12
B 3 5
C 7 10
D 2 7
There is a knapsack (k) with limited capacity that can hold atmost 12Kg.
Which item should be kept in the Knapsack so as it will maximize Knapsack
value without breaking the Knapsack. Using stepwise algorithm of GA, solve
the problem. Obtain the new population (solution) after single mutation
operation.
(Knapsack Problem)
(Knapsack Problem)
Any
Questions
?????
Dr. Rashmi Sinha, NIT Jamshedpur
48