Sei sulla pagina 1di 4

International Journal of Latest Research in Science and Technology Vol.1,Issue 2 :Page No.98-101 , July August (2012) http://www.mnkjournals.com/ijlrst.

htm

ISSN (Online):2278-5299

A Comparative Analysis of PMX, CX and OX Crossover operators for solving Travelling Salesman Problem
1

Naveen kumar,2Karambir,3Rajiv Kumar

1,2

Computer Science and Engineering Department, Kurukshetra University/University Institute of Engineering and Technology/ Kurukshetra , Haryana,India 3 Research Scholar, Department of Computer Science Kurukshtra University,Haryana,India 1 naveensaini85@gmail.com 2 bidhankarambir@rediffmail.com 3 rajiv.gill1@gmail.com

Abstract - A very famous known NP-hard problem is Travelling Salesman problem. A number of new solutions are demanded by this problem so that it can be solved in small amount of time. Genetic Algorithm is one of the best methods which are used to solve various NP-hard problems such as TSP. A number of crossover operators have been proposed for TSP problem. This paper represents the comparative analysis of the PMX, CX and OX operators. Experimental results shows that the PMX crossover operator is best among the above three mentioned crossover operators as it find the shortest path, which is best among the three. Keywords - TSP, NP- hard, Genetic Algorithm, Mutation, Selection, Crossover, PMX, CX, OX. I. INTRODUCTION Genetic Algorithm (GA) is an approximate and optimizing algorithm which is based on the biological evolution process to find the shortest tour in short instant of time. Crossover operators are the backbone of a genetic algorithm. While using the Genetic Algorithms the problem of trapping into local optima is resolved. Crossover operators are used to produce the offspring from the existing parents by maintaining the partial tours. The partially matched crossover (PMX) [1] was proposed by Goldberg and Lingle which produces the off spring by selecting a sub sequence of a tour from one parent and maintains the order and position of cities in other parent. The cyclic crossover (CX) [2] was suggested by Oliver et al, which create off springs from parents in which each position is occupied by corresponding element from one of the parents. The ordered crossover (OX)[3] was proposed by Davis which produces an offspring by selecting a sequence of parent and preserve the relative order of cities in other parent. II. GENETIC ALGORITHM WITH PMX, CX, OX OPERATORS John Holland proposed Genetic Algorithm in 1975 [4]. In the field of artificial intelligence a genetic algorithm is a search heuristic that mimics the process of natural evolution. Genetic Algorithm belongs to class of evolutionary algorithm.GA begin with various problem solution which are encoded into population, a fitness function is applied for evaluating the fitness of each individual, after that a new generation is created through the process of selection, crossover and mutation. After ISSN : 2278-5299 the termination of genetic algorithm, an optimal solution is obtained. If the termination condition is not satisfied then algorithm continues with new population. The basic steps of genetic algorithm used are given below: (A) Initialization An initial population is generated from many individual solutions. A problem depends upon size of the population that contains several hundreds or thousands of possible solutions. The search space contains all the possible solutions from which the population is generated randomly. However, the solutions are seeded in the areas from where the optimal solutions are likely to be found. In this if there are N numbers of cities then N! Possible number of solution can be made. (B) Encoding Scheme In this we represent each city with number, for example if there are 10 cities then each city is represented from number 1 to 10 such as 9 1 10 2 4 3 6 7 5 8, and no number will be repeated. For N number of cities, the cities are represented by permutation of integers from 1 to N. (C) Fitness Function In this each solution or chromosome is assigned a fitness value. For TSP problem, the fitness value is assigned to each solution by calculating the distance between the cities in each solution. (D) Selection Selection operation simulates the natural law of the survival of the fittest in the population evolutionary process. The chromosomes selected with largest fitness value. The solution with minimum distance is selected for crossover operator. Here we use the Roulette Wheel 98

Kumar et.al, International Journal of Latest Research in Science and Technology.

selection technique. The principle of Roulette wheel selection is a linear search through roulette wheel with the slots in the wheel weighted in proportion to the individuals fitness value. This technique comprises of following steps [5]: (1) Sum the total expected value of the individuals in the population. Let it be A. (2) Repeat N times: (i) Choose a random number r between 0 and A. (ii) Loop through the individuals in the population, summing the expected value, until the sum is greater than or equal to r. The individuals whose expected value put the sum over this limit is one selected.

(iv) If X%10 = =0 Apply the interchanging mutation to prevent the algorithm to trapped in local optima with mutation probability PM = 0.1. (v) The weak chromosomes are replaced by using weak replacement function. (vi) X=X+1; 5. After 1000 iterations the algorithm will terminate. 6. End Ordered Crossover: In ordered crossover operator two cut points are randomly selected from parents chromosomes. Here to produce the offspring O1 the genes between the cut points are replaced by the genes in the second parent. The Pseudo code for Ordered Genetic algorithm under TSP problem 1. 2. 3. 4. Start Generate the random population by using randperm function. X=1 Repeat step i to vi while (X!=100) (i) Evaluate the fitness of each single chromosome using fitness function in which the weight between each individual city is summed up. (ii) Individual with largest fitness value is selected by using the Roulette wheel selection procedure. (iii) Apply the ordered crossover for producing the off springs with crossover probability i.e. PC =1. For example, consider two parents P1: P2: 2 1 5 4 | 7 8 9 3 | 6 10 1 5 4 6 | 10 2 8 7 | 3 9

