Professional Documents
Culture Documents
Stefano Cagnoni
Introduction
Natural Evolution
In engineering to:
• Combinatorial/Function Optimization
• Machine Learning
• In general, search for solutions to hard problems
Components of an evolutionary
algorithm
An evolutionary algorithm is fully determined when its
essential components have been defined
1. Representation (encoding)
2. Evaluation Function (fitness function)
3. Population
4. (Parents’) Selection Strategy
5. Operators (Modification/recombination)
6. Survivors’ Selection Strategy (Substitution)
7. Initialization Strategy
8. Termination Condition
General evolutionary algorithm
A typical evolutionary algorithm is composed of the following
steps:
1. Initialize a population
2. Evaluate population’s fitness
3. repeat
a. select a population subset, based on fitness
b.from the selected individuals, generate a new
population using modification/recombination operators
c. Evaluate the new population’s fitness
until a termination criterion is met
Genetic Algorithms
Genetic Algorithms
Genetic algorithms operate on solution encodings to obtain
new solutions: in genetic terms, only the genotype is affected
(as happens in nature). A genotype-to-phenotype decoding
mechanism needs to be defined, by which a solution is
produced from its encoding, in order to evaluate its
effectiveness.
− Numbers
Integers (from 0 to 2n-1, from K to K+2n-1,
from 0 to M with M≠2n-1)
Real Numbers
Fitness-proportionate selection
pi = fi / Skfk
Premature convergence
If an individual’s fitness is much higher than the average
population fitness, but much lower than the optimum, it
tends to be repeatedly selected and a mediocre uniform
population is generated.
Stagnation
If all individuals have similar fitness, they tend to have the
same selection probability, causing the optimization strategy
to become a random search.
Selection
Rank selection
Individuals ranked by fitness (in descending order).
A probability distribution function, decreasing with rank, is
defined, independent of fitness values.
Advantages
No premature convergence: no individual can have a
selection probability much higher than any other.
No stagnation: the probability distribution does not change.
Disadvantages
Computationally heavier.
Tournament selection
To select each individual, a random subset of the population
of predefined size is picked, and the best is selected.
Advantages
Same as rank-based selection, with no need for ordering.
Selection
Elitist Selection (applicable also to survivors’ selection)
At least one copy of the best individual is kept in the new
generation.
Advantages
Good solutions are not lost due to ‘random’ selection
strategies
Disadvantages.
If the best individual’s characters become dominant, this
may lead to premature convergence.
Genetic operators: Crossover
The string is circular. Two ‘cuts’ are made and the inner or
outer sections are swapped
Genetic operators: Crossover
UNIFORM CROSSOVER
1110001101001010 1000100111001010 PARENTS
Full recombination
Child1: a y + (1-a) x Child2: a x + (1-a) y
Crossover for permutations
Partially-mapped crossover (PMX)
1. Two points are chosen and the values within them are
copied into C1
P1 : 123456789 P2: 937826514
C1: ...4567..
2. Starting from the first point, the elements of P2 ,
comprised between the two selected points, which have
not been copied yet are considered
3. For each of them (i) the element (j) of C1 which occupies
the corresponding position is considered
Crossover for permutations
Partially-mapped crossover (PMX) (cont.):
4. i is moved into the position occupied by j in P2
C1: ...4567.8
5. If the position occupied by j in P2 has already been taken in
C1 by k, i is moved into the position occupied by k in P2
C1: ..24567.8
6. The other elements of C1 are directly copied from P2
C1: 932456718 .
C2 is created similarly, swapping the parents.
Genetic operators: mutation
Mutation is aimed at maintaining genetic diversity, to try and
explore also regions in the search space which are not
‘occupied’ by the present population.
Mutation for binary representations
A bit is chosen randomly and is inverted.
1001010010101 1000010010101
Mutation for integer representations
It is possible to substitute a gene with a valid random value,
or add a positive or negative quantity to it, from a probability
distribution having its maximum in zero.
Genetic operators: mutation
Mutation for floating point representations
From <x1,x2,. . ., xn>, xi[Li,Ui],
<x’1,x’2,. . ., x’n>, x’i[Li,Ui] is generated by substituting values
randomly
Uniform Mutation
All elements are substituted by a random value belonging to
the same interval.
Non-uniform Mutation with fixed distribution
Each element of the new vector is generated by adding a
random number from a distribution centered in zero and
decreasing with the absolute value (e.g., a Gaussian
distribution G(0,s) ).
Genetic operators: mutation
Mutation for permutations
Two random points are chosen and ….
Swap
123456789 153426789
Insertion
123456789 125346789
Shuffle
123456789 153246789
Inversion
123456789 154326789
Survivors’ selection (substitution)
Age-based strategies
Independently of fitness, each individual survives for a pre-set
number of generations. Implementation is trivial if l = m (the
whole population at time t+1 is made up of offspring of
generation t).
If l < m fitness should be taken into account (with a random
substitution strategy the probability to lose the best
individual is very high).
Survivors’ selection (substitution)
Fitness-based strategies
The same strategies used to select the mating pool can be
adopted (fitness-proportionate, rank-based, tournament).
It is also possible to consider age, requiring, for instance
(if l < m ) that all offspring make up the next generation,
along with the best m - l parents.
The replace-worst strategy replaces the worst l
individuals.
Elitist strategies require that the best individual of
generation t be present in generation t+1.
Parameters of a genetic algorithm
Along with representation, operators and selection strategies,
the following parameters must be set:
• Population size
• Termination criterion, usually set alternatively as
- maximum number of iterations or
- fitness threshold (evolution ends when a sufficiently
good solution is found)
• Frequency with which genetic operators are applied:
- clonation (survival) probability
- crossover probability
- mutation probability
Genetic Programming
Genetic Programming
A variant of genetic algorithms: same algorithm applied to a
semantically different representation.
Functions are evolved, usually represented as syntactic trees
Mutation
Genetic Programming
It is necessary to define:
• A function set F (tree nodes) for each of which arity
(number of arguments) must be specified
• A terminal symbol set T (tree leaves)
that meet the following requirements:
• All elements of T are correct expressions
• If fF is a function with arity n and (e1,…., en) are correct
expressions, then also f(e1,….,en) is correct
• There are no other possible correct expressions
These conditions are equivalent to the closure requirement.
Genetic Programming
The final problem to be solved is the definition of
constants
A possible solution (Ephemeral Random Constants)
consists of using a constant terminal symbol defined
within a certain interval;
- When a new tree is generated (initialization), i.e., the
first time an ERC is used, it is assigned a random value
within its domain.
- For every subsequent use, an ERC behaves as a
constant, keeping the same value at which it has been
initialized
Genetic Programming
Selection
The same strategies described for GAs may be used.
However, since large populations are usually generated, an
over-selection strategy is also used:
• Population is ordered by fitness and divided into two
groups, the former containing x% of the population,
the latter the remaining (100-x)%
• 80% of the individuals is selected from the first group,
the 20% from the second one.
Genetic Programming
Bloat
Since GP uses a variable-length representation, tree depth
tends to increase with time
This is called bloat or, as a joke, “survival of the fattest” (as
opposed to “survival of the fittest”).
Possible remedies:
• Operations which produce individuals with depth D >
Dmax are forbidden
• A term is added to the fitness function, which penalizes
the largest trees, e.g.,
F’ = F + 0.0001 * Size (parsimony pressure)