Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithms Permutation crossovers

Similar presentations


Presentation on theme: "Genetic Algorithms Permutation crossovers"— Presentation transcript:

1 Genetic Algorithms Permutation crossovers
A technique for those who do not know how to solve the problem!

2 Permutation Crossovers
Required for TSP, POOL BALL etc Required for Decoding messages etc Random crossover of two permutations seldom result in another permutation A permutation space is N! in size. SO!

3 Categories of Perm. Crossovers
Disqualification Just kill the bad chromosomes. Why is this bad? Repairing Invalid chromosomes are fixed. Inventing Specialized Operators Crossovers generate only legal permutations Transformation Transform permutation space into a vector space and cross in vector space.

4 Permutation Operators
Partially mapped crossover (PMX) Order crossover (X) Uniform order crossover Edge recombination There are many other that we will not discuss.

5 Partially Mapped Crossover (Goldbert & Lingle, 1985)
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.

6 PMX example For the second offspring just swap the parents
No change 6 2 3 4 1 7 5 6 2 3 1 4 7 5 6 2 4 1 3 7 5 6 5 2 2 4 3 4 1 1 3 7 7 7 7 5 6 6 5 2 2 3 4 4 1 1 3 7 7 7 7 6 5 5 6 2 2 4 3 1 4 3 1 7 7 7 7 6 5 First offspring 6 6 2 2 4 3 1 4 1 3 7 7 7 7 5 5 For the second offspring just swap the parents and apply the same operation

7 Order Crossover (Davis 1985)
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.

8 Order Crossover Example
1 2 3 4 5 6 7 8 9 4 5 6 7 3 4 7 2 8 9 1 6 5 The remaining alleles are Their order in the other parent is 3 4 7 2 8 9 1 6 5 3 2 8 4 5 6 7 9 1

9 Uniform Order Crossover (Davis 1991)
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. 1 2 3 4 5 6 7 8 9 1 1 1 1 1 2 3 4 7 9 6 8 5 3 4 7 2 8 9 1 6 5 offspring

10 Edge Recombination (Whitley Starkweather Fuquay 1989 )
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 +.

11 Example Edge Table g d m h b j f i a k e c c e k a g b h i j f m d
a: +k, g ,i g: a, b, c, d b: +h,g,i h: +b, i, m c: +3, d, g i: h, j, a, f d: +m, g, c j: +f, i, b e: +k, +c k: +e, +a f: +j, m, i m: +d, f, h

12 Edge Recombination Algorithm
Pick a city at random Set current_city to this city. Remove reference to current_city form table. Examine list for current_city: If there is a common entry(+) pick that Else pick entry which has the shortest list Split ties randomly If stuck (list is empty), start from other end, or else pick a new city at random.

13 Example Continued Randomly pick a, delete all a’s from table [a]
Select k (common neighbor) [ak] Select e (only item in k’s list) [ake] Select c (only item in e’s list) [akec] d or g: pick d at random [akecd] Select m (common edge with d) [akecdm] f or h: pick h at random [akecdmh] Select b ( common edge) [akecdmhb] Select g (shortest list -0) [akecdmhbg] g has empty list so reverse direction [gbhmdcdka] Select i (only item in a’s list) [gbhmdcdkai] Select f at random, then j [gbhmdcekaifj]

14 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 aj denote the number of integers in the permutation which precede j but are greater than j. The sequence a1,a2,a3,…,an is called the inversion sequence of the permutation. The inversion sequence of is There are 4 integers greater than 1

15 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. y 1 1 2 2 1 1 1 2 3 1 3 2 3 1 2 3 2 1 2 3 1 2 1 3 x (0 0) (0 1) (1 1) (2 1) (2 0) (1 0)

16 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

17 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++; }

18 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;

19 So what do we do? Our population is of course a set of permutations.
These permutations are each mapped to their inv to create a population of inv’s say We do normal crossovers in this mapped population as well as normal mutations. In order to determine fitness we of course must apply Fitness(Inverse(inv)) Is this all worth doing?

20 Mutations of Permutations
Swap Mutation Scramble Mutation 2-Swap Insert These will maintain legal permutations

21 Swap Mutation Select two positions at random and swap the allele values at those positions. Sometimes called the “order-based” mutation. ABCDEFGJ => AECDBFGJ

22 Scramble Mutation Pick a subset of positions at random and reorder their contents randomly Some research has shown swap is best and others have shown scramble is best in certain apps. Who knows? ABCDEFGH => AHFDECGB

23 Other Permutation Mutations
2-Swap (nice for TSP) Pick two point and invert subtour AB.CDEF.GH => AB.FEDC.GH Insert Mutation Pick a value at random (say E), insert into another (rand chosen position, say B) and shift the rest over ABCDEFG => AEBCDFG

24 How about code breaking
Assume that we have the 26 letters of the alphabet permutated. This permutation is used to encode a normal message. How do we decode this using a GA? Is this even a good idea? What is the fitness function?


Download ppt "Genetic Algorithms Permutation crossovers"

Similar presentations


Ads by Google