100% found this document useful (1 vote)
152 views

Genetic Algorithms

Genetic algorithms are a technique for optimization based on Darwinian principles of natural selection and evolution. They work by initializing a population of random solutions, evaluating their fitness, selecting the best ones to reproduce via crossover and mutation to create a new generation, and repeating this process until an optimal solution emerges. For the traveling salesman problem, genetic algorithms use permutation encoding to represent solutions as orderings of cities, calculate their total distance as fitness, and apply genetic operators like crossover to evolve better routes over generations.

Uploaded by

sajinss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
152 views

Genetic Algorithms

Genetic algorithms are a technique for optimization based on Darwinian principles of natural selection and evolution. They work by initializing a population of random solutions, evaluating their fitness, selecting the best ones to reproduce via crossover and mutation to create a new generation, and repeating this process until an optimal solution emerges. For the traveling salesman problem, genetic algorithms use permutation encoding to represent solutions as orderings of cities, calculate their total distance as fitness, and apply genetic operators like crossover to evolve better routes over generations.

Uploaded by

sajinss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

Genetic Algorithms

GENETIC ALGORITHM
Introduced by Holland in 1975.
Adaptive heuristic search algorithm based
on evolutionary ideas of natural selection
and genetics.
More robust than conventional algorithms.
Do not break easily even if the inputs are
changed slightly or have reasonable noise.
INTRODUCTION
Genetic algorithms (GAs) are a technique to solve
problems which need optimization

GAs are good at taking larger, potentially huge,


search spaces and navigating them; looking for
optimal combinations of things and solutions which
we might not find in a life time.

GAs are a subclass of Evolutionary Computing

GAs are based on


Darwins theory of evolution- Natural selection and
survival of the fittest
Biological Background The cell

Every animal cell is a complex of many


small factories working together
Center of all this is cell nucleus
Nucleus contains genetic information
Biological Background Chromosomes
Genetic information is stored in the chromosomes
Each chromosome consists of strands of DNA
The chromosome is divided in parts: genes
Genes determines traits/properties of each
individual
The group of genes that represents
one property is called: allele
Every gene has an unique position
in the chromosome: locus
Biological Background Reproduction

Crossover:
Random exchange of parent's chromosomes during
reproduction resulting in:
offspring having some traits of each parent
Biological Background Reproduction

Mutation:
Rare occurrence of errors during the process of copying
chromosomes resulting in genetic variation

POSSIBILITIES
Changes that are nonsensical/
deadly producing organisms that
can't survive

Changes are beneficial producing


"stronger" organisms

Changes aren't harmful/deadly


but aren't beneficial producing
Biological Background Evolution

What is evolution?
Evolution is a gradual process of change in the
genetic composition of a population, as a result of
natural selection acting on genetic variation
among individuals

Basic Elements of an Evolutionary Process:

Reproduction with inheritance - Crossover


Genetic variation (usually produced by random
modifications) - Mutation
Natural selection (survival of the fittest) Select
the best, discard the rest
Biological Background Natural selection

In a competitive environment the fittest surviv


resulting in better organisms
individuals with better survival traits generall
survive for a longer period of time: survival of th
fittest
this provides a better chance for reproducing an
passing the successful traits on to offspring
over many generations the species improve sinc
better traits will out number weaker ones

Basic Principle
Select The Best, Discard The Rest
Biological Background An example of Natural selection

Giraffes have long necks.

Giraffes with slightly longer necks could feed on leaves


of higher branches when all lower ones had been
eaten off.
They had a better chance of survival.
Favorable characteristic propagated through
generations of giraffes.
Now, evolved species has long necks.

NOTE: Longer necks may have been a deviant


characteristic (mutation) initially but since it was
favorable, was propagated over generations. Now an
established trait.

So, some mutations are beneficial.


Biological Background Evolution through Natural selection

Initial Population Of Animals

Struggle For Existence-Survival Of the Fittest

Surviving Individuals Reproduce, Propagate Favorable


Characteristics

Millions Of Years

