Sie sind auf Seite 1von 49

Genetic Algorithms:

Soft Computing Week


13
Genetic Algorithms are
good at taking large,
potentially huge search
spaces and navigating
them, looking for optimal
combinations of things,
solutions you might not
otherwise find in a
lifetime.
- Salvatore Mangano
Computer Design, May 1995

Genetic Algorithms

The Genetic Algorithm

Directed search algorithms based on


the mechanics of biological evolution
Developed by John Holland, University
of Michigan (1970s)
To understand the adaptive processes of
natural systems
To design artificial systems software that
retains the robustness of natural systems

Genetic Algorithms

The Genetic Algorithm


(cont.)

Provide efficient, effective techniques


for optimization and machine learning
applications
Widely-used today in business,
scientific and engineering circles

Genetic Algorithms

Evolution in the real


world

Each cell of a living thing contains


chromosomes - strings of DNA
Each chromosome contains a set of genes blocks of DNA
Each gene determines some aspect of the
organism (like eye colour)
A collection of genes is sometimes called a
genotype

Genetic Algorithms

Evolution in the real


world

A collection of aspects (like eye colour)


is sometimes called a phenotype
Reproduction involves recombination of
genes from parents and then small
amounts of mutation (errors) in copying
The fitness of an organism is how
much it can reproduce before it dies
Evolution based on survival of the
fittest
5

Genetic Algorithms

Start with a Dream

Suppose you have a problem


You dont know how to solve it
What can you do?
Can you use a computer to somehow
find a solution for you?
This would be nice! Can it be done?

Genetic Algorithms

A dumb solution
A blind generate and test algorithm:
Repeat
Generate a random possible solution
Test the solution and see how good it is

Until solution is good enough

Genetic Algorithms

Can we use this dumb


idea?

Sometimes - yes:
if there are only a few possible solutions
and you have enough time
then such a method could be used

For most problems - no:


Too many possible solutions
No time to try them all
So this method can not be used

Genetic Algorithms

A less-dumb idea
(GA)
Generate a set of random solutions
Repeat
Test each solution in the set (rank them)
Remove some bad solutions from set
Duplicate some good solutions
make small changes to some of them

Until best solution is good enough


9

Genetic Algorithms

How do you encode a


solution?

Obviously this depends on the problem!


GAs often encode solutions as fixed length
bitstrings (e.g. 101110, 111111, 000101)
Each bit represents some aspect of the
proposed solution to the problem
For GAs to work, we need to be able to
test any string and get a score
indicating how good that solution is

10

Genetic Algorithms

Adding Sex - Crossover

Although it may work for simple search


spaces our algorithm is still very simple
It relies on random mutation to find a good
solution
It has been found that by introducing sex
into the algorithm better results are obtained
This is done by selecting two parents during
reproduction and combining their genes to
produce offspring

11

Genetic Algorithms

Adding Sex - Crossover

Two high scoring parent bit strings


(chromosomes) are selected and with some
probability (crossover rate) combined
Producing two new offspring (bit strings)
Each offspring may then be changed
randomly (mutation)

12

Genetic Algorithms

Selecting Parents

Many schemes are possible so long as better


scoring chromosomes more likely selected
Score is often termed the fitness
Roulette Wheel selection can be used

13

Genetic Algorithms

Example population
No.
1
2
3
4
5
6
7
8

Chromosome
1010011010
1111100001
1011001100
1010000000
0000010000
1001011111
0101010101
1011100111
14

Fitness
1
2
3
1
3
5
1
2
Genetic Algorithms

Roulette Wheel
Selection
1
1

3
2

4
3

6
3

7
5

Rnd[0..18]=7

Rnd[0..18]=12

Chromosome4

Chromosome6

Parent1

Parent2

15

8
2

18

Genetic Algorithms

Crossover Recombination
1011011111

1010000000

Parent1

Offspring1

1001011111

Parent2

Offspring2 1010000000

Crossover
singlepoint
random

Withsomehighprobability(crossover
rate)applycrossovertotheparents.

16

Genetic Algorithms

Mutation
Offspring1

1011011111

mutate

Offspring1

1011001111

Offspring2 1000000000

Offspring2 1010000000
Originaloffspring

Mutatedoffspring

Withsomesmallprobability(themutationrate)flip
eachbitintheoffspring(typicalvaluesbetween0.1
and0.001)
17

Genetic Algorithms

Back to the (GA)


Algorithm

Generate a population of random


chromosomes
Repeat (each generation)

Calculate fitness of each chromosome


Repeat
Use roulette selection to select pairs of parents
Generate offspring with crossover and mutation
Until a new population has been produced

