0% found this document useful (0 votes)
37 views24 pages

Biologically Inspired Computing: Operators For Evolutionary Algorithms

This document provides information on genetic operators for evolutionary algorithms. It discusses various mutation and crossover operators that can be used for different types of encodings, including k-ary encodings (where solutions are represented as lists of numbers) and order-based encodings (where solutions are permutations). Common mutation operators include single-gene mutation, swap mutation, and inversion mutation. Common crossover operators include one-point crossover, uniform crossover, and various order-based crossover techniques. The document provides examples to illustrate how each operator works.

Uploaded by

kulkarnigopal20
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views24 pages

Biologically Inspired Computing: Operators For Evolutionary Algorithms

This document provides information on genetic operators for evolutionary algorithms. It discusses various mutation and crossover operators that can be used for different types of encodings, including k-ary encodings (where solutions are represented as lists of numbers) and order-based encodings (where solutions are permutations). Common mutation operators include single-gene mutation, swap mutation, and inversion mutation. Common crossover operators include one-point crossover, uniform crossover, and various order-based crossover techniques. The document provides examples to illustrate how each operator works.

Uploaded by

kulkarnigopal20
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Biologically Inspired Computing:

Operators for Evolutionary


Algorithms
This is additional material for week 3 of
`Biologically Inspired Computing’
Contents:
Some basic operators
How to think of genetic operators
Selection represents our strategy for deciding
which areas of the search space to focus our
efforts on.
Operators provide our means of generating new
candidate solutions.
– We want operators to have a fair chance of yielding
good new solutions (small change, and/or combine bits
from solutions we already know are good)
– We also (obviously) want to be able to potentially
explore the whole space.
Genetic Operators / Variation Methods

Often we have used a k-ary encoding, in which a


candidate solution is just a list of L numbers, each
of which can be anything from 0 to k-1 (or 1 to k).
E.g. our simple bin-packing representation uses a k-
ary encoding. So, for 100 items and 5 bins, this
would be a 5-ary encoding of length L=100.
These might be candidate solutions from a k-ary
encoding with L = 10 and k = 20:
[17, 2, 19, 1, 1, 1, 5, 11, 12, 2]
[16, 19, 2, 19, 2, 3, 4, 7, 5, 2]
Mutation in k-ary encodings
Single-gene new-allele mutation:
Choose a gene at random, and change it to a random new
value. E.g. 352872  312872
M-random-gene new-allele mutation:
(Isn’t it obvious?)
Repeat the above M times. For example, in a
1000-gene problem, we might use 5-gene
mutation. This will result in anything from 1 to
5 new gene values.
Mutation in k-ary encodings
Single-gene random-allele mutation:
Choose a gene at random, and change it to a random value. This
is the same as single-gene new-allele mutation, except that it
doesn’t take care to make sure we have a new value for the
gene. So, often (especially if k is small) it will lead to no
change at all. But that’s not a problem – in the EA context, it
means that the next generation contains an extra copy of an
individual that survived selection (so is probably quite good),
and in fact it might not be in the new population otherwise.
M-distinct-gene new-allele mutation:
Same as M-random-gene, but making sure that M
different genes are changed.
Genewise mutation with strength m;
Go through the solution gene by gene, and mutate
every one of them with probability m. E.g. if L =
100 we might use m = 0.01 – usually, just one
gene will get changed, but possibly none, and
possibly 2 or more. There is even a tiny chance of
all of them being changed.
Single-gene mutation:
Choose a gene at random, and add a small random deviation to it.
Often chosen from a Gaussian distribution.
Vector mutation:
Generate a small random vector of length L, and add it to the whole
thing.
Crossover in k-ary encodings
One-Point Crossover.
For encodings of length L, one point crossover
works as follows:
1. Choose a crossover point k randomly (a number
from 1 to L-1)
2. The first k genes of the child will be the same as
the first k genes of parent 1
3. The genes of the child from gene k+1 onwards
will be the same as those of parent 2.
Crossover in k-ary encodings
Two-Point Crossover.
For encodings of length L, two point crossover works as
follows:
1. Choose two crossover points j and k randomly, making
sure that 1 <= j < k < L
2. Genes 1 to j of the child will be the same as genes 1 to j
of parent 1;
3. genes j+1 to k of the child will be the same as genes j to
k of parent 2.
4. the remainder of the child will be the same as parent 1.
1-point example:
Parent1: 1, 3, 4, 3, 6, 1, 3, 6, 7, 3, 1, 4
Parent2: 3, 5, 2, 6, 7, 1, 2, 5, 4, 2, 2, 8
Random choice of k = 6
Child: 1, 3, 4, 3, 6, 1, 2, 5, 4, 2, 2, 8

2-point example:
Parent1: 1, 3, 4, 3, 6, 1, 3, 6, 7, 3, 1, 4
Parent2: 3, 5, 2, 6, 7, 1, 2, 5, 4, 2, 2, 8
Random choices: j = 3, k = 10
Child: 1, 3, 4, 6, 7, 1, 2, 5, 4, 2, 1, 4
Crossover in k-ary encodings
Uniform Crossover.
For encodings of length L, Uniform crossover works as follows:
For each gene i from 1 to L
Let c = 1 or 2, with equal probability.
Make Gene i of the child the same as gene i of Parent c

In other words, we simply create the child one gene at a time,


flipping a coin each time to decide which parent to take the
gene from.
Uniform crossover example:
Parent1: 1, 3, 4, 3, 6, 1, 3, 6, 7, 3, 1, 4
Parent2: 3, 5, 2, 6, 7, 1, 2, 5, 4, 2, 2, 8
If our random choices in order were:
121221121221
the child would be:
Child: 1, 5, 4, 6, 7, 1, 3, 5, 7, 2, 2, 4
Operators in order-based encodings

Often, our chosen encoding for a problem will


be a permutation. This is the usual encoding
for problems such as the travelling
salesperson problem, and many others (as
we will see in a later lecture).
Clearly, k-ary encoding operators are invalid
in this case. The following slides show
common operators that can be used.
Mutation in order-based encodings
In all examples we will assume our encoding is a
permutation of L items, where L = 10.

swap mutation is simply this:


Choose randomly two distinct genes, i and j, and
then swap the genes at these positions.

Adjacent-swap mutation is simply this:


Choose any gene j randomly, then swap it with gene
j+1 (modulo L).
Swap mutation example:
Parent: A C J I B D E G H F
Random choices: i = 3; j = 7
Child: A C E I B D J G H F

Adjacent-swap mutation example


Parent: A C J I B D E G H F
Random choice: j = 8
Child: A C J I B D E H G F
Mutation in order-based encodings

k-Inversion-mutation:
Choose a random chunk of the parent of size
k. That is, choose a random gene j from 1 to
L, and the chunk is the section from genes j
to j+k-1 (modulo L) inclusive. Reverse the
genes in this chunk.
(note: when k = 2, what is this identical to?)
Example of k-Inversion mutation
Here is 3-inversion mutation applied to:
ABDGFCE
Choose a random chunk of size 3:
ABDGFCE
Reverse the genes in this chunk:
AGDBFCE
Mutation in order-based encodings

Variable-k-Inversion-mutation:
Choose k randomly between 2 and L.
Then do a k-inversion mutation.
k-inversion examples.
4-inversion mutation:
Parent: A C J I B D E G H F
Random choice of j = 1
Child: I J C A B D E G H F

Variable-k mutation:
Parent: A C J I B D E G H F
Random choices: k = 7; j = 7
Child: H G E I B D J C A F
(make sure you understand this one)
Crossover in order-based encodings

There are various sensible ways to produce a


valid child that combines aspects of two
different permutation parents. What might
be best depends very much on the
application. We will describe two generic
order based operators, but others will come
up in later lectures looking at particular
applications.
k-gene Order-based Crossover
Works like this:
First, make the child a copy of parent 1.
Next, randomly choose k distinct genes of the child.
Next, reorder the values of these genes so that they
match their order in parent 2.

Naturally, there is also an operator that we can call:


Variable-k-order based crossover. I will leave you
to work out what that is.
4-gene order based crossover example.

Parent 1: A C J I B D E G H F
Parent 2: F E A I H J D B C G
Random choices of 4 distinct genes: 2, 5, 6, 9
Child is initially same as parent 1 – shown here with the
random choices highlighted:
Child: A C J I B D E G H F
The order of these four gene values in Parent 2 is: H, D, B, C
So, we impose that ordering on the child, but keeping them in
the same positions:
Child: A H J I D B E G C F
k-gene Position-based Crossover
Works like this:
First, make the child a copy of parent 1.
Next, randomly choose k distinct gene positions of the child.
Let V be the set of gene values at these positions.
Next, copy the genes of parent 2 that are not in V into the
child, overwriting the child’s other genes, in their parent 2
order.
Naturally, there is also an operator that we can call: Variable-
k-position based crossover. I will leave you to work out
what that is.
An example is rather necessary in this case – all should
become clear after the next slide.
4-gene position based crossover example.

Parent 1: A C J I B D E G H F
Parent 2: F E A I H J D B C G
Random choices of 4 distinct positions: 2, 5, 6, 9
Child is initially same as parent 1 – shown here with the random
positions highlighted:
Child: A C J I B D E G H F
Now let’s blank out all of the other genes:
Child: * C * * B D * * H *
We proceed by filling the child up with its missing genes, in the
order they appear in Parent 2: This order is: F E A I J G. So the
child becomes:
Child: F C E A B D I J H G
Quiz Questions week 3
7. Suppose a chromosome for your problem is a permutation of 10 items. What
is the neighbourhood size of 3-inversion mutation?

8. Suppose you are trying to evolve a football tram, so you want the best
possible choice of 11 players from a squad of 22 players. You are given a
very complex fitness function that works out a score, for any given set of
11 players, depending on how well they might work together as a team.
A possible encoding for this is to have a list of 22 binary numbers, where
each binary position indicates a specific player, and a “1” in that position
means they are selected. Invent a (very simple) algorithm to generate a
random initial population of P chromosomes for this problem.
9. For the same problem as question 8, explain (in each case) why these
would be either a suitable or unsuitable choice of operator for this
problem: (i) genewise mutation; (ii) swap mutation; (iii) uniform
crossover.

You might also like