0% found this document useful (0 votes)
31 views29 pages

Bio-Inspired Computing - GA

Evolutionary algorithms are inspired by natural selection and genetics. They mimic the Darwinian evolution of species by applying genetic operators like selection, crossover and mutation to populations of individuals over multiple generations. The fittest individuals are more likely to survive and pass their traits to the next generation, allowing the population to evolve toward better solutions to optimization problems.

Uploaded by

Maroua Allaoui
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)
31 views29 pages

Bio-Inspired Computing - GA

Evolutionary algorithms are inspired by natural selection and genetics. They mimic the Darwinian evolution of species by applying genetic operators like selection, crossover and mutation to populations of individuals over multiple generations. The fittest individuals are more likely to survive and pass their traits to the next generation, allowing the population to evolve toward better solutions to optimization problems.

Uploaded by

Maroua Allaoui
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/ 29

Bio-inspired

computing 2
Evolutionary Algorithms:
Dr. Yassine Drias
Genetic Algorithms
Natural Selection

• Living organisms are fighting the forces of nature to


survive. Those who are the fittest (i.e. strongest, fastest,
biggest) are more likely to survive.
Charles Darwin

• Those who survive (the fittest) mate and reproduce (selection).


• Children are similar (inheritance), but not exactly like the parents
because of cross–fertilization and mutation. Thus, children can be
either less or more fit than their parents.
• Children repeat the path of their parents. After several generations
the organisms become much fitter than at the beginning.
Bio-inspired computing, Y. Drias 2
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.

Evolution = natural selection of inheritable variations

Bio-inspired computing, Y. Drias 3


Inheritance of Characteristics

• Gregor Mendel (1822-1884)


investigated the inheritance
of characteristics (“traits”).

• He conducted extensive
experiments with pea plants
and examined hybrids from
different strains of plant.

Character (gene) for tallness is dominant


Character (gene) for shortness is recessive
Bio-inspired computing, Y. Drias 4
Evolution-inspired Algorithms

• Natural Selection is a very successful organizing principle for


optimizing individuals and populations of individuals.

• If we can mimic natural selection, then we will be able to optimize


more successfully.

• A possible design of a system can be considered as an individual who


is fighting for survival within a larger population.

• Only the fittest survive.


§ Fitness is assessed via objective function f.

5
Bio-inspired computing, Y. Drias
Evolutionary Algorithms

• Evolutionary Algorithms are not just Genetic Algorithm.


§ Evolutionary Algorithms try to mimic the Darwinian evolution.
§ Evolutionary Algorithms are significantly different from Tabu Search, Local
Search and Simulated Annealing and thus complements these.
§ Evolutionary Algorithms are more difficult to use :
• Many parameters,
• Parameters are hidden and depends non-linearly on each other.

Bio-inspired computing, Y. Drias 6


Genetic Algorithms History

• Invented independently in the 60’ in three different places:


§ Michigan: John Holland, Genetic Algorithms.
§ Germany: Schwefel and Rechenberg, Evolution Strategies.
§ California: Edward Fogel, Evolutionary Programming.

• First dedicated conference: ICGA-85.

• Popularized by David Goldberg, 1989 (Genetic Algorithms).

Bio-inspired computing, Y. Drias 7


The Standard GA

Initialize the entire population (initialization)


Repeat
Select promising individuals from current population (selection)
Reproduce selected individuals (crossover)
Mutate reproduced individuals (mutation)
Evaluate created individuals (evaluation)
Create new/updated population (insertion)
Until stopping criteria
Return best from population
Bio-inspired computing, Y. Drias 8
GA Terminology
chromosome

individuals population
gene

selection
crossover
insertion
mutation

genetic operators

Generation Generation +1
9
Bio-inspired computing, Y. Drias
Application of GA to different problems

• GA is a very sophisticated parallel search algorithm that uses a special


representation of solutions (encoding), a mixture of stochastic
(random mutation) and deterministic (crosover and inheritance)
variations of solutions.

• When applying Genetic Algorithms (Evolutionary Algorithms in


general) to a certain problem we need to pay particular attention to :
§ The problem dependent parts : solution encoding, operators implementation,
fitness function, etc.
§ The algorithm’s parameters : size of the population, number of generations,
etc.
Bio-inspired computing, Y. Drias 10
Building a Population

• 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 biggest challenge in Genetic Algorithms is to represent each


individual by its genes, as a first step before starting the algorithm.
§ Identify the simplest elements (building blocks) of which a solution may
consist, and assign a letter (or a number) to each element.
• Each letter is called a gene.

§ 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.

§ This way a solution xi is represented by a string of genes.


• This string is called a chromosome of an individual.
Bio-inspired computing, Y. Drias 12
Chromosomes
chromosome

gene
alleles
1 0 0 1 0 1 1 0 1 … 0 1

1 1 0 0 0 0 1 0 0 … 0 0

• Each chromosome represents a solution, often using strings of 0’s and


1’s.
§ Each bit typically corresponds to a gene. This is called binary encoding.
§ Alleles are two genes of a pair of chromosomes, forming a pair themselves,
having identical locations on each of these two chromosomes.

13
Bio-inspired computing, Y. Drias
TSP example

• For the Travelling Salesman Problem the genes may represent


different cities, and the chromosomes represent different routes:

M: Moscow Moscow Xi’an Moscow Xi’an

D: Damascus
S: Samarkand Damascus Samarkand Damascus Samarkand

X: Xi’an

x1 = MDSXM x2 = MDXSM

