Two-Level Genetic Algorithm for Clustered Traveling Salesman Problem with Application in Large-Scale TSPs

Two-Level Genetic Algorithm for Clustered Traveling Salesman Problem with Application in Large-Scale TSPs

TSINGHUA SCIENCE AND TECHNOLOGY ISSN 1007-0214 15/20 pp459-465 Volume 12, Number 4, August 2007 Two-Level Genetic Algorithm for Clustered Traveling S...

163KB Sizes 0 Downloads 31 Views

TSINGHUA SCIENCE AND TECHNOLOGY ISSN 1007-0214 15/20 pp459-465 Volume 12, Number 4, August 2007

Two-Level Genetic Algorithm for Clustered Traveling Salesman Problem with Application in Large-Scale TSPs DING Chao (丁 超), CHENG Ye (成 晔)**, HE Miao (何 苗) Department of Industrial Engineering, Tsinghua University, Beijing 100084, China Abstract: Let G = (V, E) be a complete undirected graph with vertex set V, edge set E, and edge weights l(e) satisfying the triangle inequality. The vertex set V is partitioned into clusters V1, V2, …, Vk. The clustered traveling salesman problem (CTSP) seeks to compute the shortest Hamiltonian tour that visits all the vertices, in which the vertices of each cluster are visited consecutively. A two-level genetic algorithm (TLGA) was developed for the problem, which favors neither intra-cluster paths nor inter-cluster paths, thus realized integrated evolutionary optimization for both levels of the CTSP. Results show that the algorithm is more effective than known algorithms. A large-scale traveling salesman problem (TSP) can be converted into a CTSP by clustering so that it can then be solved by the algorithm. Test results demonstrate that the clustering TLGA for large TSPs is more effective and efficient than the classical genetic algorithm. Key words: clustered traveling salesman problem (CTSP); traveling salesman problem (TSP); Hamiltonian cycle; genetic algorithm; integrated evolutionary optimization

Introduction Let G = (V, E) be a complete undirected graph with vertex set V, edge set E, and edge weights l(e) satisfying the triangle inequality. The vertex set V is partitioned into clusters V1, V2, …, Vk. The clustered traveling salesman problem (CTSP) seeks to compute the shortest Hamiltonian tour that visits all the vertices, in which the vertices of each cluster are visited consecutively. There are many applications of the CTSP[1]. The CTSP is NP-hard, and the traveling salesman problem (TSP) can be viewed as a special case of the CTSP in which there is only one cluster or each cluster has only one vertex. There are several variants of the problem depending on whether the start and end vertices of a cluster have been specified. This paper focuses on the variant with unspecified end vertices. Received: 2006-09-30; revised: 2006-11-03

﹡﹡ To whom correspondence should be addressed. E-mail: [email protected]; Tel: 86-10-62784548

Anily et al.[2] developed a 5/3-approximation algorithm for the ordered CTSP with a prespecified visiting sequence for the clusters. Guttmann-Beck et al.[3] proposed approximation algorithms with performance bounds for some variants of the CTSP. For the CTSP with unspecified end vertices, their algorithm first uses a modified Christofides’ algorithm to get the shortest free ends Hamiltonian paths in each cluster. After the first step, the two end vertices for each cluster and the intra-cluster paths are specified. Then a rural postman problem algorithm is used to connect all the intracluster paths to form a whole tour. This algorithm favors the intra-cluster Hamiltonian paths, which implies that the inter-cluster paths may be sacrificed when the end vertices in each cluster are already determined. Sheng et al.[4] proposed a two-level-TSP hierarchical algorithm favoring inter-cluster paths. They first specify the shortest inter-cluster paths connecting every cluster. The start and end vertices are then specified for each cluster. Then a modified Christofides’ algorithm is used to get the shortest Hamiltonian paths with two

460

