0% found this document useful (0 votes)
15 views

Introduction to GA and SGA

The document provides an introduction to Genetic Algorithms (GAs), which are a class of evolutionary algorithms that mimic natural selection and genetics to solve optimization problems. It outlines the components, motivation, and advantages of GAs, including their ability to handle complex problems and their parallel processing capabilities. The document also discusses various techniques involved in GAs such as selection, crossover, and mutation, along with their applications and parameter settings for effective implementation.

Uploaded by

Mousumi Dutta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Introduction to GA and SGA

The document provides an introduction to Genetic Algorithms (GAs), which are a class of evolutionary algorithms that mimic natural selection and genetics to solve optimization problems. It outlines the components, motivation, and advantages of GAs, including their ability to handle complex problems and their parallel processing capabilities. The document also discusses various techniques involved in GAs such as selection, crossover, and mutation, along with their applications and parameter settings for effective implementation.

Uploaded by

Mousumi Dutta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Introduction to

Genetic Algorithms (GAs)

2/5/2025 01 1
Genology of Metaheuristic Algorithms
1947 LS (47)

1962 EP (62) GA (62)

Greedy
1965 Heuristics (71) ES (62)
Year

1973

1977 SS (77)

1983 SA (83)

1986 TS (86) AIS(86)


SM (86)
GRASP(89) CEA(90)
1990 TA (90)
ILS (91)
1992 GDA (93) GP(92) ACO(92)
1993 NM (93)
VNS (95) DE (94) EDA,CA(94)
1995 PSO(95)
1996 GLS (95)
CMA-ES (96) BC(96)
Evolutionary Computation (EC)
EC is a computing paradigm based on the principles of
biological evolution.
–Meta-heuristic optimization techniques
–Population based nature
–Mimics natural genetic systems
Components of EC:
– Genetic Algorithms
– Genetic Programming
– Particle Swarm Optimization (PSO)
– Ant Colony Algorithms
2/5/2025 GA 2
Genetic Algorithms (GAs)

• Genetic algorithms are classified as evolutionary


algorithms as they mimic the process of evolution.
• Definition:
Randomized Search and Optimization technique
guided by the Principles of Natural Genetics.

• Natural selection : Survival of the fittest


• Natural reproduction
2/5/2025 GA 4
GA mimics evolution by

• Creating a pool of solutions.


• Allowing mating between the existing
solutions to produce new solutions.
• Allowing mutation for long term diversity
(diversity helps improvement in solution
quality).
• Allowing old solutions to die.
2/5/2025 GA 5
Motivation

Development of robust search and optimization


tool that is adaptive, not affected by the
problem environment i.e. nature of the search
space and the variables.

2/5/2025 GA 6
Randomized Search

– Not a simple random search


– Randomized search : random choice in a
guided path !
– Use the payoff function to guide search :
fitness

2/5/2025 GA 7
Classes of Search Techniques

Searchtechniques

Calculus-basedtechniques Guidedrandomsearchtechniques Enumerativetechniques

Direct methods Indirect methods Evolutionaryalgorithms Simulatedannealing Dynamic programming

Finonacci Newton Evolutionarystrategies Genetic algorithms

Parallel Sequential

Centralized Distributed Steady-state Generational


2/5/2025 GA 8
Different Search Techniques

Calculus based techniques – seek


local extrema by gradient descent –
hill climbing

Lack of robustness

• Single point search


• Restrictive requirements of
continuity and derivative
existence
• Multi peak function causes
dilemma : random restart
• Best in neighborhood of the
current point

2/5/2025 GA 9
Search Techniques (contd.)

2/5/2025 GA 10
GAs: A quick Overview

• Developed by John Holland, his colleagues, and


his students, K. DeJong, D. Goldberg, University
of Michigan (1970’s), USA
– to understand the adaptive processes of natural
systems
– to design artificial systems software that retains the
robustness of natural systems

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.

• Sometimes attainment to the best is less important for complex problem.


Rather near optimal solutions that can be generated quickly are more
desirable than optimal solutions which require huge amount of time.
– Ex: Traveling Salesman Problem (TSP).

GAs strive to improve as close as possible to optimality.

• When the problem can be modeled as an optimization one.

2/5/2025 GA 12
TSP example

• Problem:
• Given n cities
• Find a complete tour with
minimal length/cost

Computation Time ??

• Search space is BIG:


for 30 cities there are 30!  1032
possible tours

• NP-Hard Problem

2/5/2025 GA 13
Why GAs (contd.)

• Not limited by restrictive assumptions about the


search space
– Continuity
– Existence of derivative
– Uni-modality and local minima

• Robust search in complex space


– Balance between efficiency and efficacy (flexibility of
biological system necessary for survival in many different situations)

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

• Adaptive : Features of self-repair, self-guidance and reproduction are


the rules of the biological systems

• Costly redesign can be reduced

GAs work from a rich database of points simultaneously, climbing


many peaks in parallel; thus probability of finding a false peak (local
optima) is reduced.

2/5/2025 GA 15
GAs

Distribution of Individuals in Generation 0

Distribution of Individuals in Generation N