Until best solution is good enough


18

Genetic Algorithms

Many Variants of GA

Different kinds of selection (not roulette)

Different recombination

Multi-point crossover
3 way crossover etc.

Different kinds of encoding other than bitstring

Tournament
Elitism, etc.

Integer values
Ordered set of symbols

Different kinds of mutation

19

Genetic Algorithms

Many parameters to set

Any GA implementation needs to decide on a


number of parameters: Population size (N),
mutation rate (m), crossover rate (c)
Often these have to be tuned based on
results obtained - no general theory to
deduce good values
Typical values might be: N = 50, m = 0.05, c =
0.9

20

Genetic Algorithms

Why does crossover


work?

A lot of theory about this and some


controversy
Holland introduced Schema theory
The idea is that crossover preserves good
bits from different parents, combining them
to produce better solutions
A good encoding scheme would therefore try
to preserve good bits during crossover and
mutation

21

Genetic Algorithms

Classes of Search
Techniques
S e a rc h te c h n iq u e s
C a lc u lu s - b a s e d t e c h n iq u e s
D ir e c t m e t h o d s
F in o n a c c i

G u id e d ra n d o m s e a rc h te c h n iq u e s

I n d ir e c t m e t h o d s
N e w to n

E v o lu tio n a ry a lg o rith m s

E v o lu t io n a r y s t r a t e g ie s

D y n a m ic p r o g r a m m in g

G e n e tic a lg o rith m s

P a ra lle l
C e n tra liz e d

S im u la t e d a n n e a lin g

E n u m e r a t iv e t e c h n iq u e s

D is trib u te d

22

S e q u e n tia l
S te a d y -s ta te

G e n e ra tio n a l

Genetic Algorithms

Components of a GA
A problem to solve, and ...
Encoding technique
(gene, chromosome)
Initialization procedure
(creation)
Evaluation function
(environment)
Selection of parents
(reproduction)
Genetic operators
(mutation, recombination)
Parameter settings
(practice and art)
23

Genetic Algorithms

Simple Genetic
Algorithm
{

initialize population;
evaluate population;
while TerminationCriteriaNotSatisfied
{

select parents for reproduction;


perform recombination and mutation;
evaluate population;
}
}

24

Genetic Algorithms

The GA Cycle of
Reproduction
reproduction

children

modified
children

parents

population

modification

evaluated children

evaluation

deleted
members

discard
25

Genetic Algorithms

Population
population
Chromosomes could be:

Bit strings
Real numbers
Permutations of element
Lists of rules
Program elements
... any data structure ...
26

(0101 ... 1100)


(43.2 -33.1 ... 0.0 89.2)
(E11 E3 E7 ... E1 E15)
(R1 R2 R3 ... R22 R23)
(genetic programming)

Genetic Algorithms

Reproduction
reproduction

children

parents

population

Parents are selected at random with


selection chances biased in relation to
chromosome evaluations.
27

Genetic Algorithms

Chromosome
Modification
children

modification
modified children

Modifications are stochastically triggered


Operator types are:
Mutation
Crossover (recombination)
28

Genetic Algorithms

Evaluation
evaluated
children

modified
children

evaluation

The evaluator decodes a chromosome and


assigns it a fitness measure
The evaluator is the only link between a
classical GA and the problem it is solving
29

Genetic Algorithms

Deletion
population
discarded members

discard

Generational GA:
entire populations replaced with each iteration
Steady-state GA:
a few members replaced each generation

30

Genetic Algorithms

An Abstract Example

Distribution of Individuals in Generation 0

Distribution of Individuals in Generation N


31

Genetic Algorithms

A Simple Example

The Gene is by far the most sophisticated program around.


- Bill Gates, Business Week, June 27, 1994

32

Genetic Algorithms

A Simple Example
The Traveling 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

33

Genetic Algorithms

Representation
Representation is an ordered list of city
numbers known as an order-based GA.
1) London
2) Venice

3) Dunedin
4) Singapore

5) Beijing 7) Tokyo
6) Phoenix 8) Victoria

CityList1

(3 5 7 2 1 6 4 8)

CityList2

(2 5 7 6 8 1 3 4)
34

Genetic Algorithms

Crossover
Crossover combines inversion and
recombination:
Parent1
Parent2
Children1
Children2

(3 5 7 2 1 6 4 8)
(2 8 7 6 8 1 3 4)
(3 5 7 6 8 1 3 4)
(2 8 7 2 1 6 3 4)

35

Genetic Algorithms

Mutation
Mutation changing the list:

Before:

*
*
(5 8 7 2 1 6 3 4)

