Genetic Algorithm
Genetic Algorithm
Canonical Genetic
Algorithms
2
History of Genetic Algorithms
In 1960’s
Rechenberg: “evolution strategies”
Optimization method for real-valued parameters
Fogel, Owens, and Walsh: “evolutionary programming”
Real-valued parameters evolve using random mutation
In 1970’s
John Holland and his colleagues at University of Michigan
developed “genetic algorithms (GA)”
Holland’s1975 book “Adaptation in Natural and Artificial
Systems” is the beginning of the GA
Holland introduced “schemas,” the framework of most
theoretical analysis of GAs. 3
In 1990’s
John Koza: “genetic programming” used genetic
algorithms to evolve programs for solving certain tasks
4
Differences Between GAs and
Traditional Methods
GAs operate on encodings of the parameters values,
not necessarily the actual parameter values
GAs operate on a population of solutions, not a
single solution
GAs only use the fitness values based on the
objective functions
GAs use probabilistic computations, not
deterministic computations
GAs are efficient in handling problems with a
discrete or mixed search spaces
5
The Canonical GA
Canonical GA
The canonical genetic algorithm refers to the GA
proposed by John Holland in 1965
START
Initialization
Fitness evaluation
Selection
Crossover
Mutation
STOP?
END
7
Gene Representation
Parameter values are encoded into binary strings of
fixed and finite length
Gene: each bit of the binary string
Chromosome: a binary string
Individual: a set of one or multiple chromosomes, a
prospective solution to the given problem
Population: a group of individuals
Longer string lengths
Improve resolution
Requires more computation time
8
Binary Representation
Suppose we wish to maximize f (x)
Where [
x ∈ Ω; Ω = xmin, xmax ]
Binary representation xbinary ∈ [bl bl −1 L b2 b1 ]
[
We map xmin, xmax ] to [0 , 2 l
−1 ]
x max − x min l
i −1
Thus x = x min + ∑ i
b 2
2l − 1 i =1
9
Example
Let l = 5, Ω = [-5, 20]
Then
xbinary = [ 0 0 0 0 0 ] ⇒ x = −5
xbinary = [ 1 1 1 1 1 ] ⇒ x = 20
20 − (−5)
xbinary = [ 1 0 0 1 1 ] ⇒ x = −5 + (2 4 + 21 + 2 0 ) = 10.3226
2 −1
5
10
Fitness Evaluation
Each individual x is assigned with a fitness value
f(x) as the measure of performance
It is assumed that the fitness value is positive and
the better the individual as a solution, the fitness
value is more positive
The objective function can be the fitness function
itself if it is properly defined
11
Example 1
Consider the problem
A fitness function
f(x) =-g(x)+100= -x2 + 4x + 100
12
Example 2
Consider the problem
min g(x) = x2, x ∈ [-10, 10]
A fitness function
f(x) = 1/(g(x) + 0.1) = 1/(x2 + 0.1)
13
Selection
Chooses individuals from the current population to
constitute a mating pool for reproduction
Fitness proportional selection methods
Each individual x is selected and copied in the
mating pool with the probability proportional to
fitness (f(x) / Σf(x))
14
Roulette Wheel Selection
Individuals with
fitness values Mating pool
19
76
Winner
44
27 Assign a piece
8 proportional to the
53 fitness value
31
76
15
Crossover
Single-point crossover is assumed
Two parent individuals are selected from mating pool
Crossover operation is executed with the probability pc
Crossover point is randomly chosen and the strings are
swapped with respect the crossover point between the
two parents
16
Single Point Crossover
Crossover point
Parent 1 1 0 1 0 0 1 1 0 Child 1 1 0 1 0 1 0 1 1
Parent 2 1 1 0 0 1 0 1 1 Child 2 1 1 0 0 0 1 1 0
17
Mutation
Mutation operator is applied gene-wise, that is, each
gene undergoes mutation with the probability pm
When the mutation operation occurs to a gene, its
gene value is flipped
1 0
0 1
Mutation points
1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1
18
Overview of Canonical GA
Initial
population Fitness
Evaluation
19
76
44
f (x) 27
8
53
31
76
Selection
20
A Manual Example
Using Canonical GAs
Problem Description
Consider the following maximization problem
max f(x) = x2
where x is an integer between 0 and 31
1000
900
800
700
600
f(x)
500
400
300
200
100
0
0 5 10 15 20 25 30
x
23
Canonical GA Execution Flow
START
Initialization
Fitness evaluation
Selection
Crossover
Mutation
STOP?
END
24
Initialization
Initial populations are randomly generated
Suppose that the population size is 4
An example initial population
26
Fitness Evaluation
Decoding
Results
Individual No. Initial population x value f(x) fi / Σf Expected
number
Roulette wheel 2
3
4
30
Mutation
Applied on a bit-by-bit basis
Each gene mutated with probability of pm = 0.001