Вы находитесь на странице: 1из 27

Genetic Algorithms

Asst Lec. Muhannad A. Muhammed

1 / 76
Summary Slide

Agenda
Part I
What is a genetic algorithm?
Principles of genetic algorithms.

Part II
Applications
Procedure
Conclusions

2 / 76
Part I: GA Theory

What are genetic algorithms?


How to design a genetic algorithm?
Genetic Algorithm Is...
It is biologically inspired
Simulate the survival of the fittest to give how fit is the individual

4 / 76
GA Concept

Genetic algorithm (GA) introduces the principle of evolution


and genetics into search among possible solutions
to given problem.
The idea is to simulate the process in natural systems.
This is done by the creation within a machine
of a population of individuals represented by chromosomes,
in essence a set of character strings, that are analogous to the
DNA, that we have in our own chromosomes.

Hello World Individuals


Hello chromosome

H,e,l,l,o DNA

5 / 76
Instead of Introduction...
Hill climbing

global

local

6 / 76
Instead of Introduction(2)
Multi-climbers

7 / 76
Instead of Introduction(3)
Genetic algorithm

I am at the
I am not at the top. top
My high is better! Height is ...

I will continue

8 / 76
Instead of Introduction(3)
Genetic algorithm - few microseconds after

9 / 76
Survival of the Fittest
The main principle of evolution used in GA
is survival of the fittest.
The good solution survive, while bad ones die.

10 / 76
Algorithmic Phases
Initialize the population

Select individuals for the mating pool

Perform crossover

Perform mutation

Insert offspring into the population

no
Stop?

yes

The End

11 / 76
Designing GA...
How to represent genomes?
How to define the crossover operator?
How to define the mutation operator?
How to define fitness function?
How to generate next generation?
How to define stopping criteria?

12 / 76
Crossover
Crossover is concept from genetics.
Crossover combines genetic material from two parents,
in order to produce superior offspring.
Few types of crossover:
One-point
Multiple point.

13 / 76
One-point Crossover

0 7
1 6
2 5
3 4
4 3
5 2
6 1
7 0

Parent #2
Parent #1 14 / 76
One-point Crossover

0 7
1 6
5 2
3 4
4 3
5 2
6 1
7 0

Parent #2
Parent #1 15 / 76
Problems With Gas
Sometimes GA is extremely slow,
and much slower than usual algorithms

16 / 76
Advantages of Gas
Concept is easy to understand.
Minimum human involvement.
Computer is not learned how to use existing solution,
but to find new solution!
Supports multi-objective optimization
Always an answer; answer gets better with time !!!
Inherently parallel; easily distributed
Many ways to speed up and improve a GA-based application as
knowledge about problem domain is gained

17 / 76
Some Applications of Gas
Control systems design Software guided circuit design

Optimization

Internet search search GA Path finding Mobile robots

Data mining Trend spotting

Stock prize prediction


18 / 76
Genetic Algorithms
Nature has an ability to adapt and learn without being told what
to do. In other words, nature finds good chromosomes blindly.
GAs do the same. Two mechanisms link a GA to the problem it
is solving: encoding and evaluation.
The GA uses a measure of fitness of individual chromosomes to
carry out reproduction. As reproduction takes place, the
crossover operator
exchanges parts of two single chromosomes, and the mutation
operator changes the gene value in some randomly chosen
location of the chromosome.

19 / 76
Basic genetic algorithms
Step 1: Represent the problem variable domain as a
chromosome of a fixed length, choose the size of a
chromosome population N, the crossover probability pc
and the mutation probability pm.
Step 2: Define a fitness function to measure the
performance, or fitness, of an individual chromosome in
the problem domain. The fitness function establishes
the basis for selecting chromosomes that will be mated
during reproduction.

20 / 76
Basic genetic algorithms
Step 3: Randomly generate an initial population of
chromosomes of size N:
x1, x2 , . . . , xN
Step 4: Calculate the fitness of each individual
chromosome:
f (x1), f (x2), . . . , f (xN)
Step 5: Select a pair of chromosomes for mating
from the current population. Parent chromosomes are
selected with a probability related to their fitness.

21 / 76
Basic genetic algorithms
Step 6: Create a pair of offspring chromosomes by
applying the genetic operators - crossover and
mutation.
Step 7: Place the created offspring chromosomes
in the new population.
Step 8: Repeat Step 5 until the size of the new
chromosome population becomes equal to the
size of the initial population, N.
Step 9: Replace the initial (parent) chromosome
population with the new (offspring) population.
Step 10: Go to Step 4, and repeat the process until
the termination criterion is satisfied.
22 / 76
Example: Maximizing a
Function of One Variable
This example adapts the method of an example presented in
Goldberg's book [1]. Consider the problem of maximizing the
function

where x is allowed to vary between 0 and 31.


we will encode x as a binary integer of length 5.
we select an initial population of 10 chromosomes at random. We can
achieve this by tossing a fair coin 5 times for each chromosome, letting
heads signify 1 and tails signify 0.

23 / 76
Example: Maximizing a
Function of One Variable

24 / 76
Example: Maximizing a
Function of One Variable
We select the chromosomes that will reproduce based on their tness
values, using the following probability:

25 / 76
Example: Maximizing a
Function of One Variable

26 / 76
Example: Maximizing a
Function of One Variable
For this example, we let the probability of mutation be 0.001.
After selection, crossover, and mutation are complete, the new
population is tested with the fitness function.

[1] Goldberg, D. E. (1989). Genetic Algorithms in Search, Optimization,


and Machine Learning. Reading: Addison-Wesley.

27 / 76

Вам также может понравиться