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

The Genetic Algorithm

“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
GA Overview
• Developed: USA in the 1970’s
• Early names: J. Holland, K. DeJong, D. Goldberg
• Typically applied to:
– discrete optimization
• Attributed features:
– not too fast
– good heuristic for combinatorial problems
• Special Features:
– Traditionally emphasizes combining information from good parents
(crossover)
– many variants, e.g., reproduction models, operators
A genetic algorithm (GA) is an algorithm used to
find approximate solutions to difficult-to-solve
problems through application of the principles
of evolutionary biology to computer science.

Genetic algorithms use biologically-derived


techniques such as inheritance, mutation,
natural selection, and recombination.
• Take a population of candidate solutions to a
given problem
• Use operators inspired by the mechanisms of
natural genetic variation
• Apply selective pressure toward certain
properties
• Evolve a more fit solution
Abstractions imported from biology

•Chromosomes, Genes, Alleles(position


of genes in a string of chromosome)
•Fitness, Selection
•Crossover, Mutation
GA terminology
• In the spirit – but not the letter – of biology
 GA chromosomes are strings of genes
 Each gene has a number of alleles; i.e., settings
 Each chromosome is an encoding of a solution to
a problem
 A population of such chromosomes
Genetic algorithms

• Holland’s original GA is now known as the


simple genetic algorithm (SGA)
• Other GAs use different:
– Representations
– Mutations
– Crossovers
– Selection mechanisms
SGA technical summary tableau

Representation Binary strings

Recombination N-point or uniform

Mutation Bitwise bit-flipping with fixed


probability
Parent selection Fitness-Proportionate

Survivor selection All children replace parents

Speciality Emphasis on crossover


Encoding
• A data structure for representing candidate
solutions
– Often takes the form of a bit string

– Usually has internal structure; i.e., different parts of


the string represent different aspects of the solution)
Representation

Phenotype space Genotype space =


Encoding {0,1}L
(representation) 10010001
10010010
010001001
011101001
Decoding
(inverse representation)
SGA reproduction cycle

1. Select parents for the mating pool


2. Shuffle the mating pool
3. For each consecutive pair apply crossover
4. For each offspring apply mutation (bit-flip)
5. Replace the whole population with the resulting
offspring
Crossover
• Mimics biological recombination
– Some portion of genetic material is swapped
between chromosomes
– Typically the swapping produces an offspring
• Mechanism for the dissemination of “building
blocks” (schemas)
SGA operators: 1-point crossover
• Choose a random point on the two parents
• Split parents at this crossover point
• Create children by exchanging tails
Mutation
• Selects a random locus – gene location – with
some probability and alters the allele at that
locus

• The intuitive mechanism for the preservation of


variety in the population
SGA operators: mutation

• Alter each gene independently


SGA operators: Selection
• Main idea: better individuals get higher chance
– Chances proportional to fitness
– Implementation: roulette wheel technique
» Assign to each individual a part of the
roulette wheel
» Spin the wheel n times to select n
individuals
1/6 = 17%

A B fitness(A) = 3
C fitness(B) = 1
3/6 = 50% 2/6 = 33%
fitness(C) = 2
Fitness
• A measure of the goodness of the organism

• Expressed as the probability that the organism will live


another cycle (generation)

• Basis for the natural selection simulation


– Organisms are selected to mate with probabilities
proportional to their fitness

• Probabilistically better solutions have a better chance of


conferring their building blocks to the next generation
(cycle)
The GA Cycle of Reproduction

children
reproduction modification
modified
parents children
population evaluation
evaluated children
deleted
members

discard
An example after Goldberg ‘89

• Simple problem: max x2 over {0,1,…,31}


• GA approach:
– Representation: binary code, e.g. 01101  13
– Population size: 4
– 1-point xover, bitwise mutation
– Roulette wheel selection
– Random initialisation
• We show one generational cycle done by hand
x2 example: selection
X2 example: crossover
X2 example: mutation
Simple Genetic Algorithm
{
initialize population;
evaluate population;
while Termination Criteria Not Satisfied
{
select parents for reproduction;
perform recombination and mutation;
evaluate population;
}
}
Other Example
of
Crossover and Mutation
Initial Population

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)


Select Parents

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

Try to pick the better ones.


Create Off-Spring – 1 point

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

(3,4,5,6,2)
Create More Offspring

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

(3,4,5,6,2) (5,4,2,6,3)
Mutate

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

(3,4,5,6,2) (5,4,2,6,3)
Mutate

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (2,3,6,4,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

(3,4,5,6,2) (5,4,2,6,3)
Eliminate

(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)

(2,3,4,6,5) (2,3,6,4,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)

(3,4,5,6,2) (5,4,2,6,3)

Tend to kill off the worst ones.


Integrate

(5,3,4,6,2) (2,4,6,3,5) (5,4,2,6,3)

(3,4,5,6,2) (2,3,6,4,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)


Restart

(5,3,4,6,2) (2,4,6,3,5) (5,4,2,6,3)

(3,4,5,6,2) (2,3,6,4,5) (3,4,5,2,6)

(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)

(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)


Thanks

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