After:

(5 8 6 2 1 7 3 4)

36

Genetic Algorithms

TSP Example: 30 Cities


100
90
80
70

60
50
40
30
20
10
0
0

10

20

30

40

50

60

70

80

90

100

37

Genetic Algorithms

Solution i (Distance =
941)
TSP30 (Performance = 941)
100
90
80
70

60
50
40
30
20
10
0
0

10

20

30

40

50

60

70

80

90

100

38

Genetic Algorithms

Solution j(Distance =
800)
TSP30 (Performance = 800)
100
90
80
70

60
50
40
30
20
10
0
0

10

20

30

40

50

60

70

80

90

100

39

Genetic Algorithms

Solution k(Distance =
652)
TSP30 (Performance = 652)
100
90
80
70

60
50
40
30
20
10
0
0

10

20

30

40

50

60

70

80

90

100

40

Genetic Algorithms

Best Solution (Distance =


420)
TSP30 Solution (Performance = 420)
100
90
80
70

60
50
40
30
20
10
0
0

10

20

30

40

50

60

70

80

90

100

41

Genetic Algorithms

Overview of
Performance
TSP30 - Overview of Performance
1600
1400

D ista n c e

1200
1000
800
600
400
200
0
1

11

13

15

17

19

Generations (1000)

42

21

23

25

27

29

31

Best
Worst
Average

Genetic Algorithms

Considering the GA
Technology
Almost eight years ago ...
people at Microsoft wrote
a program [that] uses
some genetic things for
finding short code
sequences. Windows 2.0
and 3.2, NT, and almost all
Microsoft applications
products have shipped
with pieces of code created
by that system.
- Nathan Myhrvold, Microsoft Advanced
Technology Group, Wired, September 1995
43

Genetic Algorithms

Issues for GA
Practitioners

Choosing basic implementation issues:

representation
population size, mutation rate, ...
selection, deletion policies
crossover, mutation operators

Termination Criteria
Performance, scalability
Solution is only as good as the evaluation
function (often hardest part)
44

Genetic Algorithms

Benefits of Genetic
Algorithms

Concept is easy to understand


Modular, separate from application
Supports multi-objective optimization
Good for noisy environments
Always has an answer; answer gets
better with time

45

Genetic Algorithms

Benefits of Genetic Algorithms


(cont.)

Many ways to speed up and improve a


GA-based application as knowledge
about problem domain is gained
Easy to exploit previous or alternate
solutions
Flexible building blocks for hybrid
applications
Substantial history and range of use
46

Genetic Algorithms

When to Use a GA

Alternate solutions are too slow or overly


complicated
Need an exploratory tool to examine new
approaches
Problem is similar to one that has already been
successfully solved by using a GA
Want to hybridize with an existing solution
Benefits of the GA technology meet key problem
requirements
47

Genetic Algorithms

Some GA Application
Types

D
o
m
a
i
n
A
p
p
l
i
c
a
t
i
o
n
T
y
p
e
s
g
a
s
p
i
p
e
l
i
n
e
,
p
o
l
e
b
a
l
a
n
c
i
n
g
,
m
i
s
s
i
l
e
e
v
a
s
i
o
n
,
p
u
r
s
u
i
t
C
ontrol

s
e
m
i
c
o
n
d
u
c
t
o
r
l
a
y
o
u
t
,
a
i
r
c
r
a
f
t
d
e
s
i
g
n
,
k
e
y
b
o
a
r
d
D
esign cm
oannfiu
gfu
racattuio
n
,
c
o
m
m
u
n
i
c
a
t
i
o
n
n
e
t
w
o
r
k
s
r
i
n
g
,
f
a
c
i
l
i
t
y
s
c
h
e
d
u
l
i
n
g
,
r
e
s
o
u
r
c
e
a
l
o
c
a
t
i
o
n
Scheduling trajectoryplanning
R
obotics designingneuralnetworks,improvingclassification
M
achineLearning afilltgeorrdithem
s
,
c
l
a
s
s
i
f
i
e
r
s
y
s
t
e
m
s
SignalProcessing poker,cshigenckers,prisonersdilemma
G
am
ePlaying setcovering,travelingsalesman,routing,binpacking,
C
om
binatorial graphcolouringandpartitioning

O
ptim
ization

48

Genetic Algorithms

Conclusions

Question:

If GAs are so smart, why aint they rich?

Answer:
Genetic algorithms are rich - rich in
application across a large and growing number of
disciplines.
- David E. Goldberg, Genetic Algorithms in Search, Optimization and Machine Learning

49

Genetic Algorithms

Das könnte Ihnen auch gefallen