Bio-Inspired Computing - GA
Bio-Inspired Computing - GA
computing 2
Evolutionary Algorithms:
Dr. Yassine Drias
Genetic Algorithms
Natural Selection
• Observations :
§ Species are continually developing.
§ Variations between species are enormous.
§ Huge potential for production of offspring, but only a small/moderate
percentage survives to adulthood.
• He conducted extensive
experiments with pea plants
and examined hybrids from
different strains of plant.
5
Bio-inspired computing, Y. Drias
Evolutionary Algorithms
individuals population
gene
selection
crossover
insertion
mutation
genetic operators
Generation Generation +1
9
Bio-inspired computing, Y. Drias
Application of GA to different problems
• Suppose that there are many possible solutions for the problem: x1, x2, ...,
xn.
§ The main idea of Genetic Algorithms is to view each solution xi of the problem
as an individual living organism.
• The number of all possible solutions for the problem can be incredibly large
(more than atoms in the universe). So, we consider only a relatively small
number m of them.
§ We call a collection of m solutions at the current time moment a population
P(t) = {𝑥!" , 𝑥#", …, 𝑥$
" }
• With time the individuals (like organisms) and the whole population will be
evolving. So, time t here simply describes the generation of the population
and its individuals. Bio-inspired computing, Y. Drias 11
Encoding Genes of an Individual
§ The number of these simplest elements (and hence the genes) is finite and
not very large. For example, in DNA there are only four kinds of genes: A, G, T
and C.
• The collection of all these letters is called an alphabet of the algorithm.
gene
alleles
1 0 0 1 0 1 1 0 1 … 0 1
1 1 0 0 0 0 1 0 0 … 0 0
13
Bio-inspired computing, Y. Drias
TSP example
D: Damascus
S: Samarkand Damascus Samarkand Damascus Samarkand
X: Xi’an
x1 = MDSXM x2 = MDXSM
• After the fitness of the individuals of the whole population has been
calculated, some of them are selected for reproduction.
• If the size of the population remains the same in all generations, then
not all individuals will be allowed to reproduce. This is because
usually the fitter reproduce more.
17
Bio-inspired computing, Y. Drias
Single–point crossover Example
1 2 3 4 5 6 7 1 2 3 4 5 6 7
P1 1 0 1 0 1 0 0 O1 1 0 1 1 0 0 1
1 2 3 4 5 6 7 1 2 3 4 5 6 7
P2 0 1 1 1 0 0 1 O2 0 1 1 0 1 0 0
1 2 3 4 5 6 7
O1 1 0 1 1 0 0 1
1 2 3 4 5 6 7
O1 1 0 0 1 1 0 1
• After the crossover and mutation operations the new generation may
have individuals which are even fitter than their parents (i.e. better
solutions of the problem).
§ The process is repeated for several generations until a good enough solution
is found.
• Fitness and selection filter out bad solutions from good ones.
• For some classes of problems there are other specific methods that
can perform better than GA. However, when no special method is
known for your problem, then try GA and see if it can give you a good
result.
Bio-inspired computing, Y. Drias 28
When to use Evolutionary Algorithms