Sei sulla pagina 1di 31

Genetic Algorithm

Presented by:
Gaurav Khandelwal
08BCE131
Overview
• General introduction to Genetic Algorithms (GA’s)
• Biological background
• Cell
• Chromosomes
• Origin of species
• Natural selection
• Genetic Algorithm
• Search space
• Basic algorithm
• Coding
• Examples
General Introduction to GA’s

• Genetic algorithms (GA’s) are technique to solve problems


which need optimization
• GA’s are a subclass of Evolutionary Computing
• GA’s are based on Darwin’s theory of evolution
• History of GA’s
• Evolutionary computing evolved in the 1960’s.
• GA’s were created by John Holland in the mid-70’s.

Biological Background(Cell)
• Every animal 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(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(Genetics)
• The entire combination of genes is called genotype
• A genotype develops to a phenotype
• Alleles can be either dominant or recessive
• Dominant alleleswill always express from the genotype
to the fenotype
• Recessive alleles can survive in the population for many
generations, without being expressed.

Biological Background(Reproduction)
• Reproduction of genetical information
• Mitosis
• Meiosis
• Mitosisis copying the same genetic information to new
offspring: there is no exchange of information
• Meiosis is the basis of the sexual reproduction
• During reproduction “errors ” occur
• Due to these “errors” genetic variation exists
• Most important “errors” are:
 Recombination(cross-over)

 mutation
Biological background(Natural-selection)
• The origin of species: “Preservation of favourable
variations and rejection of unfavourable 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.
• Important aspects in natural selection are:
• adaptation to the environment
• isolation of populations in different groups which cannot
mutually mate


Genetic Algorithms
 Genetics + Algorithm = Genetic Algorithm

 Genetic Algorithm is robust and probabilistic search algorithm


based on the mechanics of natural selection and genetics

 Genetic Algorithm follows the principle of “Survival of the


Fittest” laid down by Charles Darwin

 Random search method



Genetic Algorithm-Search space
• Most often one is looking for the best solution in a specific
subset of solutions
• This subset is called the search space (or state space)
• Every point in the search space is a possible solution
• Therefore every point has a fitness value, depending on
the problem definition
• GA’s are used to search the search space for the best
solution, e.g. a minimum

Genetic algorithm-Basic algorithm
• Starting with a subset of n randomly chosen solutions
from the 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-Basis algorithm
• Outline of basis algorithm

 START : Create random population of n chromosomes

 1 FITNESS : Evaluate fitness f(x) of each chromosome in the population

 2 NEW POPULATION

 0 SELECTION : Based on f(x)


 1 RECOMBINATION : Cross-over chromosomes
 2 MUTATION : Mutate chromosomes
 3 ACCEPTATION : Reject or accept new one
 3 REPLACE : Replace old with new population: the new

 generation
 4 TEST : Test problem criterium
 5 LOOP : Continue step 1 – 4 until criterium is satisfied
Genetic Algorithm-Coding
• Chromosomes are encoded by bitstrings
• Every bitstring therefore is a solution but not necisseraly
the best solution
• The way bitstrings can code differs from problem to
problem

0
1
0
1
1
Genetic Algorithm-Coding
 Recombination (cross-over) can when using bitstrings
schematically be represented:
 1 0
1 0
 0 1 0 1
 0 0 0 0
 1 1 1 1
X 1
 1 1 1
 0 1 1 0

 1 0 0 1

 Using a specific cross-over point


Genetic Algorithm-Coding
• Mutation prevents the algorithm to be trapped in a local
minimum
• In the bitstring approach mutation is simpy the flipping of
one of the bits

0 0
1 0
0 0
1 1
0 0
1 1
Genetic Algorithm-Coding
• Both recombination and mutation depend a lot on the
exact definition of the problem and the choice of
representing the chromosomes (e.g. no bitstrings)
• Different encodings can be used:
• Binary encoding
• Permutation encoding
• Value encoding
• Tree encoding
• Focus in this presentation stays with binary encoding
Example
 We require small finger and long feet.
 Gene are encoded as first two gene represent finger
characteristic and other two represent feet characteristic.
 We have population size four.
 Here 0 represent small and 1 represent long
 Ideal gene:

0 0 1 1
0 1 0 0 1 0 0 0
A B

0 1 0 1 0 0 1 0
C D
Example
Now fitness:

Name Fitness

A 1
 B 1
 C 2
 D 3
We apply crossover and mutation for optimum
sol.

Example

 Crossover:

Name Received Genome Fitness


A’ gene
A(0,1)+D(1,0 A’(0,1,1,0) 2
B’ )
B(1,0)+D(1,0 B’(1,0,1,0) 2
C’ )D(0,0)+C(0,1 C’(0,0,0,1) 3
D’ )D D’(0,0,1,0) 3
Example

 Mutation:

Name Gene Genome Fitness


A’ A’(0,1,1,0) A’’(0,0,1,0) 3
B’ B’(1,0,1,0) B’’(1,0,1,1) 3
C’ C’(0,0,0,1) C’’(0,0,1,1) 4
D’ D’(0,0,1,0) D’’(0,0,1,0) 3
Example(Travel salesman problem)
 Find a tour of a given set of cities so that
• each city is visited only once
• the total distance traveled is minimized


Representation
 Representation is an ordered list of city numbers known as an
order-based GA.
• 1) London 3) Dunedin 5) Beijing 7) Tokyo
• 2) Venice 4) Singapore 6) Phoenix 8) Victoria
• CityList1 (3 5 7 2 1 6 4 8)
• CityList2 (2 5 7 6 8 1 3 4)

Example(Travel salesman problem)


Crossover
•Crossover combines inversion and recombination:
• Parent1 (1 2 3 4 5 6 7 8 9)
• Parent2 (9 3 7 8 2 6 5 1 4)

• Child (9 3 2 4 5 6 7 1 8)

This operator is called the partial crossover.



Example(Travel salesman problem)

 Mutation
 Mutation involves reordering of the list:

* *
• Before: (9 3 2 4 5 6 7 1 8)

• After: (9 3 2 7 5 6 4 1 8)
TSP Example: 30 cities

120

100

80

y 60

40

20

0
0 10 20 30 40 50 60 70 80 90 100
x
TSP Example: 30 cities
Solution (Distance = 941)

TSP30 (Performance = 941)

120

100

80
y

60

40

20

0
0 10 20 30 40 50 60 70 80 90 100
x
TSP Example: 30 cities
Solution (Distance = 652)
TSP30 (Performance = 652)

120

100

80

y 60

40

20

0
0 10 20 30 40 50 60 70 80 90 100
x
TSP Example: 30 cities
Best solution(Distance = 420)

TSP30 Solution (Performance = 420)

120

100

80

y 60

40

20

0
0 10 20 30 40 50 60 70 80 90 100
x
Advantages of Genetic algorithms
 Concept is easy to understand

 Supports multi-objective optimization


 Good for “noisy” environments


 Answer gets better with time


 Inherently parallel; easily distributed



Disadvantage of Genetic algorithm
 Genetic algorithm applications in controls which are
• performed in real time are limited because of random
• solutions and convergence.

 Certain optimisation problems (they are called variant


• problems) cannot be solved by means of genetic algorithms.
This occurs due to poorly known fitness functions

Application of GA
 Management Applications
 Scheduling
 Control
 VLSI Design
 Identification & Pattern recognition

Thank you