GENETIC
ALGORITHM
General Introduction to GAs
Genetic algorithms (GAs) are a technique to solve
problems which need optimization.
GAs are a subclass of Evolutionary Computing and
are random search algorithms.
GAs are based on Darwin’s theory of evolution.
History of GAs:
• Evolutionary computing evolved in the 1960s.
• GAs were created by John Holland in the mid-1970s.
Biological Background (1) – The
Cell
Every cell is a complex of many small
“factories”
working together.
The center of this all is the cell nucleus.
The nucleus contains the genetic
information.
Biological Background (2) – Chromosomes
Genetic information is stored in the chromosomes.
Each chromosome is build of DNA.
Chromosomes in humans form pairs.
There are 23 pairs.
The chromosome is divided in parts: genes
.
Genes code for properties.
The posibilities of the genes for one property is called:
allele.
Every gene has an unique position on the
chromosome: locus.
Biological Background (3) – Genetics
The entire combination of genes is called genotype.
A genotype develops into a phenotype.
Alleles can be either dominant or recessive.
Dominant alleles will always expressfrom the genotype
to the fenotype.
Recessive alleles can survive in the population for
many generations without being expressed.
Biological Background (4) – Reproduction
Reproduction of
genetical information:
• Mitosis,
• Meiosis.
Mitosis is the
copying genetic same
to
information
exchange of information.
offspring: there new
Mitosis is the is normal
way of growing no of
multicell structures, like
organs.
Biological Background (5) – Reproduction
Meiosis is the basis of
sexual reproduction.
After meiotic division 2
gametes
appear in the process.
In reproduction two
gametes conjugate to a
zygote wich will become the
new
Hencindividual.
genetic
e information is
share tobetween
order create new the
offspring.
d parents in
Biological Background (6) – Natural
Selection
The origin of species: “Preservation of favorable
variations and rejection of unfavorable variations.”
There are more individuals born than can
survive, so there is a continuous struggle
for life.
Individuals with an advantage have a greater chance for
survive:
survival of the fittest. For example, Giraffes with long
necks.
Genetic variations due to crossover and mutation.
Comparison of Natural and GA Terminology
Natural Genetic Algorithm
Chromosome String
Gene Feature or character
Allele Feature value
Locus String position
Genotype Structure
Phenotype Parameter set, a decoded structure
PRINCIPLE OF NATURAL
SELECTION
🞭 “Select The Best, Discard The Rest”
🞭 Two important elements required for any problem before a
genetic algorithm can be used for a solution are:
🞭 Method for representing a solution
(encoding) ex: string of bits, numbers,
character
🞭 Method for measuring the quality of any proposed solution,
using fitness function
ex: Determining total weight
GA ELEMENTS
GA OPERATORS
BASIC GA
OPERATORS
Selection – To select set of chromosomes
Crossover - Looking for solutions near
existing solutions
Mutation - Looking at completely new areas
of search space
FITNESS FUNCTION
🞭 quantifies the optimality of a solution (that is, a
chromosome): that particular chromosome may
be ranked against all the other chromosomes
🞭 A fitness value is assigned to each solution
depending on how close it actually is to solving
the problem.
Genetic Algorithm (1) – Search
Space
Most often one is looking for
the best solution in a
specific subset of solutions. 2.5
This subset is called the
search space (or state 2
space). 1.5
Every point in the search
space is a possible
Therefore everysolution.
point 1
has a
fitness value, depending 0.5
on the problem
definition. 0
0
1000
100 200 300 400 500 600 700 800 900
GAs are used to search the
search space for the best
minimum.
solution, e.g.are
Difficulties a the local
minima and the starting
point of the search.
GeneticAlgorithm (2) – Basic
concept
Starting with a subsetof n randomly chosen
solutions fromthe search space (i.e. chromosomes).
This is the population.
This population is used to produce a next
generation of individuals by reproduction.
Individuals with a higher fitness have more chance to
reproduce (i.e. natural selection).
Genetic Algorithm (3) – Basic
Algorithm
Outline of the basic algorithm
1 START : Create random population of n chromosomes
2 FITNESS : Evaluatefitness f(x) of each chromosome
in
population the
2 NEW
POPULATION : Based on
1 CROSS OVERf(x)
2 : Cross-over chromosomes
SELECTION
3 MUTATION : Mutate chromosomes
3 REPLACE : Replace old with new population: the new
generation
4 TEST : Test problem criterium
5 LOO : Continue step 1 – 4 untill criterium is
P satisfied
GeneticAlgorithm – Reproduction
Cycle
1. Select parents for the mating pool
(size of mating pool = population
size).
2. Shuffle the mating pool.
3. For each consecutive pair apply
crossover.
4. For each offspring apply mutation (bit-flip independently
for each bit).
5. Replace the whole population with the resulting offspring.
ENCODING
🞭 The process of representing the solution in
the form of a string that conveys the
necessary information.
🞭 Just as in a chromosome, each gene controls a
particular characteristic of the individual,
similarly, each element in the string represents a
characteristic of the solution.
ENCODING
METHODS
🞭 Binary Encoding – Most common method of encoding.
Chromosomes are strings of 1s and 0s and each position in the
chromosome represents a particular characteristic of the problem.
Chromosome A 1011001011001110010
Chromosome B 1111111000000001111
1
🞭 Permutation Encoding – Useful in ordering problems such as the
Traveling Salesman Problem (TSP). Example. In TSP, every
chromosome is a string of numbers, each of which represents
a city to be visited.
Chromosome A 1 5 3 2 6 4 7 9 8
Chromosome B 8 5 6 7 2 3 1 4 9
ENCODING METHODS (CONTD.)
🞭 Value Encoding – Used in problems where
complicated values, such as real numbers, are used and where
binary encoding would not suffice.
Good for some problems, but often necessary to develop some specific crossover and
mutation techniques for these chromosomes.
Chromosome A 1.235 5.323 0.454 2.321 2.454
Chromosome B (left), (back), (left), (right),
(forward)
ENCODING METHODS (CONTD.)
This encoding is used mainly for evolving programs or expressions,
i.e. for Genetic programming. Every chromosome is a tree
of some objects, such as values/arithmetic operators or
commands in a programming language.
( do_until step
(+ x (/ wall )
5 y)
)
SELECTION TECHNIQUES
Roulette Selection
Rank Selection
Steady State Selection
Tournament Selection
But most important Technique is Routette Selection
ROULETTE WHEEL SELECTION
Main idea: the fitter is the solution with the
most chances to be chosen
HOW IT WORKS ?
ROULETTE WHEEL SELECTION
Chromosome
1
Chromosome
2
Chromosome
3
Chromosome
4
All you have to do is spin the ball and grab the chromosome at the point it stops
HOW TO SIMULATE ROULETTE
WHEEL SELECTION SCHEME ?
Suppose there are 10 chromosomes...
Evaluate the fitness function of all the
chromosomes
Arrange the chromosomes in the descending
order of their fitness values…(If u r going to
maximize the objective function).
Let say Pc = 0.8. Then select the best 8
chromosomes from the entire population.
That means select the first 8 chromosomes.
Now these chromosomes will be paired up
randomly and then they will crossover.
CROSSOVER
Main idea: combine genetic material ( bits ) of 2
“parent” chromosomes ( solutions ) and produce a new
“child” possessing characteristics of both “parents”.
How it works ?
Several methods ….
Genetic Algorithm – Crossover (Single
Point)
Choose a random point on the two
parents.
Split parents at this crossover point.
Create children by exchanging tails.
CONT INUE…
Single Point Crossover- A random point is
chosen on the individual chromosomes
(strings) and the genetic material is exchanged
at this point.
TWO POINT
CROSSOVER
Two-Point Crossover- Two random points are chosen on the
individual chromosomes (strings) and the genetic material
is exchanged at these points.
Chromosome1 11011 | 00100 |
110110
Chromosome 2 10101 | 11000 |
011110
Offspring 1 10101 | 00100 |
011110
Offspring 2 11011 | 11000 |
110110
N- Point Crossover
Choose n random crossover points.
Split along those points.
Glue parts, alternating between
parents.
Generalization of 1 point.
UNIFORM CROSSOVER
METHODS
Each gene (bit) is selected randomly
from one of the corresponding genes of the parent
chromosomes
Chromosome1 11011 | 00100 | 110110
Chromosome 2 10101 | 11000 | 011110
Offspring 10111 | 00000 | 110110
NOTE: Uniform Crossover yields ONLY 1 offspring.
CROSSOVER (CONTD.)
Crossover between 2 good solutions MAY NOT
ALWAYS yield a better or as good a solution.
Since parents are good, probability of the child being
good is high.
If offspring is not good (poor solution), it will be
removed in the next iteration during “Selection”.
ELITISM
Main idea: copy the best chromosomes (solutions) to
new population before applying crossover and mutation
When creating a new population by crossover or
mutation the best chromosome might be lost.
Forces GAs to retain some number of the best individuals
at each generation.
Has been found that elitism significantly improves
performance.
MUTATION
Main idea: random inversion of bits in solution to
maintain diversity in population set
CONTINU
E…
🞭 Mutation
🞤 Generating new offspring from single parent
🞤 Maintaining the diversity of the individuals
🞫 Crossover can only explore the combinations of the
current gene pool
🞫 Mutation can “generate” new genes
MUTATION TECHNIQUES
🞭 Flipping :Flipping of bit involves changing
o to 1 and 1 to 0 based on mutation
chromosome generated randomly
🞭 Reversing: A random position is chosen
and bits next to that position are
reversed and child chromosome is
produced
🞭 Interchanging: Two random position
chromosome are chosen and of
corresponding
the to that position are bits
interchanged
APPLICATIONS OF GA
1. Function
Optimization
2. System
Identification
3. Channel
Equalization