Sie sind auf Seite 1von 11

Department of Computer science

University of Peshawar
Introduction to Genetic Algorithms
(III)

Advanced Algorithms
Adv Algo: Spring 2008

GA: Example f(x) = x2


Problem: Maximize the function f(x) = x2 where x varies
between 1 and 31.
Step-1: Code the decision variables of the problem as
some finite length string.
Code it as a binary unsigned integer of length 5.
To start we select an initial population of size 4 by
tossing a fair coin 20 times.
Fitness or objective function is calculated by squaring
x value.
Adv Algo: Spring 2008

GA: Example f(x) = x2


String no Initial pop

x value

f(x) = x2

011012

13

169

110002

24

576

010002

64

100112

19

361

The GA need not know the semantics of the coding or


that of the objective function

Adv Algo: Spring 2008

GA: Example f(x) = x2


Step-2: Reproduction (copying).
Strings for creating next generation are selected
by spinning the weighted roulette wheel 4 times.

30.9%

5.5%

14.4%

49.2%

Adv Algo: Spring 2008

GA: Example f(x) = x2


f(x) = x2

pselect
fi/f

Expected count
fi/avg

Actual count
(Roulette wheel)

1 13

169

0.14

0.58

2 24

576

0.49

1.97

3 08

64

0.06

0.22

4 19

361

0.31

1.23

Sum

1170

1.00

4.00

4.0

Avg

293

0.25

1.00

1.0

Max

576

0.49

1.97

2.0

Adv Algo: Spring 2008

GA: Example f(x) = x2


Actual count was generated using coin tosses.
Note the similarity with pselect, we obtained what we
expected.
The best strings get more copies, while the weak ones
just die off.
After selection, crossover takes place in two steps
(i) strings combined randomly using coin tosses
(ii) selection of crossing sites using coin tosses.

Adv Algo: Spring 2008

GA: Example f(x) = x2


String Crossover Mating pool after
no
site
selection

mate

Mate coded

1 13

0110|1

1100|0

2 24

1100|0

0110|1

2 24

11|000

10|011

4 19

10|011

11|000

Adv Algo: Spring 2008

GA: Example f(x) = x2


Mating pool after
selection

Mate coded

New population

x value

f(x) x2

1 13

0110|1

2 24

1100|0

01100

12

144

2 24

1100|0

1 13

0110|1

11001

25

625

2 24

11|000

4 19

10|011

11011

27

729

10|011

3 08

01|000

10000

16

256

4 19

Adv Algo: Spring 2008

GA: Example f(x) = x2

Adv Algo: Spring 2008

GA: Limitations & Weaknesses


The idea behind GA is extremely appealing, but just don't
seem to work on practical combinatorial optimization
problems like SA does for the following reasons:
It is quite unnatural to model most applications in terms of
genetic operators like mutation and crossover on bit strings.
The pseudo biology adds another level of complexity between
you and your problem.
The process of selection alone is too systematic and
predictable, not like creativity as we know it.
Binary representations are limited in their operations.
Adv Algo: Spring 2008

10

GA: Limitations & Weaknesses


The cross over and mutations make no use of real problem
structure, so large fractions of transitions lead to inferior
solutions, and convergence is slow.
GAs take a very long time on non-trivial problems because of
more objective function evaluations as compared to classical
optimization techniques. This being a major practical
limitation.
Analogy with evolution is appropriate, but it took millions of
years to achieve significant improvement.
Can we afford to wait that long?
Adv Algo: Spring 2008

11

Das könnte Ihnen auch gefallen