Presentation is loading. Please wait.

Presentation is loading. Please wait.

Crossovers and Mutation Richard P. Simpson. Genotype vs. Phenotype The genotype of a chromosome is just the basic data structure (it bits in a binary.

Similar presentations


Presentation on theme: "Crossovers and Mutation Richard P. Simpson. Genotype vs. Phenotype The genotype of a chromosome is just the basic data structure (it bits in a binary."— Presentation transcript:

1 Crossovers and Mutation Richard P. Simpson

2 Genotype vs. Phenotype The genotype of a chromosome is just the basic data structure (it bits in a binary chromosome) The Phenotype is the object that the chromosome represents. For example the bit pattern 10110111011101 could be used to represent a particular polygon such as The polygon is the phenotype and the binary pattern is the genotype. (think in terms of yourself).

3 Crossover and Mutations 10110111011101  mutate 101010111011011 

4 1 Point Binary Crossover Choose a random point on the two parents Split parents at this crossover point Create children by exchanging tails P c typically in range (0.6, 0.9)

5 Performance with 1 point binary crossover more likely to keep together genes that are near each other Can never keep together genes from opposite ends of string This is known as Positional Bias Can be exploited if we know about the structure of our problem, but this is not usually the case

6 n-point binary crossover Choose n random crossover points Split along those points Glue parts, alternating between parents Generalisation of 1 point (still some positional bias)

7 Uniform Binary Crossover 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 Inheritance is independent of position

8 Binary Mutation Alter each gene independently with a probability p m p m is called the mutation rate Typically a small number between 1/pop_size and 1/ chromosome_length.

9 Crossover OR mutation? What effect does each of these have on the evolution process. See paper Crossover or Mutation by William M. Spears See Genetic Algorithms:The crossover- mutation Debate by Nuwan Senaratna, 2005 GA operator roles: disruption and construction. Generally mutation causes more disruption and crossover causes more construction.

10 Disruption vs. Construction on a landscape Disruption (exploration) is  individual  Construction (exploitation) climbs the hills! Of course what actually happens depends on the problem and its method of chromosome coding. IE Use both.

11 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

12 Representations other than binary Gray coding of integers (still binary chromosomes) Gray coding is a mapping that means that small changes in the genotype cause small changes in the phenotype (unlike binary coding). “Smoother” genotype-phenotype mapping makes life easier for the GA Nowadays it is generally accepted that it is better to encode numerical variables directly as Integers Floating point variables

13 Gray Codes When you count up or down in binary, the number of bit that change with each digit change varies. From 0 to 1 just have a single but From 1 to 2 have 2 bits, a 1 to 0 transition and a 0 to 1 transition From 7 to 8 have 3 bits changing back to 0 and 1 bit changing to a 1 For some applications multiple bit changes cause significant problems.

14 Gray Code Contrast of bit changes ValBinChgGrayChg 0 000000 1 00110011 2 01020111 3 01110101 4 10031101 5 10111111 6 11021011 7 11111001 0 00030001

15 Integer representations Some problems naturally have integer variables, e.g. image processing parameters Others take categorical values from a fixed set e.g. {blue, green, yellow, pink} N-point / uniform crossover operators work Extend bit-flipping mutation to make “creep” i.e. more likely to move to similar value Random choice (esp. categorical variables) For ordinal problems, it is hard to know correct range for creep, so often use two mutation operators in tandem

16 Integer example There is a well known class of math problems called Diophantine equations. These are multivariate equations where the solutions are require to be integer. For example Assume we want three integers x,y,z such that 0 = 2x – 3y 2 – 4z OR we get as close as we can to zero! In a GA that searches for these guys we have chromosomes that look like XYZ

17 0 = 2x – 3y 2 – 4z Possible Fitness function Fitness(x,y,z)=|2x – 3y 2 – 4z| Possible Crossover one point crossover, between variables Possible Mutator using random deviate d. pick a random gene X,Y or Z and change it with low probability. Maybe vary it slightly X = X +/- d for some d ?! What happens if d is small? Large?

18 Real Coded Genetic Algorithms In this type of GA a chromosome is usually an array of floating point values. It is often applied to optimize some real valued function. Mutations are probabilistically performed on a real value by adding a random deviate in some range from –d to +d. One can select this deviation from a Gaussian (normal) distribution or from a uniform distribution (see rand()).

19 Normal Distribution about 0 http://www.cplusplus.com/reference/random/normal_distribution/

20 De Jong’s classical test functions A lot of test functions can be found here http://www.sfu.ca/~ssurjano/optimization.html

21 Real Crossovers There are a lot of options here The obvious n point crossovers where each allele value in offspring z comes from one of its parents (x,y) with equal probability Intermediate (a blending scheme) exploits idea of creating children “between” parents (hence a.k.a. arithmetic recombination) z i =  x i + (1 -  ) y i where  : 0    1. The parameter  can be: constant: uniform arithmetical crossover variable (e.g. depend on the age of the population) picked at random every time

22 Do it for a single gene Parents:  x 1,…,x n  and  y 1,…,y n  Pick a single gene (k) at random, (or more!) child 1 is: reverse for other child. e.g. with  = 0.5

23 Simple arithmetic crossover Parents:  x 1,…,x n  and  y 1,…,y n  Pick random gene (k) after this point mix values. The child 1 is: reverse for other child. e.g. with  = 0.5 What if  =0 ?

24 Permutations Chromosomes 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

25 Permutations Mutations if every chromosome is a permutation of a set, say {1,2,…,n} then a mutation must generate another mutation. The mutation operator must be applied to the entire genome.

26 Two simple mutation schemes Pick two allele 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 Pick two alleles at random and swap their positions Preserves most of adjacency information (4 links broken), disrupts order more

27 Inversion and Scramble Mutations (inversion) 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 (scramble) Pick a subset of genes at random Randomly rearrange the alleles in those positions

28 Crossover operators for Perms Partially mapped crossover (PMX) Order crossover (X) Uniform order crossover Edge recombination There are many other that we will not discuss.

29 Partially Mapped Crossover Given two parents s and t, PMX randomly picks two crossover points. The child is constructed in the following way. Starting with a copy of s, the positions between the crossover points are, one by one, set to the values of t in these positions. This is performs by applying a swap to s. The swap is defined by the corresponding values in s and t within the selected region.

30 PMX example 6234175 6234175 62314756241375 752413767 6234175762413757 62341757524137676234175752413767 For the second offspring just swap the parents and apply the same operation First offspring No change

31 Order Crossover This crossover first determines to crossover points. It then copies the segment between them from one of the parents into the child. The remaining alleles are copied into the child (l to r) in the order that they occur in the other parents. Switching the roles of the parents will generate the other child.

32 Order Crossover Example 123456789 347289165 4567 The remaining alleles are 1 2 3 8 9. Their order in the other parent is 3 2 8 9 1 328456791 347289165

33 Uniform Order Crossover Here a randomly-generated binary mask is used to define the elements to be taken from that parent. The only difference between this and order crossover is that these elements in order crossover are contiguous. 123456789 347289165 110100010123479685 offspring

34 Edge Recombination This operator was specially designed for the TSP problem. This scheme ensures that every edge (link) in the child was shared with one or other of its parents. This has been shown to be very effective in TSP applications. Constructs an edge map, which for each site lists the edges available to it from the two parents that involve that city. Mark edges that occur in both with a +.

35 Inversion Transformations This scheme will allow normal crossover and mutation to operate as usual. In order to accomplish this we map the permutation space to a set of contiguous vectors. Given a permutation of the set {1,2,3,…,N} let a j denote the number of integers in the permutation which precede j but are greater than j. The sequence a 1,a 2,a 3,…,a n is called the inversion sequence of the permutation. The inversion sequence of 6 2 3 4 1 7 6 is 4 1 1 1 2 0 0 There are 4 integers greater than 1

36 Inversion of Permutations The inversion sequence of a permutation is unique! Hence there is a 1-1 correspondence between permutations and their inversion sequence. Also the right most inv number is 0 so dropped. 1 1 22 1 1 2 31 3 23 1 23 2 12 3 12 1 3 0 1 2 0 1 x (0 0) (0 1) (1 1) (2 1) (2 0) (1 0) y

37 Inversions Continued What does a 4 digit permutation map to? 1234 -> (0 0 0) 2134 -> (1 0 0) 4321 -> (3 2 1) 2413 -> (2 0 1) 1423 -> (0 1 1) etc Maps to a partial 3D lattice structure

38 Converting Perm to Inv Input perm: array of permutation Output: inv: array holding inv sequence For (i=1;i<=N;i++){ inv[i]=0; m=1; while(perm[m]<>i){ if (perm[m]>i )then inv[i]++; m++; }

39 Convert inv to Perm Input: inv[] Output: perm[] For(i=1;i<=N;i++){ for(m=i+1;m<=N;m++) if (pos[m]>=inv[i]+1)pos[m]++; pos[i]=omv[i]+1; } For(i=1;i<=N;i++) perm[i]=i;


Download ppt "Crossovers and Mutation Richard P. Simpson. Genotype vs. Phenotype The genotype of a chromosome is just the basic data structure (it bits in a binary."

Similar presentations


Ads by Google