specified end vertices in each cluster. At last a whole tour is formed by combining the paths generated in both levels. Sheng et al.[4] also showed that the penalties caused by favoring the intra-cluster Hamiltonian paths and the inter-cluster paths are comparable. This paper describes a two-level genetic algorithm (TLGA) for the CTSP that favors neither of the two levels of paths, thus avoiding the disadvantages of both algorithms. The general idea is to find the shortest Hamiltonian cycle for each cluster, to delete a selected edge for each cycle to form an intra-cluster path, and then to connect all the intra-cluster paths in a certain sequence to form a whole tour. In the lower level, a genetic algorithm (GA) is used to find the shortest Hamiltonian cycle rather than the shortest Hamiltonian path for each cluster. In the higher level, a modified genetic algorithm is designed to determine which edge will be deleted from the shortest Hamiltonian cycle for each cluster, and the visiting sequence of all the clusters with the objective of shortest traveling tour for the whole problem. Since the shortest Hamiltonian cycle rather than the shortest Hamiltonian path is formed in the lower level, it leaves open the question of choosing the edge to be deleted. The higher level algorithm has the freedom to choose the edge to be deleted for each cluster while searching for the shortest whole tour. The clustering method can be used to convert a large-scale TSP into a CTSP which can then be solved by the TLGA. Test results demonstrate that the clustering TLGA algorithm for large-scale TSPs is more effective and efficient than the classical genetic algorithm. The increase in computing time of clustering TLGA is almost proportioned to the problem size.

1

Two-Level Genetic Algorithm for the CTSP

The ordinal encoding scheme[5] was used in the TLGA. Under this scheme, any vertex is assigned a unique unsigned integer from 1 to the number of vertices. The ordinal encoding scheme uses genes that are integers. Chromosomes which represent the traveling paths are permutations of these integer genes. A gene segment is defined as a permutation of the serial numbers of vertices in a cluster. Note that a chromosome is also a

Tsinghua Science and Technology, August 2007, 12(4): 459-465

permutation of all the gene segments with one gene segment per cluster. In the lower level, the genetic algorithm finds the (near) shortest Hamiltonian cycles for each cluster. In the higher level, a modified genetic algorithm is designed to choose the edge to be deleted from the shortest Hamiltonian cycle for each cluster, and simultaneously determine the visiting sequence for all the clusters with the objective of the shortest entire traveling tour. 1.1

Lower level genetic algorithm

The objective of the lower level genetic algorithm is to find the shortest Hamiltonian cycle for the given vertices in each cluster. This is a classical application of the genetic algorithm to the traveling salesman problem[6]. In most cases the genetic algorithm cannot assure that it will find the shortest Hamiltonian cycle, but it will find an acceptable cycle. The genetic algorithm for the TSP is applied cluster by cluster. The result of the lower level genetic algorithm is tours T1, T2, …, Tk for clusters V1, V2, …, Vk. A simple example is shown in Fig. 1.

Fig. 1 Example result of the lower level GA

1.2

Higher level genetic algorithm

The objective of the higher level genetic algorithm is to form an entire tour that is as short as possible based on the tours generated in the lower level. In each generation, the designed genetic algorithm selects two adjacent vertices in tour Ti as end vertices for cluster Vi (that is to select the edge to be deleted from Ti), specifies which one will be the start vertex and which one will be the end vertex, and determines a sequence for visiting all the clusters.

DING Chao (丁 超) et al:Two-Level Genetic Algorithm for Clustered Traveling Salesman…

1.2.1 Generating initial population The population is initialized based on the tours T1, T2, …, Tk generated in the lower level genetic algorithm. First, two adjacent vertices in each tour are chosen randomly, with one assigned to be the start vertex and the other assigned to be the end vertex. The intracluster paths in each cluster are then specified, which means that all the gene segments are specified for the chromosome. Then, a whole chromosome is formed by randomly arranging all the gene segments. For example, for the problem shown in Fig. 1, suppose Vertices 1, 8, and 9 are chosen as the start vertices for Clusters 1, 2, 3, and Vertices 4, 7, 10 are chosen as the end vertices for the three clusters (note that the start and end vertices must be adjacent in relevant cycles). Then the gene segment for Cluster 1 is 1→2→3→4, that for Cluster 2 is 8→5→6→7, and for Cluster 3 is 9→12→ 11→10. Suppose Cluster 1 is assigned to be the second visited cluster, Cluster 2 is assigned to be the third visited cluster, and Cluster 3 is assigned to be the first visited cluster, then the whole chromosome is 9→12→11→10→1→2→3→4→8→5→6→7 (1) 1.2.2 Fitness evaluation and selection The fitness of each individual chromosome in the population is the length of the entire tour specified by the chromosome. The selection operation is based on the scaled fitness for each chromosome. 1.2.3 Genetic operators The three genetic operators used to search for the entire feasible region are one crossover operator and two mutation operators. Each operator has its own fraction with the crossover fraction being CF, the first mutation fraction being MF_1. Two different mutation fractions, MF_21 and MF_22, are used in the second mutation operator. The crossover operator and the first mutation operator are used to change the visiting sequence of clusters. They do not change the gene segments for each cluster. Many different operators could be chosen, such as partial mapped crossover, order crossover, swap mutation, and inversion mutation[7]. They are similar to the operators used in the lower level genetic algorithm, except that the objective in the higher level algorithm is to change the visiting sequence of all the clusters rather than the vertices in one cluster.