Evolved Species
(Favorable Characteristic Now A Trait Of Species)
Genetic Algorithms
Implement Optimization Strategies
by Simulating Evolution Of Species
through Natural Selection.
Genetic Algorithm Basic steps

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction-Crossover and Mutation

Replacement of the current population with the new one


GA for Traveling Salesman problem

The Traveling Salesman Problem (TSP)

Defined as:
We are given a set of cities and a symmetric distance
matrix that indicates the cost of travel from each city to
every other city.
The goal is to find the shortest circular tour, visiting
every city exactly once, so as to minimize the total travel
cost, which includes the cost of traveling from the last city
back to the first city.
GA for Traveling Salesman problem

Problem Complexity
Well known combinatorial optimization problem
Problem belongs to NP-Hard category
N city TSP has N! possible combinations
Consider a 5 city TSP
1

4 5
GA for Traveling Salesman problem

Distance/Cost Matrix For TSP

1 2 3 4 5

1 0

2 5 0

3 8 3 0

4 2 4 9 0

5 7 10 6 8 0
Genetic Algorithm Nature to Computer
Mapping

Nature Computer

Population Set of solutions.


Individual Solution to a problem.
Fitness Quality of a solution.
Chromosome Encoding for a Solution.
Gene Part of the encoding of a solution.
Reproduction Crossover
Genetic Algorithm Initial population
Starting with a subset of n randomly chosen
solutions from the search space (i.e.
chromosomes). This is the population
Each chromosome represents the encoding of a
randomly generated solution
Encoding scheme a GA operator
Binary encoding
Octal Encoding
Hexadecimal Encoding
Permutation encoding
Value encoding
Selection depends on problem nature
Genetic Algorithm Operator - Encoding

The process of representing the solution in the


form of a string that conveys the necessary
information.

Just as in a chromosome, each gene controls a particular


characteristic of the individual, similarly, each bit in the
string represents a characteristic of the solution.
Encoding Methods

Binary Encoding Most common method of encoding.


Chromosomes are strings of 1s and 0s and each position in the
chromosome represents a particular characteristic of the
problem.

Chromosome A 1011 0010 1100 1110 0101


Chromosome B 1111 1110 0000 0001 1111

Octal Encoding Encoding using octal numbers


Chromosome A 034617216
Chromosome B 15723314
Hexadecimal Encoding Encoding using hexa
decimal numbers
Chromosome A 9CE7
Chromosome B 3 D BA
Encoding Methods (contd..)

Permutation Encoding (Real number coding)


Useful in ordering problems such as the Traveling Salesman
Problem (TSP). Example. In TSP, every chromosome is a
string of numbers, each of which represents a city to be
visited.
Chromosome A 1 5 3 2 6 4 7 9 8
Chromosome B 8 5 6 7 2 3 1 4 9
Encoding Methods (contd..)

Value Encoding Used in problems where complicated


values, such as real numbers, are used and where binary
encoding would not suffice.
Good for some problems, but often necessary to develop some
specific crossover and mutation techniques for these
chromosomes.

Chromosome A 1.235 5.323 0.454 2.321 2.454


Chromosome B (back), (back), (right), (forward), (left)
GA for Traveling Salesman problem

Problem Encoding
The path [1 2 3 4 5 ] represents a path from 1 to 2,
2 to 3, 3 to 4, 4 to 5and finally from 5 to 1.
This is an example of Permutation Encoding as
the position of the elements determines the fitness
of the solution.

Fitness Evaluation
For a chromosome [1 2 3 4 5], the total cost of
travel or fitness will be calculated as shown below
Fitness = 5 + 3 +9 +8 +7 = 32
Since our objective is to Minimize the distance, the
lesser the total distance, the fitter the solution.
Genetic Algorithm Operator Fitness evaluation

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


GA for Traveling Salesman problem

Random generation of initial population Fitness After