(E) Crossover Crossover operators are the backbone of the genetic algorithm. Reproduction makes clones of good strings but does not create new ones. Crossover operators are applied to mating pool with hope that it creates a better offspring. Here three crossover operators PMX, CX and OX are discussed. Partially Matched Crossover: In partially matched crossover operator two crossover points are selected randomly from the parents chromosomes to produce the offspring. The two crossover points give a matching selection which is used to affect a cross through position by position exchange operations [5]. The Pseudo code for PMX problem 1. 2. Genetic algorithm under TSP

Start Generate the random population by using randperm function. 3. X=1 4. Repeat step i to vi while (X!=100) (i) Evaluate the fitness of each single chromosome using fitness function in which the weight between each individual city is summed up. (ii) Individual with largest fitness value is selected by using the Roulette wheel selection procedure. (iii) Apply the PMX crossover for producing the off springs with crossover probability i.e. PC =1. For example ,consider two parents P1 : P2 : 2 1 5 4 | 7 8 9 3 | 6 10 1 5 4 6 | 10 2 8 7 | 3 9

Finally we have the off springs as follows: O1: O2: (iv) 5 4 9 3 | 10 2 8 8 7| 6 1

4 6 10 2 | 7

9 3 | 1 5

Finally we have the off springs as follows: O1: O2: 9 1 5 4 |10 2 1 5 4 6 |7 8 8 7| 6 3

9 3 | 10 2 5

If X%10 = =0 Apply the interchanging mutation to prevent the algorithm to trapped in local optima with mutation probability PM = 0.1. (v) The weak chromosomes are replaced by using weak replacement function. (vi) X=X+1; After 1000 iterations the algorithm will terminate.

ISSN: 2278-5299

99

Kumar et.al, International Journal of Latest Research in Science and Technology.

End

repeated until a termination condition has been reached. Here the algorithm terminates after 1000 iterations. III . SIMULATION RESULTS: The following graph shows the distance find out by PMX,CX and OX operator with 30 number of cities and PC =1 and PM = 0.1. Output:

Cyclic Crossover: Cyclic crossover operator performs recombination under the constraint that each gene comes from the parent or other. The Pseudo code for Cyclic Genetic algorithm under TSP problem Start Generate the random population by using randperm function. 3 X=1 4 Repeat step i to vi while (X!=100) (i) Evaluate the fitness of each single chromosome using fitness function in which the weight between each individual city is summed up. (ii) Individual with largest fitness value is selected by using the Roulette wheel selection procedure. (iii) Apply the Cyclic crossover for producing the off springs with crossover probability i.e. PC =1. 1 2

Fig.1 Graph for the shortest path for 25 cities The resulting graph shows the distance find out by PMX,CX and OX operator with 25 no. of cities and PC =1 and PM = 0.1.

Consider the following parents : P1: P2: 2 8 0 1 3 4 5 7 9 6 1 0 5 4 6 8 9 7 2 3

The offspring produced are : O1: O2: 2 8 10 1 6 4 5 7 9 3 1 5 4 3 8 9 7 2 6 10 Fig.2 Graph for the shortest path for 30 cities IV. CONCLUSIONS The experimental results show that the distance measured by partially matched crossover operator is minimum as compared to distance measured by cyclic crossover operator. And distance measured by cyclic crossover operator is less than the distance measured by ordered crossover .The results shows that the PMX crossover outperforms the CX and OX crossover operator. The shortest path find out by PMX, CX and OX operator is shown below for 25 numbers of cities: Table 1: Distance measured by PMX,CX and OX Cases 1 2 3 4 5 6 7 8 9 10 PMX 431 460 450 483 491 493 424 324 328 400 CX 494 468 472 531 551 500 520 420 424 449 OX 498 494 495 538 557 507 540 426 450 510 100

(iv) If X%10 = =0 Apply the interchanging mutation to prevent the algorithm to trapped in local optima with mutation probability PM = 0.1. (v) The weak chromosomes are replaced by using weak replacement function. (vi) X=X+1; (5) After 1000 iterations the algorithm will terminate. (6) End (F) Mutation After the crossover operation, the chromosomes are subjected to mutation process. Mutation prevents the algorithm to be trapped in local optima. Here interchanging mutation is used. In this mutation process two random position of chromosomes is chosen and the bits corresponding to that position are interchanged the mutation probability PM is taken as 0.1. (G) Termination When the algorithm has run a given number of iterations, it stops and output the best solution. This generational process is

Distance

ISSN: 2278-5299

Kumar et.al, International Journal of Latest Research in Science and Technology.