461

The second mutation operator is designed to change the gene segments for each cluster. After the chromosomes for the second mutation are chosen by the MF_21, MF_22 determines how many gene segments in the chromosome will mutate. Note that MF_1 and MF_21 are for the chromosomes, while MF_22 is for the gene segments in the selected chromosomes. After the gene segments for the second mutation are specified, the mutation is operated as follows. First add an edge between the start and end vertex to form a gene cycle based on the gene segment, choose a gene randomly from the gene cycle as the new start gene, and then randomly choose a direction (backward or forward each with 0.5 probabilities) as the mutation direction. A new gene segment is then generated by starting from the chosen start gene and going in the mutation direction until reaching the end gene which is next to the start gene in the gene cycle. The second mutation operator ensures that all the feasible gene segments can be reached by the mutation. Every gene can be chosen as the start gene in the new gene segment and every gene can also be assigned as the end gene. As an example of the second mutation, suppose the chromosome in Eq. (1) is chosen for the second mutation based on MF_21 and the third gene segment is chosen to mutate based on MF_22. The current gene segment is 8→5→6→7, but if 5 is chosen as the new start gene and backward is chosen as the mutation direction, then the new gene segment will be 5→8→ 7→6. The TLGA is summarized in the flowchart in Fig. 2.

2

Example and Performance Analysis

2.1

Example showing the advantages of the TLGA

The example shows that the TLGA can get shorter tours for the CTSP than the algorithm favoring the intra-cluster Hamiltonian paths and the algorithm favoring the inter-cluster paths. The vertex coordinates and their clusters are listed in Table 1.

Tsinghua Science and Technology, August 2007, 12(4): 459-465

462

Fig. 2 Table 1 X 0 0 1 2 5 5.2 6 4 0 1 3 3

TLGA flowchart

Vertex information used in the example Y 4 3 2 3 4 3 2 2 0.5 0.5 1 1.5

Cluster 1 1 1 1 2 2 2 2 3 3 3 3

(1) The best result of the algorithm favoring the intra-cluster Hamiltonian paths is shown in Fig. 3. The solid lines stand for the shortest free ends Hamiltonian paths for each cluster, and the dash-dotted lines stand for the edges connecting all the clusters. The total tour length is 19.470. (2) The best result of the algorithm favoring the inter-cluster paths is shown in Fig. 4. The dash-dotted lines are the edges connecting the clusters which are specified first, and the solid lines are the shortest two

ends (or one end) Hamiltonian paths in each cluster. The total tour length is 19.272. (3) The TLGA result shown in Fig. 5 is the optimal result for this CTSP. The dash-dotted lines are the cycles generated by the lower level genetic algorithm in the TLGA for each cluster, while the solid line is the optimal tour generated by the TLGA (note that parts of the dash-dotted lines are covered by the solid line). The total tour length is 18.595, which is shorter than the other two algorithms. As the problem scale increase, the TLGA will give substantially better results.

Fig. 3 Best result for the algorithm favoring the intra-cluster Hamiltonian paths

DING Chao (丁 超) et al:Two-Level Genetic Algorithm for Clustered Traveling Salesman…

Fig. 4 Best result for the algorithm favoring the intercluster paths

Fig. 5 Optimal result for the CTSP generated by the TLGA

2.2

Performance analysis and discussion

