Algoritmos genéticos
Algoritmos genéticos
Introduction
What are genetic algorithms?
What are genetic algorithms?
`
“…Search algorithms based on the mechanics of natural
l
i
d
l
i ”
selection and natural genetics.”
Holland, J. (1989)C
bi i l
f
h
fi
`
Combine survival of the fittest.
I
i
`
In every generation,
` A new set of artificial creatures is created
` Pieces of the fittest old ` Pieces of the fittest old
` Ocassional new parts tried for good measure.
`
Randomized but no random walk.
What are genetic algorithms?
What are genetic algorithms?...
`
Developed by John Holland and colleagues at the
University of Michigan.
`
Central research theme:
robustness
.
` Balance between efficiency and efficacy. ` Nature is better for robust performance. ` Computationally simple and powerful.
` Not fundamentally limited by restrictive assumptions about the search space
C f d d l
Traditional optimization methods
Traditional optimization methods
`
Search methods
` Random search
` Do not use information about the search space.
` Simulated Annealing is a randomized technique (not a random ` Simulated Annealing is a randomized technique (not a random
search)
`
Calculus-based
` Local in scopep
` Depend upon the existence of derivatives
`
Enumerative
Optimization
Optimization
`
Improve performance toward some optimal point or
points
1. Seek improvement to approach some …
` Process of improvement
2. … optimal point (destination)
` U l t i t d id if d i d h ` Usual metric to decide if a procedure is good enough.
` Is like asking a person to be perfect when solving problems.
`
Nature: the most important goal of optimization is
improvement
improvement
.
GA vs Traditional methods
GA vs. Traditional methods
`
Four differences:
1. GAs work with a coding of the parameter set, not the
parameters themselves.
2. GAs search from a population of points, not a single point
3. GAs use payoff (objective function) information, not
derivatives or other auxiliary knowledge derivatives or other auxiliary knowledge.
GA vs Traditional methods
GA vs. Traditional methods …
`
Natural parameter set of the optimization problem must
be coded as a
finite-lenght string over some finite
alphabet
.
`
GAs work in parallel.
`
GAs are blind.
Simple Genetic Algorithm
p
g
Simple Genetic Algorithm
Simple Genetic Algorithm
`
Simplicity of operation and power of effect two main
attractions of GA approach.
`
Composed of three operators:
Reproduction
Reproduction
`
Process in which individual strings are
copied
according to
their objective function values
f
their objective function values,
f
.
` Biologist call it fitness function.
` Measure of profit, utility of goodness.
` We want to maximize it.
`
Strings with higher value have a higher
probability
of
`Strings with higher value have a higher
probability
of
contributing one or more offspring in the next generation.
`
Artificial version of natural selection (Darwinian survival of the
Reproduction
Reproduction …
`
Biased roulette
` Each current string has a slot sized in proportion to its fitness.
f
P l t
i∑
=
f
f
Pselect
i if
unt
ExpectedCo
=
iA i l
d f
d
i i
li
d i h
_
f
p
`
A string selected for reproduction is replicated in the
Crossover
Crossover
`
Two steps:
1 Members of the new reproduced strings are mated at random 1. Members of the new reproduced strings are mated at random.
2. Each pair of strings undergoes crossing:
1. An integer position k along the string is selected between 1 and the
string length less one [1, l – 1]
T i d b i ll h b
2. Two new strings are created by swapping all characters between
positions k + 1 and l inclusively.
`
The process of reproduction and crossover is a kind of
exchange – much of the power of GA.
g
p
` High performance notions are repeatedly tested and exchanged in
Mutation
Mutation
` Secondary role in GAs.
` Mutation is the occasional random alteration of the value of a string position.g p
` Needed because some information, relative to the position of
h b l d
characters, may be lost during crossover.
` Is a random walk through the string space ` Is a random walk through the string space.
Example
Example
` Maximize f(x) = x2
` x varies between 0 and 31 ` x varies between 0 and 31.
1. Coding
1. Binary unsigned integer length 5.
2 Select initial population at random. 2. Select initial population at random.
3. Repeat
1. Reproduction
2. Crossover
Example
Example …
Initial Expected Actual
String No. Population x f(x) Pselect count Count
1 01101 13 169 0.14 0.58 1
2 11000 24 576 0.49 1.97 2
3 01000 8 64 0.05 0.22 0
4 10011 19 361 0.31 1.23 1
Sum 1170 1 4 4
Generation 1 Average 292.5 0.25 1 1
Max 576 0 49 1 97 2
Example
Example …
Mating Crossover New
P l M t Sit P l ti
Pool Mate Site Population
0110|1| 2 4 01100
1100|0 1 4 11001
11|000 4 2 11011
Example
Example …
Initial Expected Actual
String No. Population x f(x) Pselect count Count
1 01100 12 144 0.08 0.33 0
2 11001 25 625 0.36 1.43 1
3 11011 27 729 0.42 1.66 2
4 10000 16 256 0.15 0.58 1
Sum 1754 1 4 4
Exercises
Exercises
`
The following exercises must be handed in at the end of
the class.
Exercise 1
Exercise 1
`
Create a list of
N
numbers that equal
X
when summed
together
`
For instance:
` N = 5 ` X = 100 ` Solutions:
` [20,20,20,20,20]
` [50,20,10,10,10]
[10 20 30 40 0]
Exercise 2
Exercise 2
Exercise 3
Exercise 3
B
25 52
25
63
52
A D
33
48 19
Lingo
Lingo
Nat ral
Genetic Algorithm
Natural
Genetic
Algorithm
chromosome
string
gene
feature,
character,
or
detector
allele
feature
value
locus
string
position
genotype
structure
Mathematical Foundations
Similarity templates (Schemata)
Similarity templates (Schemata)
`
What information is contained in a population of strings
d h i bj
i f
i h l id i
?
and their objective function to help guide improvement?
String Fitness
01101 169 11000 576 01000 64
A h
i il i i
i
?
01000 64 10011 361
`
Are there any similarities among strings?
A h
l l
h b
h
l
`
Are there causal relationships between these similarities
Schemata
Schemata …
`
Schema
: similarity template describing a subset of
strings with similarities at certain string positions.
` Uses the * or don’t care symbol.
` For instance:
{ }
` Binary alphabet {0,1}
` Schemata created from the ternary alphabet {0, 1, *}
` Some schemata of length 6: ` Some schemata of length 6:
*01010
1*0*0*
Schemata
Schemata …
`
Schema
` Powerful and compact way to analyze well-defined similarities.
(
)
l` Number of possible schemata in a string
` l = length of string
k di li f l h b
(
)
lk
+
1
` k = cardinality of alphabet
` Example: l = 6, k = 2; 3*3*3*3*3*3 = 36 = (2+1)6 = 729
Schemata
Schemata …
`
All schemata are not analyzed, only those present in a
population
population.
` Number of schemata in a binary string are: 2l (26 = 64)
f 2l (2l
` Binary population of size n contains between 2l and n(2l) schemata.
` Example. n = 5, between 64 to 320 schemata.
` Several schemata are processed at each iteration.
` Some schemata are better: ` Some schemata are better:
` 0****1 ` 11****
` Are these schemata preserved by reproduction, crossover and
Fundamental Theorem Notation
Fundamental Theorem – Notation
`
Basic notation
{ }
` Binary alphabet
` Strings
{ }
0
,
1
=
V
a a a a a a a A = ` Strings` ai is a single feature (gene) that can take a value (allele).
7 6 5 4 3 2
1a a a a a a
a A =
` Order of genes need not to be sequential A′ = a2a7a3a1a5a6a4
` Population of individual strings Aj, j = 1, 2, …, n
` A(t) population at time t (generation) ` A(t) population at time t (generation).
` Schema alphabet V + =
{ }
0,1,*Fundamental Theorem Notation
Fundamental Theorem – Notation …
`
Notation …
` All schemata are not created equal.
` Order of a schema H is the number of fixed positions: o(H)
` The defining length of a schema H is the distance between the first
and the last specific string position: p g p δ
( )
H` Examples:
( )
Hδ
H1 = *1**10*
Fundamental Theorem Reproduction
Fundamental Theorem – Reproduction
`
Effect of reproduction in schemata
` At time t there are m examples of a schema H in population
A(t)
( )
H t mm = ,
` String Ai is selected with probability
( )
H t m m ,∑
= f fpi i
g i p y
∑
f pi` Number of elements of schema H at time t+1
(
H
t
+
)
=
m
( )
H
t
⋅
n
⋅
f
( )
H
m
1
` f(H) is the average fitness of strings representing schema H
(
)
( )
∑
⋅
⋅
=
+
f
n
t
H
m
t
H
m
,
1
,
Fundamental Theorem Reproduction
Fundamental Theorem – Reproduction …
f
∑
`
Average fitness of entire population:
n f
f =
∑
`
therefore:
(
)
( )
( )
( ) ( )
f H f t H m f H f n t H m t H
m , +1 = , ⋅ ⋅ = ,
∑
` Above population average: increasing number of samples in next population
f f
∑
next population
Fundamental Theorem Reproduction
Fundamental Theorem – Reproduction …
` Effect of reproduction in the number of schemata is:` Ab d li
` Above-average grow and live. ` Below-average die off.
` How is this growth? Exponential
` Assume schema H remains above average an amount
c
f
, c is a constant.(
)
( )(
) ( ) ( )
c m H tf f c f t H m t H
m , +1 = , + = 1+ ⋅ ,
` Starting at t = 0 and assuming c stationary:
( )
(
) (
)
tc
H
m
t
H
m
=
0
⋅
1
+
` Geometric progression with with common ratio greater than 1, i.e. exponential
growth
( )
H
t
m
(
H
) (
c
)
m
,
=
,
0
⋅
1
+
Fundamental Theorem Crossover
Fundamental Theorem – Crossover
`
Effect of crossover in schemata
` Crossover: structured yet randomized information exchange between strings.
` Affects schemata
` Examples:
A = 1101010 H1 = *1****0 H22 = ***10**
Crossover sites: 3 and 5
Fundamental Theorem Crossover
Fundamental Theorem – Crossover …
( )
H
δ
`
Schema H is destroyed with probability:
( )
( )
1
−
=
l
H
p
dδ
( )
H
δ
`
and survives with probability:
( )
( )
1
1
1
−
−
=
−
=
l
H
p
p
s dδ
`
If crossover is selected random with probability p
`If crossover is selected random with probability p
c( )
( )
1
−
⋅
≥
p
H
p
δ
( )
1
1
−
≥
l
p
Fundamental Theorem Crossover
Fundamental Theorem – Crossover …
`
The combined effect of reproduction and crossover is:
(
)
( ) ( )
⎢⎣
⎡
( )
⎥⎦
⎤
−
⋅
−
≥
+
1
1
,
1
,
l
H
p
f
H
f
t
H
m
t
H
m
cδ
` Schema survives or dies based on a factor. This factor depends
⎦
⎣
l
−
1
f
p on:
` Reproduction: schema above or below the average.
` Crossover: schema has a short or long defining length.
` Ab d h t d fi i l ht l d
` Above average and short defining lenght are sampled
Fundamental Theorem Mutation
Fundamental Theorem – Mutation
` Effect of mutation in schemata
` Mutation is a random alteration of genes with probability p ` Mutation is a random alteration of genes with probability pm
` A schema survives if all its fixed positions survive with the same value, i.e. all
alleles survive.
` A single allele survives with probability
(
)
m
p
−
1
` Therefore a schema with o(H) fixed positions has the following probability to
survive:
(
)
o( )Hm p
−
1
` For small values of pm (pm << 1) this expression can be approximated by:
( )
H po ⋅
−
1
` Thefore, the lower the order, the greater the probabilities of a schema to
survive
( )
H pmo ⋅
1
Fundamental Theorem
Fundamental Theorem
`
Taking into consideration all three factors:
(
+
)
≥
( ) ( )
⎢⎣
⎡
−
c⋅
( ) ( )
−
o
H
p
m⎤
⎥⎦
l
H
p
f
H
f
t
H
m
t
H
m
1
1
,
1
,
δ
⎥⎦
⎢⎣
l
−
f
1
`
Schemata Theorem (Fundamental Theorem of GAs)
` Short (crossover) ` Short (crossover),
` Low order (mutation),
` Above average (reproduction) ` Above average (reproduction)
Implicit parallelism
Implicit parallelism
`
GA processes at each cycle
n
strings.
`
At the same time it processes n
p
3schemata.
Building block hypothesis
Building block hypothesis
`
Building blocks
. Highly fit schemata of low defining
lenght and low order.
`
These are sampled, recombined, and resampled to form
Computer Implementation of GA
p
p
Data structures
Data structures
`
Construct a population as an array of individuals with:
` Phenotype (decoded parameter of parameters) ` Genotype (artificial chromosome or string)
` Fitness (objective function)
Performance of GAs
Good performance of GAs
Good performance of GAs
`
Depend of a good choice of (De Jong, 1975):
` High crossover probability. ` Low mutation probability
` Inversely proportional to the population size
` Moderate population size
` For the problem of x10 the selection was:
` P t ti = 0 0333 ` Pmutation = 0.0333
` Pcrossover = 0.6
Mapping Objective Functions to Fitness
Form
Form
`
A fitness function must be a
nonnegative
figure of merit.
`
Necessary to map a natural objective function to a fitness
function.
`
Cost-fitness (minimization) transformation in GAs
( )
⎨
⎧
C
−
g
( )
x
when
g
( )
x
<
C
f
( )
max( )
( )
max⎩
⎨
⎧
=
otherwise
g
g
x
f
0
max max
`
C
maxmay be taken as the largest value of the cost function
g(x)
Mapping
Mapping …
`
Profit or utility (maximization) in GAs:
( )
x
=
⎨
⎧
u
( )
x
+
C
when
u
( )
x
+
C
>
f
( )
min min0
⎩
⎨
otherwise
f
0
`
C
minmay be the absolute value of the worst
u
value in the
Fitness scaling
Fitness scaling
`
Regulation of the number of copies important in small
populations
populations
` Start of GA
` Few extraordinary stringsy g
` Normal selection rule
E di i di id l k i ifi i f l i
` Extraordinary individuals take over a significant proportion of population
very quickly
` Causes premature convergence.
` Later in run
` Not enough diversity ` Not enough diversity
` Population average fitness close to best fitness
Fitness scaling
Fitness scaling …
`
Fitness scaling helps.
b
f
f
′
+
` Linear scaling is very useful.
` Coefficients a and b are calculated based on:
b
af
f
=
+
` Coefficients a and b are calculated based on:
` Selection for reproduction insures each average member contributes
one offspring to next generation.
f
f
′
` Number of offsprings of a member can be controlled by
avg avg
f
f
′
=
` Number of offsprings of a member can be controlled by
avg mult
f
C
f
max′
=
⋅
` Cmult is the number of expected copies of the best member
Codings
Codings
`
Codes used in GA can be any.
` Programmer limited by imagination.
`
What other code can be assigned to the problem
f(x) = x
2in [0,31]?
`
GA exploit similarities in codes as long as building blocks
p
g
g
lead to near optima.
Codings
Codings …
`
Principle of meaningful building blocks
` The user should select a coding so that short, low-order
schemata are relevant to the underlying problem and relatively
l t d t h t th fi d iti
unrelated to schemata over other fixed positions.
` Can be formaly verified but usually is done empirically ` Can be formaly verified but usually is done empirically.
`
Principle of minimal alphabets
`Principle of minimal alphabets
` The user should select the smallest alphabet that permits a natural expression of the problem
Codings
Codings …
Binary String Value X Nonbinary String Fitness 0 1 1 0 1 13 N 169 1 1 0 0 0 24 Y 576
0 1 0 0 0 8 I 64
0 1 0 0 0 8 I 64 1 0 0 1 1 19 T 361
Coding Correspondence Table Coding Correspondence Table
Binary Nonbinary
0 0 0 0 0 A 0 0 0 0 1 B
. .
. .
. .
1 1 0 0 1 Z
1 1 0 1 0 1
1 1 0 1 0 1 1 1 0 1 1 2
Codings
Codings …
`
Binary code
` Search for similarities possible by small cardinality ` l = 5
` Number of strings = 25 = 32
` Number of schemata = 35 = 243
`
Nonbinary code
` No similarities to exploit ` l = 1
Multiparameter mapped fixed point coding
Multiparameter, mapped, fixed-point coding
`
Coding of multiparameter optimization problems of real
parameters.
`
Map linearly from
[0,2
l]
to an interval
[U
min, U
max]
.
`
Precision calculated by:
U U
1 2
min max
− − = U l U
Constraints
Constraints
` Usually checked when evaluating the objective function.
` In some cases we want to degrade fitness value based on the degree of constraint violation.
` Penalty method
` A constrainded problem in optimization associates a cost or penalty with all constraint
violations.
E l
` Example
` Minimize ` Subject to
,... 2 , 1 0 ) ( ) ( n i x h x g
i ≥ =
` Minimize g(x) r
[
h (x)]
n i Φ +
∑
` Minimize ` .[
]
t coefficien penalty -function, penalty where ) ( ) ( 1 r g i i Φ∑
=( )
[
hi x]
= hi2( )
xΦ
t. coefficien penalty
Example
p
Example
Example
`
Evolutionary Approach for Strategy Learning in RoboCup
Soccer.
Nakashima et al. (2004). IEEE International Conference on Systems, Man and Cybernetics.
` Evolutionary method to obtain team strategies for soccer agents.
M f fi d
Example
Example …
`
Each soccer agent has a set of action rules.
`
Action rules used only when agent keeps ball, i.e. ball is
y
g
p
Example …
Aj is one of the 48 subareas of the field
of the field.
Bj examines whether the nearest opponent is near the agent or not, i.e.near
or not near.
Example …
p
Example
Example …
`
Encoding scheme
Th 48 2 96 i l f
` There are 48 x 2 = 96 action rules for an agent.
` 10 agents need to calculate rules (not the keeper), therefore, 960 ` 10 agents need to calculate rules (not the keeper), therefore, 960
rules in a team.
T k E l i i f l h 960 b i i
` Task: Evolve integer strings of length 960 to obtain team strategies
with high performance.
Example
Example …
`
Evaluation of integer strings
` Scores of soccer games.
1. Scored goals 2. Goals against.
`
Evolutionary operation
`Evolutionary operation
1. Initialization
2 Generation of new integer string uses mutation only 2. Generation of new integer string – uses mutation only. 3. Performance evaluation.
4 Generation update best strings of current and new 4. Generation update – best strings of current and new
Example …
Experimental settings:
Number of integer strings in a population: one.
Number of new strings generated by mutation: one.
Probability of mutation for Probability of mutation for each gene: 1/96.
Example …
First Evaluation Scheme:
Scheme:
Current integer string directly competes with the new integer string
generated by the mutation operator.
Example …
Second Evaluation Scheme:
Each current integer string and the new generated integer string compete against UvA Trilearn 2003 base team.
I i i h h
Integer string with the
Improvements in basic technique
p
q
Alternate Selection Schemes
Alternate Selection Schemes
`
Brindle’s (1981) schemes:
` Deterministic sampling
` Remainder stochastic sampling without replacement ` Remainder stochastic sampling without replacement
` Stochastic sampling without replacement ` Stochastic sampling without replacement
` Remainder stochastic sampling with remainder
` Stochastic sampling with replacement
Alternate Selection Schemes
Alternate Selection Schemes …
`
Deterministic sampling
S l i l l d l pselect = fi
` Selection calculated as usual:
` Expected number of individuals ei is calculated as:
` The integer part of ei is the number of samples for individuals.
∑
= f pselecti n pselect ei = i ⋅g p i p
` Population is sorted according to fractional parts of ei.
` The remainder strings needed are drawn from the top of the sorted list.
`
Remainder stochastic sampling without replacement
` Starts as deterministic sampling. ` Starts as deterministic sampling.
` Integer part of ei is used in the same way. ` Fractional parts are treated as probabilities.
` Weighted coin tosses (Bernoulli trials) are performed.
Alternate Selection Schemes
Alternate Selection Schemes …
`
Stochastic sampling without replacement
f
` Expected number of individuals is:` Each time a string is selected for
` Mating and crossover its offspring count is decreased by 0 5
f
f
` Mating and crossover its offspring count is decreased by 0.5.
` Without mating and crossover its offspring count is decreased by 1.0.
` If the count was below 0.0 the string was not available for g selection.
R
i d
h i
li i h
l
`
Remainder stochastic sampling with replacement.
` Starts as deterministic sampling.
` Integer part of e is used in the same way ` Integer part of ei is used in the same way.
Alternate Selection Schemes
Alternate Selection Schemes …
`
Stochastic sampling with replacement
` Fancy name for normal selection.
`
Stochastic tournament (Wetzel ranking)
` Selection probabilities are calculated normally.
` Pairs of individuals are drawn using roulette wheel selection. ` After drawing a pair,
` String with highest fitness is the winner and inserted in the new
population.
Scaling mechanisms
Scaling mechanisms
`
Done to keep appropiate levels of competition in a
simulation.
`
Without scaling
` Few superindividuals dominate the selection process early on the simulation.
` Scaling helps to scale back superindividuals to prevent them to
takeover the population takeover the population.
` Later on population is largely converged competition is less ` Later on, population is largely converged, competition is less
strong and simulation tends to wander.
Scaling mechanisms
Scaling mechanisms …
`
Linear scaling
W k llb
af
f
′
=
+
` Works well.
` Can have problems with negative values.
`
Sigma truncation
` Constant c is chosen as a reasonable multiple of the population
)
(
´
=
f
−
f
−
c
⋅
σ
f
standard deviation (between 1 and 3)
` Negative results are set to 0.
` There is no danger of negative values ` There is no danger of negative values.
`
Power law scaling
g
f
´
=
f
k` K is problem-dependent
May require change during a run to stretch or shrink the range.
Ranking procedures
Ranking procedures
`
Alternative to scaling.
`
Population sorted according to objective function value.
`
Individuals assigned offsprings as a function to their rank.
` Rank 1 is the maximum count ` Rank 1 is the maximum count.
`
Ranking has the same resistance to overselection and
g
underselection as normal selection in conjunction with scaling.
`
Problem
Generalized crossover model
Generalized crossover model
`
Proposed by De Jong (1975).
` Parameter: number of crossover points (CP).
` CP = 1 implies simple crossover.
` Even CP implies treating the string as a ring.
Crossover points selected around the ring uniformily at random. Crossover points selected around the ring uniformily at random.
` Odd CP implies
Position 0 is always a default crossing point.
` Not very good results ` Not very good results.
Advanced Operators in GA
p
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance
`
Diploidy – Pair of chromosomes.
`
Haploidy – Single stranded chromosome.
`
Di l id f
`
Diploid form
` Genotype carries one or more pairs of chromosomes (homologous
chromosomes).)
` Contain information for the same functions (decode to the same
function) function).
` Example:
` AbCDe
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance …
`
AbCDe
` Each locus of a letter represents an allele.
` Capital letters and lowercase letters are different phenotypic characteristics.
` Only one allele can be used at each locus.
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance …
`
Dominance
` Primary mechanism for eliminating the conflict of redundancy.
` The dominant allele takes precedence over alternative alleles ` The dominant allele takes precedence over alternative alleles
(recesives).
` An allele is dominant if it is expressed when paired with some other
allele.
` Example: ` Example:
` If capital letters are dominant and lowercase are recessive then:
AbCDe aBCde
` will produce:
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance …
`
Heterozygous (mixed, Aa = A)
`
Homozygous (pure, aa = a)
yg
(p
)
`
Dominant are heterozygous or homozygous
`Dominant are heterozygous or homozygous.
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance …
`
Diploidy (use of)
` Mechanism for remembering alleles and allele combinations that were previously useful
M l l l d l h l l
` Multiple solutions carried along with only one particular solution expressed.
`
Dominance (use of)
` O t t hi ld b d ll l f h f l l ti
` Operator to shield remembered alleles from harmful selection in a hostile environment.
` Dominance change allow old lessons to be remembered and ` Dominance change allow old lessons to be remembered and
Implementation of diploidy and dominance
p
p
y
H ll ti (1971) D i
Hollstien (1971) Dominance map
` Each binary gene described by
two genes two genes
` Modifier gene
` Functional gene
0M 0m 1M 1m
` Functional gene takes 0 or 1 as
normal.
0M
0
` Modifier gene takes values of Mor m.
0m
1M
` 0 alleles are dominant whenthere is at least one M allele
Implementation …
p
Hollstein Holland (1975)
D
i
Hollstein-Holland (1975)
Dominance map
`
As in Hollstein (1971) but:
0
1
1
(
)
` 3-alphabet {0,10,1}
0
1
0
1
` 1 is a dominant 1.
0
` 10 is a recesive 1.
1
0
Dominance Diploidy and Abeyance
Dominance, Diploidy and Abeyance …
`
Dominance-diploidy
` For shielding or abeyance
Reordering and Inversion
Reordering and Inversion
`
In GAs, it is not clear if a building block will lead to a
solution of a problem.
`
Nature is also not sure about its codings
` Has operators to search for
` Better codings – good string arrengements
Reordering and Inversion
Reordering and Inversion …
`
Inversion operator
` Primary natural mechanism responsible for recoding a problem.
` Two points are chosen along the chromosome.
` The end points are swaped.
` Example:
1
01
1
1
01
1
Reordering and Inversion
Reordering and Inversion …
`
Simple representation of GA
` Inversion has no meaning
` Value of an allele is dependent of its position
187
1
01
1
1
01
1
01
1
1
01
1
=
187
1
=
∧ ∧
159
10011111
I ll l ’ i i i i d d f i i
159
10011111
=
Reordering and Inversion
Reordering and Inversion …
`
New representation
1
01
11
01
1
12345678
`
changes to
1
01
11
01
1
∧ ∧
`
changes to
12654378
`
Allele value retains its meaning.
10011111
`
Allele value retains its meaning.
Reordering and Inversion
Reordering and Inversion …
`
Crossover with inversion
` Inversion has no problem with mutation, selection and decoding.
N bl
` Naive crossover constitutes a problem ` Example:
|
A A' 1234 | 43 8
1011 | 1011 5678 | 1234 = A 1111 | 1011 4378 | 1234 '= A 4378 | 1265 | =
B ' 1265 | 5678
| = B 1111 | 1001
Reordering and Inversion
Reordering and Inversion …
`
Reordering operators
` Partially Matched Crossover (PMX)
` Order Crossover (OX)
Reordering and Inversion
Reordering and Inversion …
` Partially Matched Crossover (PMX)
` Crossover of permutations ` Crossover of permutations
` Guarantees each position is found one in each chromosome.
1. Chromosomes are alligned. 1. Chromosomes are alligned.
2. Crossing sites are selected uniformily at random places (match section) 3. Matching section effect a crossover position by position.
4. Alleles are moved to their new positions in the chromosome. 4. Alleles are moved to their new positions in the chromosome.
` Example:
6
4
5
9
|
10
3
2
|
1
7
8
10
2
3
1
|
7
6
5
|
4
8
9
=
B
A
3
4
2
9
|
6
|
1
10
8
'
7
5
6
1
|
10
3
2
|
4
8
9
'
=
A
6
4
5
9
|
10
3
2
|
1
7
8
=
Reordering and Inversion
Reordering and Inversion …
`
Partially Matched Crossover (PMX)
` Useful for problems like Travel Salesman Problem (blind or normal versions)
` Chromosomes are a sequence of integers. ` Chromosomes are a sequence of integers.
` Each integer is a different city (permutation encoding)
87654321
` Permutation encoding
` Interest is on labels not on alleles
12345678
` Interest is on labels not on alleles.00000000
12345678
` For problems where fitness function depend only on ordering of
Reordering and Inversion
Reordering and Inversion …
` Order Crossover (OX)
1 Stars similar to PMX – select a
A
=
9
8
4
|
5
6
7
|
1
3
2
10
1. Stars similar to PMX select amatching section.
2. Map elements in the
6
4
5
9
|
10
3
2
|
1
7
8
=
B
p corresponging matching chromosome.3 Mapped elements leave a hole
H
9H4
|
10
23
|
1
H
8
=
B
3. Mapped elements leave a hole
(H) in the current chromosome.
4 Move holes with a sliding motion
B
=
23
10
H
H
H
9481
4. Move holes with a sliding motionstarting at the second crossing point.
9481
H
H
H
10
23
=
B
5. Fill in holes with the matching
Reordering and Inversion
Reordering and Inversion …
`
Order Crossover (OX)
` PMX and OX are very similar.
` PMX exploits absolute position similarities.
Reordering and Inversion
Reordering and Inversion …
` Cycle Crossover (CX)
1 Start with the first gene and fix it. C = 98217 4510 6 3 1. Start with the first gene and fix it.
2. The matching chromosome
defines the next position to be
10 9 8 7 6 5 4 3 2 1 D = p
considered using the value on the first gene (the one used first)
3 The corresponding gene in the
− − − − − − − − − = 9 ' C
3. The corresponding gene in the
matching chromosome defines
the next gene to consider. C'= 9− −1−− − − −−
4. Repeat until a cycle is found.
5. Crossover the remaining genes.
− − − − − −
Exercises Reordering
Exercises - Reordering
`
Results must be submitted at the end of the class.
`
Given the following pairs of chromosomes, what are the
g p
reorderings using?
` PMX
A
=
A
B
C
D
E
F
G
H
I
J
K
L
M
` OX ` CX
K
H
C
M
B
E
L
I
F
D
G
A
J
=
B
` Crossing points:
C
=
0
1
2
3
4
5
6
7
8
9
10
` A and B: 6, 11
` C and D: 2, 5