View
220
Download
0
Category
Tags:
Preview:
Citation preview
What is an Evolutionary Algorithm?
Chapter 2
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Contents
Recap of Evolutionary Metaphor Basic scheme of an EA Basic Components:
– Representation / Evaluation / Population / Parent Selection / Recombination / Mutation / Survivor Selection / Termination
Examples : eight queens / knapsackTypical behaviours of EAsEC in context of global optimisation
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
EVOLUTION
Environment
Individual
Fitness
The Main Evolutionary Computing Metaphor
PROBLEM SOLVING
Problem
Candidate Solution
Quality
Quality chance for seeding new solutions
Fitness chances for survival and reproduction
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Recap of EC metaphor
A population of individuals exists in an environment with limited resources
Competition for those resources causes selection of those fitter individuals that are better adapted to the environment
These individuals act as seeds for the generation of new individuals through recombination and mutation
The new individuals have their fitness evaluated and compete (possibly also with parents) for survival.
Over time Natural selection causes a rise in the fitness of the population
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Recap 2:
EAs fall into the category of “generate and test” algorithms. Learning doesn't happen from failure itself but rather from analyzing the failure, making a change, and then trying again.
They are stochastic, population-based algorithms Variation operators (recombination and mutation)
create the necessary diversity and thereby facilitate novelty
Selection reduces diversity and acts as a force pushing quality
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
General Scheme of EAs
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The generic structure of EAs
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Pseudo-code for typical EA
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
G enetic A lgorithm s(G A )D atatype: B inary S tring
A p p lic a t io n : a n y , A d a p t iv e S y s . (h is t . )P e rs o n s : G o ld b e rg , H o lla n d
E volution S trategy (E S )D atatype: R eal N um ber
A p p lic a t io n : N u m . O p t im iz a t io nP ersons: Schw efe l, B aeck, Rechenberg
C lass ifier S ys tem s(C FS )D atatype: R ule-S et
A p p lic a t io n : m a c h in e - le a rn in gP ersons : H o lland , D eJong , G re ffens te t te
G enetic P rogram m ing(G P )D atatype: P rogram T ree
A p p lic a t io n : a n yP e rs o n : K o z a
E P *Operators: m utation in spec. setting
P e rs o n : F o g e l
O ther
O ther (ca lled E P in textbook)D atatype: any
w ith p ro b le m -s p e c ific o p e ra to rsA p p lic a t io n : a n y
E v o lu tiona ry C om pu ta tion (E C) o ther nam es: E P , G A , E A ...
What are the different types of EAs (1)
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
What are the different types of EAs (2)
Historically different flavours of EAs have been associated with different representations
– Binary strings : Genetic Algorithms– Real-valued vectors : Evolution Strategies– Finite state Machines: Evolutionary Programming– LISP trees: Genetic Programming
These differences are largely irrelevant, best strategy – choose representation to suit problem– choose variation operators to suit representation
Selection operators only use fitness and so are independent of representation
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Representations
Candidate solutions (individuals) exist in phenotype space
They are encoded in chromosomes, which exist in genotype space
– Encoding : phenotype=> genotype (not necessarily one to one)
– Decoding : genotype=> phenotype (must be one to one)
Chromosomes contain genes, which are in (usually fixed) positions called loci (sing. locus) and have a value (allele)
In order to find the global optimum, every feasible solution must be represented in genotype space
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Evaluation (Fitness) Function
Represents the requirements that the population should adapt to
a.k.a. quality function or objective function Assigns a single real-valued fitness to each phenotype
which forms the basis for selection– So the more discrimination (different values) the
better Typically we talk about fitness being maximised
– Some problems may be best posed as minimisation problems, but conversion is trivial
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Population
Holds (representations of) possible solutions Usually has a fixed size and is a multiset of genotypes Some sophisticated EAs also assert a spatial structure
on the population e.g., a grid. Selection operators usually take whole population into
account i.e., reproductive probabilities are relative to current generation
Diversity of a population refers to the number of different fitnesses / phenotypes / genotypes present (note not the same thing)
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Parent Selection Mechanism
Assigns variable probabilities of individuals acting as parents depending on their fitnesses
Selection acts as a force pushing quality Usually probabilistic
– high quality solutions more likely to become parents than low quality
– but not guaranteed– even worst in current population usually has non-
zero probability of becoming a parent This stochastic nature can aid escape from local
optima
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Variation Operators
Role is to generate new candidate solutions Work on the individual level and creates diversity and
therefore facilitate novelty Usually divided into two types according to their arity
(number of inputs):– Arity 1 : mutation operators– Arity >1 : Recombination operators– Arity = 2 typically called crossover
There has been much debate about relative importance of recombination and mutation
– Nowadays most EAs use both– Choice of particular variation operators is representation dependant
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Mutation
Acts on one genotype and delivers another Element of randomness is essential and differentiates it
from other unary heuristic operators Importance ascribed depends on representation and
dialect:– Binary GAs – background operator responsible for preserving
and introducing diversity– EP for FSM’s/ continuous variables – only search operator– GP – hardly used
May guarantee connectedness of search space and hence convergence proofs
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Recombination
Merges information from parents into offspring Choice of what information to merge is stochastic Most offspring may be worse, or the same as the
parents Hope is that some are better by combining elements of
genotypes that lead to good traits Principle has been used for millennia by breeders of
plants and livestock
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Survivor Selection
a.k.a. replacement Most EAs use fixed population size so need a way of
going from (parents + offspring) to next generation Often deterministic
– Fitness based : e.g., rank parents+offspring and take best
– Age based: make as many offspring as parents and delete all parents
Sometimes do combination (elitism)
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Initialisation / Termination
Initialisation usually done at random, – Need to ensure even spread and mixture of possible allele values– Can include existing solutions, or use problem-specific heuristics,
to “seed” the population
Termination condition checked every generation – Reaching some (known/hoped for) fitness (the discovery of an
optimal or near optimal solution)– Reaching some maximum allowed number of generations– Reaching some minimum level of diversity– Reaching some specified number of generations without fitness
improvement (the EC detects the problem has no feasible solution)– Convergence on a single solution or set of similar solutions– After a user-specified threshold has been reached
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Initialisation using domain-specific knowledge
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Place 8 queens on an 8x8 chessboard insuch a way that they cannot check each other
Example: the 8 queens problem
For a certain application, explain how could be the Genotype and Phenotype?
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The 8 queens problem: representation
1 23 45 6 7 8
Genotype: a permutation of the numbers 1 - 8
Phenotype: a board configuration -The Phenotype space is the set of all such configurations.
Obvious mapping
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
EA FOR 8-QUEENS PROBLEM
Solution Representation
A chromosome is a permutation of the number 1,…,8 and a given g = < i1,…, i8> denotes the board configuration where the k-th column
contains exactly one queen placed on the ik th row.
Example: The permutation g = < 1,2,3,4,5,6,7,8> represents a board where the queens are placed along the main diagonal.
The solution space is now the set of all permutations of 1,…,8.
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Solution Representation (cont.)
By using such chromosome, we restrict the search to board configurations where horizontal constraint violation (two queens on the same column) and vertical constraint violation (two queens on the same row) do not occur.
The representation guarantees “half” number of the constraints and what remains to be minimized is the number of diagonal constraint violations.
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
• Penalty of one queen:the number of queens she can check.
• Penalty of a configuration: the sum of the penalties of all queens.
• Note: penalty is to be minimized
• Fitness of a configuration: inverse penalty to be maximized
8 Queens Problem: Fitness evaluation
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The 8 queens problem: Mutation
Small variation in one permutation, e.g.:• swapping values of two randomly chosen positions,
1 23 45 6 7 8 1 23 4 567 8
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The 8 queens problem: Recombination
Combining two permutations into two new permutations:• choose random crossover point• copy first parts into children• create second part by inserting values from other parent:
• in the order they appear there • beginning after crossover point• skipping values already in child
8 7 6 42 5311 3 5 24 678
8 7 6 45 1231 3 5 62 874
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Parent selection:– Pick 5 parents and take best two to undergo crossover
Survivor selection (replacement)– When inserting a new child into the population, choose
an existing member to replace by: sorting the whole population by decreasing fitness enumerating this list from high to low replacing the first with a fitness lower than the given child
– Usually survivor selection: (replace worst) after merging the population and offsprings, then ranks them according to fitness and deletes the worst two.
The 8 queens problem: Selection
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
8 Queens Problem: summary
Note that is is only one possible set of choices of operators and parameters
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most useful items.
Example: 0-1-KNAPSACK problem
http://www.nils-haldenwang.de/computer-science/computational-intelligence/genetic-algorithm-vs-0-1-knapsack
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
0-1 Knapsack problem with Greedy Algorithm
A greedy algorithm obtains an optimal solution to a problem by making a sequence of choices. At each decision point, the algorithm chooses the locally optimal solution. In other words, when we are considering which choice to make, we make the choice that looks best in the current situation, without considering results from subproblems.
This is called the 0-1 knapsack problem because each item must be taken in its entirely. If we use a greedy strategy to solve this problem, we would take the objects in order of their benefit/weight value.
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
The Greedy method does not work for the 0-1 Knapsack Problem.
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Knapsack Problem: summary
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Knapsack Problem: Implementation question
From the viewpoint of programming language, how can you create/represent individuals and the population to manipulate them?
i.e. an individual could be a bit, byte, int, char, ..., and the population is a vector, matrix, structure, etc.? Justify your answer.
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Knapsack Problem: individual / population
public void initPopulation() {
population = new string[Configuration.population_size];
for (int i = 0; i < Configuration.population_size; i++) {
string currentGenome = getRandomBitStream();
population[i] = currentGenome;
} }
public string getRandomBitStream() {
string genome = "";
for (int i = 0; i < itemsNr; i++) {
string randomGene = "";
randomGene = random_gene.Next(2).ToString();
genome += randomGene; }
return genome; }
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Typical behaviour of an EA
Early phase:
quasi-random population distribution
Mid-phase:
population arranged around/on hills
Late phase:
population concentrated on high hills
Phases in optimising on a 1-dimensional fitness landscape
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Example with two traits
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Typical run: progression of fitness
Typical run of an EA shows so-called “anytime behavior”
Bes
t fit
ness
in p
opul
atio
n
Time (number of generations)
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Hypervolume comparison in MOEA problems
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Hypervolume definition
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Be
st fi
tne
ss in
po
pula
tion
Time (number of generations)
Progress in 1st half
Progress in 2nd half
Are long runs beneficial?
• Answer: - it depends how much you want the last bit of progress - it may be better to do more shorter runs
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
T: time needed to reach level F after random initialisation
TTime (number of generations)
Be
st fi
tne
ss in
po
pula
tion
F: fitness after smart initialisationF
Is it worth expending effort on smart initialisation?
• Answer : it depends: - possibly, if good solutions/methods exist.- care is needed, see chapter on hybridisation
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Evolutionary Algorithms in Context
There are many views on the use of EAs as robust problem solving tools
For most problems a problem-specific tool may:– perform better than a generic search algorithm on
most instances, – have limited utility, – not do well on all instances
Goal is to provide robust tools that provide:– evenly good performance – over a range of problems and instances
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Scale of “all” problems
Per
form
ance
of
met
hods
on
prob
lem
s
Random search
Special, problem tailored method
Evolutionary algorithm
EAs as problem solvers: Goldberg’s 1989 view
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
EAs and domain knowledge
Trend in the 90’s:
adding problem specific knowledge to EAs
(special variation operators, repair, etc) Result: EA performance curve “deformation”:
– better on problems of the given type– worse on problems different from given type– amount of added knowledge is variable
Recent theory suggests the search for an “all-purpose” algorithm may be fruitless
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
Scale of “all” problems
P
Michalewicz’ 1996 viewP
erfo
rman
ce o
f m
etho
ds o
n pr
oble
ms
EA 1
EA 4
EA 3EA 2
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
EC and Global Optimisation
Global Optimisation: search for finding best solution x*
out of some fixed set S Deterministic approaches
– e.g. box decomposition (branch and bound etc)– Guarantee to find x* , but may run in super-
polynomial time Heuristic Approaches (generate and test)
– rules for deciding which x S to generate next– no guarantees that best solutions found are globally
optimal
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
A.E. Eiben and J.E. Smith, Introduction to Evolutionary ComputingWhat is an Evolutionary Algorithm?
EC and Neighbourhood Search
Many heuristics impose a neighbourhood structure on S
Such heuristics may guarantee that best point found is locally optimal e.g. Hill-Climbers: – But problems often exhibit many local optima – Often very quick to identify good solutions
EAs are distinguished by:– Use of population,– Use of multiple, stochastic search operators – Especially variation operators with arity >1– Stochastic selection
Recommended