Bio-inspired computing, Y. Drias 14


Selection

• After the fitness of the individuals of the whole population has been
calculated, some of them are selected for reproduction.

• There are several strategies for selection.


§ For example a roulette wheel selection, when individuals are selected
randomly with probability proportional to their fitness.
§ Ranked selection is when we select only the few fittest individuals.

• 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.

Bio-inspired computing, Y. Drias 15


Fitness Function

• The fitness function is needed


to compare different solutions
(individuals) and choose the
better ones.
§ It returns a number such that if
f(x1) > f(x2), then x1 is preferable
to x2 (x1 is ‘fitter’).

• Choosing the right fitness


function is very important, but
also quite difficult.

Bio-inspired computing, Y. Drias 16


Crossover

• The selected individuals (parents) are grouped in pairs in order to


produce their offspring (children).

• Crossover is an operation of replacing some genes in one parent by


the corresponding genes of the other. Thus, each child becomes an
offspring of two parents.

• There are many ways to do the crossover, such as single–point


crossover, two-point crossover, k-point crossover, uniform crossover,
etc.

17
Bio-inspired computing, Y. Drias
Single–point crossover Example

• For example, let’s consider a single–point crossover at point 3:

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

Bio-inspired computing, Y. Drias 18


Mutation

• A randomly chosen gene (or several genes) is changed to some other


gene (mutate).
§ Mutation helps to add diversity to the population. It works as a random
experimentation.
§ Mutation can help the population to avoid local optimum.
§ The process of mutation may occur at variable rate.
§ Some problems cannot be solved at all without mutation.

• Exactly like the neighborhood !

Bio-inspired computing, Y. Drias 19


Mutation example

• For example, mutation of genes 3 and 5 in the offspring O1 will give:

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

Bio-inspired computing, Y. Drias 20


Stopping Criteria

• The stopping criteria of Genetic Algorithms is important in


determining when a GA run will end.
§ We want a termination condition such that the solution is close to the
optimal, at the end of the run.

• Usually, we keep one of the following termination conditions :


§ When the objective function value has reached a certain pre-defined value.
§ X number of generations completed, typically O(100).
§ When there has been no improvement in the population for X iterations.

Bio-inspired computing, Y. Drias 21


Genetic Algorithms pseudocode
Input: Populationsize, Problemsize, Pcrossover, Pmutation
Output: SGbest
Population := InitializePopulation(Populationsize, Problemsize )
EvaluatePopulation(Population)
SGbest := GetBestSolution(Population)
While (not StopCondition())
Parents := SelectParents(Population, Populationsize)
Children := {Æ}
For (Parent1, Parent2 ϵ Parents)
Child1 := Crossover(Parent1, Parent2, Pcrossover)
Child2 := Crossover(Parent2, Parent1, Pcrossover)
Children := Mutate(Child1, Pmutation)
Children := Mutate(Child2, Pmutation)
End
EvaluatePopulation(Children)
Sbest := GetBestSolution(Children)
if (Sbest > SGbest ) then Sgbest := Sbest
Population := Replace(Population, Children)
End
Return (SGbest)
22
Bio-inspired computing, Y. Drias
Summary of Genetic Algorithms

• 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.

• The first steps to perform when applying Genetic Algorithms to a new


problem are :
§ Find an optimal solution encoding.
§ Define the appropriate fitness function.

Bio-inspired computing, Y. Drias 23


Why Genetic Algorithms Work?

• In each generation, several solutions are checked at once. Thus,


Genetic Algorithm is a kind of a parallel search.

• Fitness and selection filter out bad solutions from good ones.

• Offspring inherit properties of mostly good solutions.

Bio-inspired computing, Y. Drias 24


Variations in Genetic Algorithms

• Different selection strategies: roulette wheel, ranked, tournament


selection.
• Different forms of the crossover operator: two–point, uniform, etc.
• Static or variable population size.
• Variable mutation rates.
• Some “good” parts of the chromosomes may be kept intact. They are
usually called schemas.
• Some very good individuals may survive for several generations
(elitism).
Bio-inspired computing, Y. Drias 25
Convergence

• Premature convergence is a common problem found in genetic


algorithms.
• Premature convergence means
that a population for an
optimization problem converged
too early, resulting in being
suboptimal.
• In this context, the parental
solutions, through the help of
genetic operators, are not able
to generate offspring that are
superior to, or outperform, their
parents.
26
Bio-inspired computing, Y. Drias
Parallel implementations

• Parallel implementations of genetic algorithms come in two flavors :


§ Coarse-grained parallel genetic algorithms assume a population on each of
the computer nodes and migration of individuals among the nodes.
§ Fine-grained parallel genetic algorithms assume an individual on each
processor node which acts with neighboring individuals for selection and
reproduction.

• Other variants, like genetic algorithms for online optimization


problems, introduce time-dependence or noise in the fitness
function.

Bio-inspired computing, Y. Drias 27


Application of Genetic Algorithms

• GA are easily programmable and can be applied to a wide range of


problems such as :
§ Transport scheduling.
§ Timetabling.
§ Circuit design.
§ Route optimization (TSP)

• 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

• In general, Evolutionary Algorithms should be considered when :


§ The problem is REALLY hard:
• If the problem is very multimodal.
• If the problem is a multi criteria problem.
• If the standard neighborhood is bad.

§ If there is a good reproduction operator.


§ If the problem is multi-objective.

Bio-inspired computing, Y. Drias 29

You might also like