Scaling
Population size=5 total distance (f) exp(-f*k
k=0.05
1 2 3 4 5 =32 =0.201
2 1 3 4 5 =40 =0.135
5 3 1 2 4 =31 =0.212

4 1 5 3 2 =22 =0.333

3 4 2 5 1 =38 =0.149
Fitness function

A fitness function quantifies the optimality


of a solution (chromosome) so that that
particular solution may be ranked against
all the other solutions.

A fitness value is assigned to each solution


depending on how close it actually is to
solving the problem.

Ideal fitness function correlates closely to


goal + quickly computable.
Fitness function Scaling mechanisms

The scaling mechanism are generally divided


into three categories as:

1.Linear Scaling: In this method the actual


chromosomes fitness is scaled as
fi = a * fi +b
where
fi :Scaled fitness value of a
chromosome
fi :Fitness value of a chromosome
a & b : parameters that are selected such that
the average fitness is mapped to itself and the
best fitness is increased by a desired multiple
of the average
Fitness function Scaling mechanisms

2. Power Law Scaling: In this method the initial


fitness is taken to some specific power as:
f i = fi k
where
k : A constant closer to one

3. Exponential Scaling: In this method the initial


fitness is scaled exponentially as:
fi= exp (fi*k)
where
k : A problem dependent constant
Genetic Algorithm Operator
Recombination/Selection

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


Recombination/Selection

The process that determines which solutions are


to be preserved and allowed to reproduce and
which ones deserve to die out.

The primary objective of the recombination


operator is to emphasize the good solutions and
eliminate the bad solutions in a population, while
keeping the population size constant.

Selects The Best, Discards The Rest.


Recombination/Selection

Process of choosing two parents from the


population for crossing

How many offspring from each parent


combination

Eliminate bad solutions from the population so


that multiple copies of good solutions can be
placed in the population.
Recombination/Selection

Selection techniques a GA operator


Proportionate Based Selection: picks out
individuals based upon their fitness values
relative to the fitness of other individuals in
the population
Ordinal based selection: Based on rank
within the population
Too strong selection - Sub-optimal, highly fit
individuals take over the population (reducing
diversity needed for change)
Too weak selection Too slow evolution
Recombination/Selection

Roulette wheel selection


Random Selection
Rank selection
Tournament selection
Stochastic Universal Sampling
Roulette wheel selection

Each current string in the population has a slot assigned


to it which is in proportion to its fitness.
We spin the weighted roulette wheel thus defined n times
(where n is the total number of solutions).
Each time Roulette Wheel stops, the string corresponding
to that slot is created.

Strings that are fitter are assigned a larger slot and hence
have a better chance of appearing in the new population.
Roulette wheel selection

A marble is thrown in the roulette wheel and the chromosome


where it stops is selected. Clearly, the chromosomes with bigger
fitness value will be selected more times.
This process can be described by the following algorithm.
1. [Sum] Calculate the sum of all chromosome fitnesses in
population - sum S.
2. [Select] Generate random number from the interval
(0,S) - r.
3. [Loop] Go through the population and sum the fitnesses
from 0 sum S.
When the sum S is greater then r, stop and return the
chromosome where you are. Of course, the step 1 is performed
Random Selection

Randomly selects a parent from the


population

More disruptive than Roulette wheel


selection
Rank selection
Rank selection ranks the population first and
then every chromosome receives fitness
value determined by this ranking.
The worst will have the fitness 1, the second
worst 2 etc. and the best will have fitness N
(number of chromosomes in population).
Select a pair of individuals at random, generate
random number R between 0 & 1. If R < r, choose
parent 1, else parent 2. ( r a parameter to be
tuned)
Select two individuals at random, individual
with higher fitness value becomes parent. Repeat
to find second parent.
Results in slow convergence, but prevents too
quick convergence
Tournament selection

As the name suggests tournaments are played


between N solutions (selected randomly) and
the better solution is chosen and placed in the
new generation.

The above process is repeated till all the


chromosomes for the new generation are selected
Stochastic Universal Sampling

Provides zero bias and minimum spread

Individuals are mapped to contiguous segments


of a line
Equally spaced N pointers are placed over the
line, to select N individuals
Position of Ist pointer determined by random
number in the range [0,1/N]
GA for Traveling Salesman problem

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


GA for Traveling Salesman problem

Initial Population Evaluation Iteration 1:


Generation Module New Population Generation Module
Selection
Random generation (Roulette wheel method)
of Fitness
c cp(c) Random Chromosome c Selected
Initial Population fit(c)
(pop_size=5) ps(c) = Number that satisfies
ps(c) rand() cp(c-1) rand() < cp(c)

1 1 2 3 4 5 0.201 0.195 0.195 0.734 4 1 5 3 2 (4)


2 2 1 3 4 5 0.135 0.131 0.326 0.053 1 2 3 4 5 (1)
3 5 3 1 2 4 0.212 0.205 0.531 0.999 3 4 2 5 1 (5)
4 4 1 5 3 2 0.333 0.323 0.854 0.418 5 3 1 2 4 (3)
5 3 4 2 5 1 0.149 0.146 1 0.616 4 1 5 3 2 (4)
Elitism

Elitism is a method which copies the best


chromosome to the new offspring population
before crossover and mutation.

When creating a new population by crossover


or mutation the best chromosome might be
lost.

Forces GAs to retain some number of the best


individuals at each generation.

Has been found that elitism significantly


improves performance.
Genetic Algorithm Operators Reproduction

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


Cross over

Random exchange of parent's chromosomes during


reproduction resulting in:
offspring having some traits of each parent
Genetic Algorithm Operator Crossover

It is the process in which two chromosomes


(strings) combine their genetic material (bits)
to produce a new offspring which possesses
both their characteristics.

Two strings are picked from the mating pool at


random to cross over.
Strings are selected from the population based
on crossover probability
Crossover probability (Pc): determines the
number of chromosomes subjected to crossover
The method chosen depends on the Encoding
Crossover methods

Single Point Crossover- A random point is


chosen on the individual chromosomes
(strings) and the genetic material is
exchanged at this point.

( | is the crossover point-generated randomly)


Chromosome1 11011 | 00100110110

Chromosome 2 11011 | 11000011110

Offspring 1 11011 | 11000011110

Offspring 2 11011 | 00100110110


Crossover methods

Two-Point Crossover- Two random points are


chosen on the individual chromosomes (strings)
and the genetic material is exchanged at these
points.

( | are the crossover points-generated randomly)


Chromosome1 11011 | 00100 | 110110

Chromosome 2 10101 | 11000 | 011110

Offspring 1 10101 | 00100 | 011110

Offspring 2 11011 | 11000 | 110110


Crossover methods

Two-Point Crossover- Head and Tail of one


chromosome can be passed together to
the offspring
Head and tail may contain good genetic
material
Multipoint Crossover (N-point crossover)
Adding more cut points reduces performance of
GA
Chromosome1 11011 | 00100 | 110110
But problem space may be searched more
thoroughly
Chromosome 2 10101 | 11000 | 011110

Offspring 1 10101 | 00100 | 011110

Offspring 2 11011 | 11000 | 110110


Crossover methods
Uniform Crossover- Each gene (bit) is selected
randomly from one of the corresponding genes of
the parent chromosomes, according to a random
generated binary mask
1 in mask, gene copied from parent 1 else from
parent 2
Offspring contain mixture of genes from each
parent
New mask generated for each pair of parents
PARENT I 10110011
PARENT I I 00011010
MASK 11010110
OFFSPRING I 10011010
OFFSPRING I I 00110011
Crossover methods
Three-Parent Crossover- Three parents are
randomly chosen
Each bit of the first parent is compared with the
bit of the second parent.
If both are the same, the bit is taken for the
offspring, otherwise bit from the third parent is
taken
PARENT I 11010001
PARENT I I 01101001
PARENT I I I 01101100
OFFSPRING 01101001
Crossover methods
Shuffle Crossover Similar to uniform crossover

Single cross over position is selected

Before variables are exchanged, they are


randomly shuffled in both parents
Removes positional bias
Crossover methods
Ordered Crossover- Ordered two point cross
over is used when the problem is order based.
Given two parent chromosomes, two random cross
over points are selected, partitioning them into
left, middle and right portions.
Child 1 inherits its left and right sections from
parent 1
Middle section is determined by the genes in the
middle section of parent 1 in the order in which
values appear in parent 2

PARENT I 4 2|1 3|6 5


PARENT I I 2 3|1 4|5 6
CHILD I 4 2 | 3 1| 6 5
CHILD I I 2 3|4 1|5 6
Crossover methods

Partially Mached Crossover (PMX)- used for


permutation encoded chromosomes.
T S P each city exactly once
Offspring receive full complement of genes
( | are the crossover points-generated randomly)

2
Genetic Algorithm Operator - Mutation

It is the process by which a string is deliberately


changed so as to maintain diversity in the population
set.

We saw in the giraffes example, that mutations could


be beneficial.

Prevents the algorithm to be trapped in a local


optimum & maintain diversity

Exploitation ( Intensification ) Vs
Exploration ( Diversification)
Mutation

After a crossover is performed, mutation takes


place.
Mutation is intended to prevent falling of all
solutions in the population into a local optimum
of the solved problem.
Mutation operation randomly changes the
offspring resulted from crossover.
The technique of mutation depends mainly on
the encoding of chromosomes.
In case of binary encoding we can switch a few
randomly chosen bits from 1 to 0 or from 0 to 1.
called Bit inversion (Bit Flipping)
Original offspring 1101111000011110
Mutated offspring 1100111000011110

NOTE: The number of bits to be inverted depends on the Mutation Probability.


Mutation

For permutation encoding following


methods are used
Swap operation (Interchanging)

Shift operation

Rotation operation
GA for Traveling Salesman problem

Random generation of initial population Fitness After


Scaling
Population size=5 total distance (f) exp(-f*k
k=0.05
1 2 3 4 5 =32 =0.201
2 1 3 4 5 =40 =0.135
5 3 1 2 4 =31 =0.212

4 1 5 3 2 =22 =0.333

3 4 2 5 1 =38 =0.149
GA for Traveling Salesman problem

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


GA for Traveling Salesman problem

Initial Population Evaluation Iteration 1:


Generation Module New Population Generation Module
Selection
Random generation (Roulette wheel method)
of Fitness
c cp(c) Random Chromosome c Selected
Initial Population fit(c)
(pop_size=5) ps(c) = Number that satisfies
ps(c) rand() cp(c-1) rand() < cp(c)

1 1 2 3 4 5 0.201 0.195 0.195 0.734 4 1 5 3 2 (4)


2 2 1 3 4 5 0.135 0.131 0.326 0.053 1 2 3 4 5 (1)
3 5 3 1 2 4 0.212 0.205 0.531 0.999 3 4 2 5 1 (5)
4 4 1 5 3 2 0.333 0.323 0.854 0.418 5 3 1 2 4 (3)
5 3 4 2 5 1 0.149 0.146 1 0.616 4 1 5 3 2 (4)
GA for Traveling Salesman problem
Iteration 1:
New Population Generation
Crossover Mutation Evaluation
(p_cross=0.9) (p_mut =0.05) Module

Chromosome c Selected Chromosomes


Chromosomes Chromosomes
that satisfies after Mutation
selected with After Crossover fitness
(swap operator)
cp(c-1) rand() < cp(c) cut point (PMX operator)
New Population

4 1 5 3 2 (2,4) 1 4 2 5 3 1 5 2 4 3 38

1 2 3 4 5 x 1 2 3 4 5 1 2 3 4 5 32

3 4 2 5 1 (2,4) 2 1 5 3 4 2 1 5 3 4 31

5 3 1 2 4 (3,4) 1 2 5 3 4 4 2 5 3 1 30

4 1 5 3 2 (3,4) 4 5 1 2 3 4 5 1 2 3 32

Pair 1 Pair 2
Parent 1 4 1 5 3 2 5 3 1 2 4
Parent 2 3 4 2 5 1 4 1 5 3 2
CROSSOVER (PMX)
Offspring 1 4 2 5 3 1 2 5 3 4
1
2 1 5 3 4 4 5 1 2 3
GA for Traveling Salesman problem

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


Genetic Algorithm Operator Termination
criterion

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one


Termination criterion

Process of selection, crossover and mutation are


repeated until termination criterion is reached
Commonly used criterion:
A maximum number of cycles/generations are
evaluated
Discovery of an optimal /near optimal solution
(precision > 0) Best individual
Convergence on a single or set of similar
solutions ( No change in fitness) for a specified
number of generations Worst individual fitness
less than a threshold
Elapsed Time a specified time or maximum
Genentic Algorithm Parameters

Population size:
Good population size is about 20-30,
However sometimes sizes 50-100 are reported as
the best.
Some research also shows, that the best population
size depends on the size of encoded string
(chromosomes).

Encoding:
Encoding depends on the problem and also on the
size of instance of the problem.

Selection:
Basic roulette wheel selection can be used, but
sometimes rank selection can be better.
Different selection schemes could be attempted for a
Genentic Algorithm Parameters

Crossover and mutation type:


Operators depend on the chosen encoding and on the
problem.

Crossover probability:
Crossover rate should be high generally, about 60%-
95%.

Mutation probability:
Mutation rate should be very low. Best rates seems to be about 5% -
15%.

Sensitivity analysis with different operators and


parameters should be done for selecting the best
operator/parameter
Constraints in Genentic Algorithm

Equality and Inequality relations of variables


Eg.
Maximize F(x) subject to g i (x) >= 0, i = 1,2,3,.,n

Transforming into unconstrained form using penalty


function :

Maximize F(x) + P [ g i (x) ] , i = 1,2,3,.,n

where penalty function and P penalty coefficient


GA for Traveling Salesman problem

Start

Initial population creation (randomly)

Fitness evaluation (of each chromosome)


yes
New generation

Terminate? Stop

no
Selection of individuals (proportional with fitness)

Reproduction (genetic operators)

Replacement of the current population with the new one

Apply LS/SAA/TS to improve each chromosome


Advantages of Genetic Algorithm

Global Search Method: GAs search for the function


optimum starting from a population of points -they can
climb many peaks in parallel, reducing the probability of
getting trapped in local minima
GAs are widely applicable-more robust and applicable to
a large range of problems-handling constraints, multimodal,
multiobjective, non-differentiable, non-continuous, NP-
complete problems
Low development costs- i.e. costs to adapt to new
problem spaces
Parallel computing
Conceptual simplicity
Limitations of Genetic Algorithm

No solid theoretical basis


Parameter turning is largely based on trial and error
No guarantee for finding optimal solutions within a
finite amount of time
Often computationally expensive
Some Applications of Genetic Algorithm

Domain Application Types


Control gas pipeline, pole balancing, missile evasion, pursuit

Design semiconductor layout, aircraft design, keyboard


configuration, communication networks
Scheduling manufacturing, facility scheduling, resource allocation

Robotics trajectory planning

Machine Learning designing neural networks, improving classification


algorithms, classifier systems
Signal Processing filter design

Game Playing poker, checkers, prisoners dilemma

Combinatorial set covering, travelling salesman, routing, bin packing,


graph colouring and partitioning
Optimization
Classification of Genetic Algorithm

Adaptive Genetic Algorithm


Hybrid Genetic Algorithm
Messy Genetic Algorithm
Parallel Genetic Algorithm
Independent sampling GA
Real Coded GA
Simple Genetic Algorithm

1: P Initial Population
2: Evaluate (P)
3: while (Termination Criterion not met) do
4: P Recombine (Select(P))
5: P Mutate (P)
6: P Evaluate (P")
7: P Replace (P U P")
8: end while
9: Output P
End

You might also like