The TLGA can be thought of as a relaxation of the algorithm favoring the intra-cluster Hamiltonian paths proposed by Guttmann-Beck et al.[3] The algorithm favoring the intra-cluster Hamiltonian paths has the disadvantage that the shortest Hamiltonian paths specify the end vertices for each cluster which do not necessarily lead to the best inter-cluster paths. In the TLGA, the shortest Hamiltonian cycles are formed instead of the shortest Hamiltonian paths for each cluster, thus the higher level genetic algorithm is free to choose end Table 2 Cycles generated in lower level algorithm SHC Cycle containing SHP

463

vertices for each cluster to get a shorter entire tour. Some of the resulting intra-cluster paths may not be the shortest Hamiltonian paths. The disadvantage of the algorithm favoring the intra-cluster Hamiltonian paths is then an advantage for the TLGA. One disadvantage of the TLGA is that the intracluster paths of the optimal entire tour for the CTSP may not be part of the corresponding shortest Hamiltonian cycles. Even so it is reasonable for the lower level algorithm to seek the shortest Hamiltonian cycle. For any cluster, the shortest free ends Hamiltonian path is the shortest intra-cluster path possible in the optimal tour for a CTSP. Let SHC denote the shortest Hamiltonian cycle and its length for a cluster, SHP denote the shortest Hamiltonian path and its length, l(s, t) denote the edge connecting the start and end vertices of the shortest Hamiltonian path and its length, D denote the longest edge and its length in the cluster, then SHC ≤ SHP+l ( s, t ) ≤ SHP+D (2) Since there is a constant upper bound for SHC compared to SHP, SHC is a good choice. One test was generated to compare the effect of forming the shortest Hamiltonian cycle in the lower level algorithm to that of forming a cycle containing the shortest Hamiltonian path in the lower level of the TLGA. A CTSP was designed with 100 vertices randomly distributed in an area of 1000 by 1000. The kmeans clustering algorithm[8] was used to assign all the points to 10 clusters. The TLGA was run 50 times using each of these methods in the lower level algorithm. The statistical results of the entire tour length are listed in Table 2 which shows that the average tour lengths generated by the two lower level methods are almost the same. The standard deviation of the tour lengths generated using the shortest Hamiltonian cycle in lower level algorithm is smaller while the minimum tour length is longer. Therefore, both lower level algorithms give comparable results in the TLGA.

Statistical results for 50 runs with the two lower level algorithms Generated tour lengths

Minimum

Maximum

Average

Standard deviation

Coefficient of variance (%)

9219

10 068

9641.1

214.6

2.2

8623

10 283

9637.4

359.4

3.7

Tsinghua Science and Technology, August 2007, 12(4): 459-465

464

3

Application to Large-Scale TSPs

There are many research results for large-scale TSPs[9,10]. With the TLGA, the vertex clusters must be specified and the vertices in each cluster must be visited consecutively. The TSP does not have this constraint. However, the TSP can be converted to a CTSP by assigning each vertex to a cluster with a divide and conquer philosophy[11]. This is especially helpful in large-scale TSPs. Here the k-means clustering algorithm was used to assign the vertices into several clusTable 3 Example

Optimum tour length 4

Comparison of TLGA and CGA results

Minimum tour length CGA

TLGA

4

Average computational time (s) CGA

TLGA

5.08×10

1.45

1.31

68.44

19.71

rat783

8.81×103

1.25×104

1.12×104

1.49

1.29

272.24

45.48

7

7

7

1.41

1.28

690.87

66.34

1.87×10

2.45×10

6.53×10

CGA

pcb442 dsj1000

6.96×10

Ratio (average/optimum)

TLGA 4

ters and then the TLGA was employed to solve the CTSP to get a reasonable tour for the original TSP. This clustering TLGA algorithm was used to solve three large-scale benchmark TSPs from TSPLIB[12]. The tour lengths and the computing times of the clustering TLGA and the classical genetic algorithm (CGA) are compared in Table 3. The computing platform was Matlab7.0.1 on a 1.6-GHz computer with 256 MB RAM. Each algorithm was run five times for each example. The ratio refers to the average length of all tours generated by the algorithm to the optimum tour length.

2.35×10