2/5/2025 GA 16
Why GAs (contd.)

• Always an answer/solution; answer gets better with time


empirically proved to be convergent
• Inherently parallel; easily distributed
• Supports multi-objective optimization
• Modular
• Finally, the power of GAs comes from simple concepts; easy
to understand

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

• A solution (phenotype) Individual


• Representation of a solution Chromosome
(genotype )
• Components of the representation Genes
• Set of solutions Population
• Selection:survival of Darwin’s Theory
the fittest
• Search operators Crossover and
Mutation

2/5/2025 GA 19
Algorithm
• Repeat { Selection
Crossover
Mutation}
Until final solution.

Convergence: run for maximum no. of


generations, most of the population becoming
identical.
2/5/2025 GA 20
Simple Genetic Algorithm (SGA)

1. Generate random population of chromosomes


2. Decode each chromosome to get an individual
3. Evaluate the fitness of each individual
4. Perform selection, crossover and mutation
5. Repeat steps 2, 3 and 4 until it reaches a
termination condition.

There is no overlapping between generations

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

Chromosome: A set of alleles/genes


A chromosome is an encoded form of all parameters
describing the given problem
An encoded parameter – A subset of alleles
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

• Fitness (objective function) associated with each


chromosome
• Indicates the degree of goodness of the encoded solution
(chromosome)
• only problem specific information (also known as the
payoff information) that GAs use
• for minimization problem
fitness  1/objective

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

» Assign to each individual a part of the


roulette wheel
» Spin the wheel n times to select n
individuals

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

• Ranks the population and every chromosome


receives fitness from the ranking
• The worst has fitness 1 and the best has fitness N
• Rank based proportioned selection scheme is
expected to perform better than fitness
proportioned scheme

2/5/2025 GA 29
Tournament Selection

2/5/2025 GA 30
Elitist Model of GAs

• This scheme is proposed by Keneth De Jong (1993)


• The best chromosome (elite string) or few best
chromosomes are copied to the new population
• The rest is done in a classical way
• This is done because best string may be lost if they are
not selected to reproduce or if crossover or mutation
destroy them
• This significantly improves the GA’s performance

2/5/2025 GA 31
Crossover

• Partial exchange of information between


two randomly selected parent chromosome
• Single point crossover : most commonly
used
• Probabilistic operation, mc

2/5/2025 GA 32
Single point Crossover (example)

Crossover point

before Crossover after

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

• Random alteration in the genetic structure


• Mutating a binary gene : simple negation of the bit
• Probabilistic operation : alter each gene
independently with a probability pm
• Exploring the search area : new search points
• Introduce genetic diversity into the population

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

• Exploration: Discovering promising areas in the search space, i.e.


gaining information on the problem – new search points

• Exploitation: Optimizing within a promising area, i.e. using


information - Exploit historical information: survival of the fittest
co-operation AND competition between them
• Crossover is explorative, it makes a big jump to an area somewhere
“in between” two (parent) areas
• Mutation is exploitative as well as explorative, it creates random small
diversions, thereby staying near (in the area of ) the parent
• Selection is totally exploitive

2/5/2025 GA 40
An example of SGA (Goldberg)

• Simple problem: max x2 over {0,1,…,31}


• GA approach:
– Representation: binary code, e.g. 01101  13
– Random initialization
– Population size: 4
– Roulette wheel selection
– 1-point crossover, bit wise mutation
We show one generational cycle done by hand

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

– Representation is too restrictive


– Mutation & crossovers only applicable for bit-
string & integer representations
– Selection mechanism sensitive for converging
populations with close fitness values

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

• Control parameters or their fuzzy representations co-


evolve with the chromosome representing solutions to a
particular problems.
• Adaptation in three levels
Population level: Adjust control parameters for the entire population
Individual level: Parameters adjusted for individuals
Component level: Manipulates parameters for individual
components

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

Crossover combines inversion and


recombination:
* *
Parent1 (3 5 7 2 1 6 4 8)
Parent2 (2 5 7 6 8 1 3 4)

Child (5 8 7 2 1 6 3 4)

This operator is called the Order1 crossover.


GA 56
Mutation

Mutation involves reordering of the list:

* *
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

Domain Application Types


Control gas pipeline, pole balancing, missile evasion, pursuit

Design semiconductor layout, aircraft design, keyboard


configuration, communication networks
Scheduling manufacturing, facility scheduling, resource allocation

Robotics trajectory planning


Machine Learning designing neural networks, improving classification
algorithms, classifier systems
Signal Processing filter design

Game Playing poker, checkers, prisoner’s dilemma

Combinatorial set covering, travelling salesman, routing, bin packing,


Optimization graph colouring and partitioning

2/5/2025 GA 63
Conclusion

Question: ‘If GAs are so smart, why aren’t they rich?’


Answer: ‘Genetic algorithms are rich - rich in
application across a large and growing
number of disciplines.’
- David E. Goldberg, Genetic Algorithms in Search, Optimization and Machine Learning

2/5/2025 GA 64
Questions

??

2/5/2025 GA 65
Thanks !

2/5/2025 GA 66

You might also like