Introduction to GA and SGA
Introduction to GA and SGA
2/5/2025 01 1
Genology of Metaheuristic Algorithms
1947 LS (47)
Greedy
1965 Heuristics (71) ES (62)
Year
1973
1977 SS (77)
1983 SA (83)
2/5/2025 GA 6
Randomized Search
2/5/2025 GA 7
Classes of Search Techniques
Searchtechniques
Parallel Sequential
Lack of robustness
2/5/2025 GA 9
Search Techniques (contd.)
2/5/2025 GA 10
GAs: A quick Overview
2/5/2025 GA 11
Why GAs
• Most of the real life problems are very complex and can not be solved in
polynomial time using a deterministic algorithm.
2/5/2025 GA 12
TSP example
• Problem:
• Given n cities
• Find a complete tour with
minimal length/cost
Computation Time ??
• NP-Hard Problem
2/5/2025 GA 13
Why GAs (contd.)
2/5/2025 GA 14
Why GAs (contd.)
• Efficiently exploit historical information to speculate on new search
points with expected improved performance : nature is full of
precedents
2/5/2025 GA 15
GAs
2/5/2025 GA 16
Why GAs (contd.)
2/5/2025 GA 17
Features of GAs
• Optimization Technique
• Darwin’s principle of evolution (survival of the fittest)
has made this optimization algorithm effective.
• Work with a coding of the parameter set
• Search from a population of points, not a single point
• Use payoff (objective function) information, not
derivatives or auxiliary knowledge
• Use probabilistic transition rules, not deterministic rules
2/5/2025 GA 18
GAs vs. Nature
2/5/2025 GA 19
Algorithm
• Repeat { Selection
Crossover
Mutation}
Until final solution.
2/5/2025 GA 21
Initialize Population
GA Flowchart
Evaluate Fitness
Yes
Terminate? Output
solution
No
Perform selection,
crossover and mutation
Evaluate Fitness
2/5/2025 GA 22
Encoding and Population
• Encoding: A chromosome encodes a solution in the search
space
– Usually binary string of 0’s and 1’s
– Each bit in the string can represent some characteristics of
the solution
– Chromosome size depends on parameter set to be encoded
• Population:
– A set of chromosomes in a population
– Population size is usually constant
– Common practice is to choose the initial population randomly.
2/5/2025 GA 23
Chromosome Size
An allele
parameter n
A Chromosome
2/5/2025 GA 24
Population
string 1
string 2
A population
string m
2/5/2025 GA 25
Fitness Evaluation
2/5/2025 GA 26
Selection (Reproduction)
• A process in which individual strings are copied according to their
objective function or fitness values : Darwin’s survival of fittest
• The primary objective is to emphasize the good solutions and eliminate the
bad solutions in a population, while keeping the population size constant.
• Better individuals get higher chance
– more copies to good strings
– fewer copies to bad strings
• Mimics the natural selection procedure to some extent
• Implementation:
• Roulette wheel selection
• Ranking Selection
• Tournament selection
• Boltzmann Selection
• Elitist Selection etc.
2/5/2025 GA 27
Roulette Wheel Selection
1/6 = 17%
fitness(A) = 3
A B fitness(B) = 1
C fitness(C) = 2
3/6 = 50% 2/6 = 33%
2/5/2025 GA 28
Ranking Selection
2/5/2025 GA 29
Tournament Selection
2/5/2025 GA 30
Elitist Model of GAs
2/5/2025 GA 31
Crossover
2/5/2025 GA 32
Single point Crossover (example)
Crossover point
2/5/2025 GA 33
n-point crossover
• Choose n random crossover points
• Split along those points
• Glue parts, alternating between parents
• Generalisation of 1 point (still some positional bias)
2/5/2025 GA 34
Uniform Crossover
• A more general version of the multi-point crossover.
• Each gene (bit) is selected randomly from one of the
corresponding genes of the parent chromosomes.
2/5/2025 GA 35
Comparison
• Disruption rate of crossover depends on both
recombination potential and exploratory power.
• Disruption rate increases with the number of crossover
points for both multipoint and uniform crossover
• For a large search space, uniform crossover is perform
better than single/multi point crossover
• A single point crossover may perform better than two-
point crossover.
2/5/2025 GA 36
Mutation
2/5/2025 GA 37
Mutation (example)
Before mutation
After mutation
2/5/2025 GA 38
Different forms of Mutation
• Flipping
– Flipping of a bit involves changing 0 to 1 and 1 to 0 based
on a mutation chromosome generated
• Interchanging
– Two random positions of the string are chosen and the bits
corresponding to those positions are interchanged
• Reversing
– A random position is chosen and the bits next to that
position are reversed and children chromosome is produced
2/5/2025 GA 39
Exploitation vs. Exploration
2/5/2025 GA 40
An example of SGA (Goldberg)
2/5/2025 GA 41
x2 example (contd.) : Selection
2/5/2025 GA 42
x2 example (contd.) :Crossover
2/5/2025 GA 43
x2 example (contd.) :Mutation
2/5/2025 GA 44
2/5/2025 GA 45
2/5/2025 GA 46
2/5/2025 GA 47
Shortcomings of SGA
2/5/2025 GA 48
Parameters
• Population size : usually fixed
• String/chromosome length : usually fixed
• Crossover probability : (mc)
• Mutation probability : (mm)
mc mm
• Termination criteria :
– desired fitness, if possible (known)
– generally a maximum number of iterations
2/5/2025 GA 49
Termination Criterion
The cycle of GA-operators (selection, crossover and
mutation) is repeated a number of times till :
– A desired objective function value is attained in any
string/chromosome of the population
or
– The average fitness value of a population becomes more or less
constant over a specified number of generations
or
– The number of generations/iterations is greater than some
pre-specified value.
2/5/2025 GA 50
Parameter Setting
• For a GA to be successful a balance between
exploration & exploitation is needed
• Selection of crossover and mutation probabilities are
important
• Best settings:
Population size: 20-30
Crossover rate: 0.75-0.95
Mutation rate: 0.005-0.01
• Exact vales are problem dependent-settings to be adaptive
2/5/2025 GA 51
Making GA adaptive: Co-evolution
2/5/2025 GA 52
GA evolves according to the fitness of
the chromosomes
• Control parameters co-evolve according to the
efficiency induced by them
• Efficiency Measured by
– Diversity level of the population
• Genotypical diversity: average distance of the
population from the best chromosome
• Phenotypical diversity: ratio between the best and the
average fitness
• Diversity measures control exploration,
exploitation and the selection pressure
2/5/2025 GA 53
Real coded GA
In Binary GA:
• Biological inheritance is better represented.
• Problem in encoding and decoding.
Genetic operation using binary code
• No of bits to be used for binary representation depends upon
accuracy requirement.
• Greater string length involves more computing time.
In real coded GA:
• Discretization and code conversion problem of binary GA
Crossover : C1 =λP1 +(1-λ)P2, C2 =λP2 +(1-λ)P1
Mutation : Adds small perturbations
2/5/2025 GA 54
TSP representation
Representation is an ordered list of
city numbers known as an order-
based GA.
• Encoding:
• Label the cities 1, 2, 3, ….., n
• One complete tour is one
permutation, e.g. for n = 8
CityList1 (3 5 7 2 1 6 4 8)
CityList2 (2 5 7 6 8 1 3 4)
2/5/2025 GA 55
Crossover
Child (5 8 7 2 1 6 3 4)
* *
Before: (5 8 7 2 1 6 3 4)
After: (5 8 6 2 1 7 3 4)
2/5/2025 GA 57
TSP30 - Overview of Performance
1800
1600
1400
1200
Distance
1000
800
600
400
200
0 Best
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
Worst
Generations (1000)
Average
2/5/2025 GA 58
??
• Why not a bad chromosome is totally
eliminated ?
• Mutation is mandatory?
• Population size : Population size is a critical factor
to determine.
– Large : time vs. diversity
– Too small : converge to local optima
2/5/2025 GA 59
??
• Total execution time T(approx) ?
I + n ??
given : n = no. of iterations (no. of generations)
p = population size (no. of chromosome)
d = decoding time of the parameters (from chromosome
representation to actual problem/function domain)
E = time to execute the function (problem to be optimized)
to calculate its output/result from the decoded parameters
F = time to calculate the fitness of the
function/output/result
I = time to generate initial population
2/5/2025 GA 60
Current Trends in GAs
Encoding strategy
Integer encoding
Real encoding
Encoding of other structures
Variable length representation
Operators
New domain specific operators
Variable and adaptive probabilities of the operations
Chromosome differentiation
Incorporation of local search –memetic search
Handling constraints
Reject infeasible strings
Penalty based method
2/5/2025 GA 61
Cont..
Multiobjective optimization
Multiple conflicting objectives to be simultaneously
optimized
NSGA-II, PAES, SPEA, SPEA-II, AMOSA
Hybridization with other soft computing tools
Neural networks
Fuzzy sets
Rough sets
2/5/2025 GA 62
Some GA Application Types
2/5/2025 GA 63
Conclusion
2/5/2025 GA 64
Questions
??
2/5/2025 GA 65
Thanks !
2/5/2025 GA 66