The results in Table 3 show that the clustering TLGA is more effective and efficient than the classical genetic algorithm for large TSPs. For example, for dsj1000, the clustering TLGA produced shorter tours in less than one-tenth of the computing time than the classical algorithm on average. Hence the clustering TLGA is preferable to get reasonable tours in limited time for large TSPs. The results in Table 3 also shows that as the problem scale increases, the increase in the computing time of the clustering TLGA is much less than that of the classical algorithm. Figure 6 clearly shows this result where the increase in computing time of the clustering TLGA with the problem scale is almost linear, which is a notable advantage with large TSPs.

For very large TSPs, the TLGA can be applied in a recursive manner. For example, for a TSP with 10 thousand vertices, the TLGA will have to analyze many clusters, since each cluster can only have a moderate number of vertices in order to assure the lower level algorithm runs efficiently. However, this will greatly affect the efficiency of the higher level algorithm. Such a large problem can be solved more efficiently in a recursive manner. The 10 thousand vertices are first divided into 12 clusters with about 800 vertices in each cluster. Rather than using the lower level genetic algorithm to get the shortest Hamiltonian cycle for each large cluster, the TLGA is used independently to calculate a sub-optimal tour for each of these large clusters. Then the higher level genetic algorithm is used to create an entire tour.

4

Fig. 6

Computational time for large TSPs

Conclusions

A two-level genetic algorithm for the CTSP was developed, which realized the integrated evolutionary optimization for both levels of the CTSP. In TLGA, a shortest Hamiltonian cycle is formed instead of the shortest Hamiltonian path for each cluster in the lower level genetic algorithm, and then the higher level genetic algorithm is free to choose end vertices for each cluster. The TLGA favors neither the intra-cluster Hamiltonian paths nor the inter-cluster paths, thus it

DING Chao (丁 超) et al:Two-Level Genetic Algorithm for Clustered Traveling Salesman…

can get a shorter tour for the CTSP. An example shows that the algorithm is more effective than known algorithms. The TLGA can also be applied to large TSPs to more efficiently get reasonable solutions than the classical genetic algorithm.

dimensional measurement in automotive manufacturing. Transactions of the ASME, 2005, 127(2): 420-428. [5]

coordinate measuring machine (CMM). International Journal of Advanced Manufacturing Technology, 1999, 15(6): 409-416. [6]

Wang L. Intelligent Optimization Algorithms with Applications. Beijing: Tsinghua Univ. Press, 2001. (in Chinese)

tistics and Operations Research of Tel Aviv University in Israel for his help during this research.

Lu C G, Morton D, Wu M H, Myler P. Genetic algorithm modeling and solution of inspection path planning on a

Acknowledgments The authors thank Prof. Refael Hassin in the Department of Sta-

465

[7]

Gen M, Cheng R. Genetic Algorithms and Engineering Optimization. Yu X, Zhou G., trans. Beijing: Tsinghua

References [1]

Laporte G, Palekar U. Some applications of the clustered traveling salesman problem. Journal of the Operational Research Society, 2002, 53(9): 972-976.

[2]

Anily S, Bramel J, Hertz A. A 5/3-approximation algorithm for the clustered traveling salesman tour and path problems. Operations Research Letters, 1999, 24(1-2): 29-35.

[3]

Guttmann-Beck N, Hassin R, Khuller S, Raghavachari B. Approximation algorithms with bounded performance guarantees for the clustered traveling salesman problem. Algorithmica, 2000, 28(4): 422-437.

[4]

Sheng W, Xi N, Song M, Chen Y. Robot path planning for

Univ. Press, 2001. (in Chinese) [8] Han J, Kamber M. Data Mining: Concepts and Techniques. Beijing: Higher Education Press, 2001. [9]

Walshaw C. A multilevel approach to the traveling salesman problem. Operations Research, 2002, 50(5): 862-877.

[10] Lu C Y, Delgado-Frias J G, Lin W. A clustering and genetic scheme for large TSP optimization problems. Cybernetics and Systems, 1998, 29(2): 137-157. [11] Mulder S A, Wunsch II D C. Million city traveling salesman problem solution by divide and conquer clustering with adaptive resonance neural networks. Neural Networks, 2003, 16(5): 827-832. [12] TSPLIB. http://www.iwr.uni-heidelberg.de/groups/comopt/ software/ TSPLIB95/. April, 2006.