The shortest path find out by PMX, CX and OX operator is shown below for 30 numbers of cities: Table 2: Distance measured by PMX, CX and OX Cases PMX CX OX 1 428 431 469 2 461 521 546 3 437 448 500 4 439 450 474 5 444 464 500 Distance 6 468 505 525 7 405 428 473 8 407 449 479 9 425 450 480 10 449 469 485 The following table gives the briefing of experiments: Table 3: Result of PMX, CX and OX No. PC PM Averag of Crossove Mutation e Citie r Probabili Distan s Probabili ty ce ty By PMX 25 1 0.1 428 30 1 0.1 436

REFERENCES
1 D.E.Goldberg, Alleles Loci and the TSP, Proceedings of the First International Conference on Genetic Algorithms and Their Application, Lawrence Erolaum, New Jersy, 1985, pp 154-159. I.M.Oliver, D.J.Smith , J.R.C Holland, A Study of Permutation Crossover Operator on the TSP, Proceedings of the Second International Conference , Lawrence Erolaum, New Jersy,1987, pp224-230. L. Davis, Applying adaptive Algorithms to Epistatic Domains,Proceeding of the International Joint Conference on Artificial Intelligence, IEEE Computer Society Press, Los Angeles 1985,pp. 162-164. J. Holland, Adaptation in Natural and Artificial Systems : An Introductory Analysis with applications to biology , Control and Artificial Intelligence. The University of Michigan Press, 1975. S. N. Sivanandam, S.N. Deepa , Introduction to Genetic Algorithm, ISBN 978-3-540-73189-4 Springer Berlin Heidelberg New York, Springer Verlag Berlin Heidelberg 2008.

Averag e Distan ce By CX 483 461

Averag e Distan ce By OX 503 493

Table 4 Input: Input is the distance between the 25 cities. The cities are numbered from 1 to 25.

No. of cities
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 0 24 30 43 21 35 50 26 42 11 18 34 46 43 21 22 29 23 43 45 42 20 43 39 22 2 33 0 32 21 24 34 35 43 21 23 33 44 21 34 37 43 38 28 36 21 43 45 43 5 32 3 45 21 0 33 21 22 35 31 32 47 25 43 25 21 32 21 50 11 22 43 4 3 1 3 43 4 35 32 35 0 33 21 43 45 46 49 31 22 32 43 22 11 43 22 10 9 8 5 11 23 45 5 46 25 50 22 0 22 32 22 23 43 21 11 23 43 34 25 29 25 34 22 11 45 43 22 22 6 41 42 22 44 33 0 31 32 22 33 44 21 24 35 37 32 31 22 32 36 32 21 44 34 11 7 35 43 11 55 44 22 0 43 33 32 22 34 21 22 43 45 49 48 43 31 32 24 22 43 33 8 41 41 42 11 5 21 33 0 44 22 32 5 4 3 21 33 44 22 11 21 32 32 34 44 21 9 32 33 27 43 6 44 43 34 0 44 32 21 32 1 2 3 4 5 7 33 44 50 32 21 32 10 32 11 25 32 21 43 21 43 2 0 1 3 45 43 22 34 21 23 32 21 33 32 33 21 44 11 44 22 26 22 34 22 33 32 34 35 0 34 23 21 35 43 47 31 48 24 45 50 2 43 43 12 50 35 21 43 23 21 23 43 21 43 21 0 22 31 21 33 43 47 31 22 31 34 44 54 41 13 21 24 33 45 22 23 22 11 44 43 42 21 0 32 32 5 34 32 23 21 43 54 32 44 24 14 25 21 31 47 34 22 21 22 43 21 33 21 33 0 34 36 39 41 40 32 34 33 50 11 35 15 43 17 32 21 21 22 32 43 45 48 23 22 21 33 0 31 22 45 34 22 33 45 32 21 45 16 44 19 22 34 22 33 44 5 21 32 43 21 22 33 33 0 22 21 43 21 50 32 21 21 46 17 22 21 55 21 33 43 41 23 34 45 46 47 32 31 33 32 0 22 21 33 32 43 5 23 23 18 33 32 33 32 44 33 11 22 43 23 43 12 11 14 15 17 32 0 22 34 35 37 39 34 21 19 11 38 21 44 45 50 32 43 44 21 23 43 44 45 31 32 22 11 0 22 21 32 43 32 11 20 9 39 33 50 33 44 55 6 21 34 23 22 32 45 46 47 32 33 21 0 34 43 41 32 22 21 5 31 44 11 43 43 21 34 23 21 22 5 32 43 2 3 4 6 7 9 0 22 33 22 33 22 2 25 32 20 22 22 11 34 35 35 46 43 21 21 33 32 21 44 50 21 22 0 21 44 44 23 9 35 12 32 23 43 21 33 43 22 21 34 43 26 28 32 13 11 22 44 34 21 0 23 21 24 32 21 24 45 43 21 43 22 33 11 42 32 31 12 15 21 25 21 33 45 34 21 23 0 32 25 22 33 21 32 22 21 21 33 43 22 21 44 21 43 45 43 41 23 22 21 23 34 22 12 0

N o.

o f c i t i e s

ISSN: 2278-5299

101

Potrebbero piacerti anche