GA Lec5 Operators Selection Replacement
GA Lec5 Operators Selection Replacement
Various Operators
Sabah Sayed
Department of Computer Science
Faculty of Computers and Artificial Intelligence
Cairo University
Egypt
3/8/2024 1
Remember: Mechanism Of GAs
Begin
Initialize population
T =0
Evaluate Solutions
Optimum N
Solution?
Selection
Y
Mutation
Replacement
2
Various Strategies for the Genetic Operators
t t w w Dictionary
h h o o
r f r f
e s e s
s . . . e . . s . . . . e
Chr 1 Chr N
English Word Generation Example
Problem: Generate valid English word of Objective fn
length 5 characters
Mutation
t t w w Dictionary
h h o o
r e r f
e s d s
s . . . e . . s . . . . e
Chr 1 Chr N
Integer Representation
• Some problems naturally have integer variables,
e.g. image processing parameters
3/8/2024 7
Uniform Crossover for Integers
• Assign 'heads' to one parent, 'tails' to the other
• Flip a coin for each gene of the first child
• Make an inverse copy of the gene for the second
child
• Example:
8
Uniform Crossover for Integers
• Inheritance is independent of position
• Applicable for binary representation
• How to implement it (programming)
• N-point crossover ???
3/8/2024 9
Permutation Representations
• Ordering/sequencing problems form a special type
• Task is (or can be solved by) arranging some objects
in a certain order
– Example: sort algorithm: important thing is which
elements occur before others (order)
– Example: Travelling Salesman Problem (TSP) : important
thing is which elements occur next to each other
(adjacency)
• These problems are generally expressed as a
permutation:
– if there are n variables then the representation is as a list
of n integers, each of which occurs exactly once
3/8/2024 10
Crossover for Permutations
• Normal crossover operators will often lead to
inadmissible solutions
12345 12321
54321 54345
3/8/2024 11
Mutation operators for permutations
3/8/2024 12
Insert Mutation for permutations
• Pick two allele (gene) values at random
• Move the second to follow the first, shifting
the rest along to accommodate
• Note that this preserves most of the order and
the adjacency information
3/8/2024 13
Swap mutation for permutations
• Pick two alleles (genes) at random and swap
their positions
• Preserves most of adjacency information (4
links broken)
• disrupts order more
3/8/2024 14
Inversion mutation for permutations
• Pick two alleles at random and then invert the
substring between them.
• Preserves most adjacency information (only
breaks two links) but disruptive of order
information
3/8/2024
Floating-point (real values) Representation
• Many problems occur as real valued problems, e.g.
continuous parameter optimization f : n →
3/8/2024 16
Crossover over FP Chromosomes
3/8/2024 17
Mutation over FP Chromosomes
• General scheme of floating point mutations
x = x1 , ..., xl → x = x1, ..., xl
xi , xi LBi ,UBi
3/8/2024 18
Uniform FP Mutation
xi drawn randomly (uniform) from LBi ,UBi
x1 x2 … xi … xm-1 xm
x1 x2 … xi … xm-1 xm
– At t=0:
∆(t,y) = Maximum value of mutation
– At t=T:
∆(t,y) = 0 (No mutation)
3/8/2024 21
Crossover or Mutation?
• Decades of long debate: which one is better or
necessary?
3/8/2024
Crossover
• It greatly accelerates search early in evolution
of a population
• It leads to effective combination of schemata
(subsolutions on different chromosomes)
3/8/2024
Crossover or Mutation?
✓ Exploration: Discovering promising areas in the search space,
i.e. gaining information on the problem
✓ Exploitation: Optimising within a promising area, i.e. using
information
There is co-operation AND competition between them
• Crossover is explorative: it makes a big jump to an area
somewhere “in between” two (parent) areas
• Mutation is exploitative: it creates random small diversions,
thereby staying near (in the area of ) the parent
Crossover OR mutation?
• Only crossover can combine information from two parents
• Only mutation can introduce new information (alleles)
• Crossover does not change the allele frequencies of the
population (thought experiment: 50% 0’s on first bit in the
population, ?% after performing n crossovers)
• To hit the optimum you often need a ‘lucky’ mutation