82
European
Journal
of Operational
Research
23 (1986) 82-85 North-Holland
A note on finding a shortest complete cycle in an undirected graph A. VOLGENANT,
R. JONKER, and G.A.P. KINDERVATER * Institute /or Actuarial Sciences arld Econometrics, University of Amsterdam, Jodenbreestraat 23, 1011 NH Amsterdam
How to transform a shortest complete cycle problem into a traveling salesman problem is well known. Although these problems appear ill-conditioned, a l-tree relaxation based traveling salesman algorithm solves them rather easily (up to 150 nodes), provided non-optimal edges are eliminated. The computational results are considerably better than known results for a linear programming approach.
Abstract:
Complete cycle problem, cycles, circuits, traveling salesman problem, edge elimination, ing, networks, integer programming
Keywords:
1. Introduction
The Complete Cycle Problem (CCP) is to find a shortest cycle (circuit) visiting each node of a graph at least once. Changing ‘at least’ into ‘exactly’ gives a definition for the Traveling Salesman Problem (TSP). Hardgrave and Nemhauser [3] showed how to solve the CCP by solving a TSP: Transform the distance matrix C = ((cii)) into the shortest path matrix ((dij)) by replacing each cij with the length dji of a shortest path between nodes i and j, and solve the TSP on D. The transformation of an optimal solution for this TSP into an optimal solution of the original CCP is simple: If (i, j) is contained in an optimal TSP tour (in D) and (i, k,..., I, j) is a shortest path from i to j (in C) the related optimal complete cycle contains the sequence (i, k, . . . , I, j). Miliotis, Laporte and Nobert [7] used linear programming in combination with cutting planes
* Current Systems Science, Received
address: Department Theory, Centre for Amsterdam. November
0377-2217/86/$3.50
84; revised
0 1986.
of Operations Mathematics
February
Elsevier
Research and and Computer
85
Science
Publishers
B.V.
schedul-
and with branch-and-bound to solve the CCP directly. The computational results led them to the conclusion that this approach is superior to solving the TSP on the shortest path matrix. For the symmetric CCP, however, we will show that their method is not as fas as a l-tree relaxation based algorithm on the TS tp transformation. Furthermore we will show the advantages of elimination of non-optimal edges for the TSP according to the theory given by Jonker and Volgenant [4,5]. To be fair, we mention that the linear programming approach can handle additional restrictions, which a TSP algorithm cannot. An example is the CCP with the restriction that each edge can be used at most once. This CCP is well known to holiday makers, so one might call it the Traveling Tourist Problem. For further reading on related research we suggest Fleischmann [l] who treats linear programming and the TSP. Concerning edge elimination, [2] gives a method, where the number of nodes of the problem increases. It is developed mainly for a linear programming based CCP algorithm, applied on road map problems. Nevertheless, it can also be used for a branch-and-bound approach. The numbers of eliminated edges in [2] are substantially smaller than the corresponding numbers in [5] and [S], However, both elimination approaches can be combined.
(North-Holland)
A. Volgenan:
2. Non-optimal
et al. /A
shortest
edges for the CCP
In Jonker and Volgenant [4] an edge is defined to be non-optima1 for a TSP if no optimal solution contains it; so non-optimal edges can be eliminated from the problem. We outline the general form of criteria to identify some of these edges. We refer to [4] for refinements. ‘e.g., how to utilize already eliminated edges. For a TSP distance matrix D = ((dij)) and a node k, the quantity pk is defined by pk=~~{dij-d,,-d,jli+j.
kand j#k}.
Suppose that for an edge ( p, q) there is a node k for which pk reaches its value only for (p, q). Now this edge is non-optimal, as one can show that any Hamiltonian circuit containing (p, q) is not 3-optimal in the sense of Lin [6]. Replacing the edge (p, q) and the two edges incident to k-say (I, k) and (k, m)-with the edges (p, k), (k, q) and (I, m) yields a shorter circuit. If the value of pk is degenerate, the rules for non-optimality are easily modified. For the symmetric TSP similar rules are given in [5], based on 2-optimality. Elimination of non-optimal edges is also possible for the TSP transformation of a CCP. When the CCP distance matrix C is transformed into the shortest path matrix D, a number of edges is ‘shortened’. This concerns all edges (p, q) which are not themselves the shortest path between p and q. The edges identified as nonoptimal belong often to this category. This can be explained as follows. If an edge (p, q) is shortened and the node s is contained in the shortest path from p to q, this path consists of a shortest path from p to s and one from s to q, i.e., d,, = d,,, + d,,. So ps computed on D, reaches the value zerosfor ( p, q). This is the maxima1 possible value, as D satisfies the triangle inequality. A not shortened, non-optimal edge can nevertheless be identified, if for some node k not contained in any shortest path pk reaches its value for this edge. Solving the CCP directly, Miliotis et al. [7] can eliminate every shortened edge: About 92% of the edges for the two (out of five) CCP’s of size 100 that they could solve within a preset time limit of 500 seconds. Using the TSP algorithm of Volgenant and Jonker [8], we started with an average of 78% eliminated edges, for ten problems of size 100 (all solved). This elimination is based on an edge
complete
cycle in a graph
83
exchange analysis, that checks whether fixing edges into or out of a lower bounding l-tree causes the length of the tree to exceed an upper bound. According to [5] checking the non-optimality criteria for all edges takes O(nE) operations, with E the number of not eliminated edges. So ‘we checked these criteria only when at least 75% of the edges were already eliminated by other means. For the problems that satisfied this rule in the initial node of the enumeration tree, about 35% of the remaining edges were eliminated. Thus for eight problems (out of ten) with n = 100, the average percentage of eliminated edges rose from 89% to about 92%, the same value reached by Miliotis et al. We conclude this section with two remarks on optima1 edges: (1) A sufficient condition for a node k to be visited exactly once in every optimal solution is pk < 0. For such a node one can try to identify an edge that must be in any optimal solution. Let c~,,,= mini{ cki ] i # k}. Now it is easy to see that the edge (k, m) will occur twice in every optimal . . solution if c~,,, < - 4~~; (2) An edge is also optimal if one finds that all shortest paths from a node k start with the same edge. This edge must be contained twice in any optimal solution (given cij 2 0), so we may as well remove node k from the problem. These remarks turned out to be merely, of theoretical interest: In our set of test problems of size 60 we found only one optima1 edge (according-to remark 2).
3. Computational
results
In order to compare the computational results of Miliotis, Laporte and Nobert with our results, test problems were generated in a similar way, i.e., by taking the distances cij uniformly distributed on ]O,lOO[ and all distance matrices complete. We had to restrict ourselves to symmetric problems on account of our TSP algorithm. Unfortunately we cannot compare results with Fleischmann [l], which would have been interesting. The description of his algorithm is. not complete, and he does not give a comparison of result with Miliotis et al. Ten problems of size 60 and ten of size 100 were solved in two ways: By solving the TSP on
84
A. Volgeuaut
et al. / A shortest
the shortest path matrix, without and with elimination of non-optimal edges according to [5]. The TSP algorithm was not adapted, although one can think of reasons to change some rules or parameters. We expect shorter lower bounding ascents to lead to shorter running times. We used the CDC Cyber 175 of SARA, the academic computing centre of Amsterdam. As far as we know this computer is about five times as fast as the Cyber 173 used by Miliotis et al. They used Fortran and we used Pascal (about twice as slow) for the main part of our code. So we divided their computing times conservatively by four to make their results and ours roughly comparable. Thus their present time limit of 500 set becomes 125 sec. As Table 1 shows, the main advantage of our method is that we solve all problems, unlike Miliotis, Laporte and Nobert. Only without elimination of non-optimal edges, two problems took more than 125 sec. to be solved (even 600 sec. was not sufficient). With elimination, however, both problems were solved easily, in 71 and 61 set respectively. Another advantage over the linear programming approach is that the memory requirements are modest, and they never made us fail to solve a problem. For loo-nodes problems 41K memory words (of 60 bits) are sufficient. We also investigated whether for our algorithm the CCP is easier or more difficult to solve than the standard TSP, and to what extent the solution
Table 1 Comparison
of compuIational
Solution
Miliotis. Laporte and Nobert - CCP as TSP with culling planes with branch and bound - CCP directly with cutting planes with branch and bound Jonker, Volgenant and Kindervnter - CCP as TSP without elimination with elimination
complete
qde
it1 a graph
Table 2 A comparison of CPU distance intervals Problem
CCP TSP
times
for CCP average
and TSP, CPU
on different
time (set)
Distance interval
,I = 60
I1 = 100
o- 100 0-1000 o- 100 0-1000
4.1 5.6 3.6 3.5
32.9 >111.9 15.3 23.2
times depend on the interval on which the distances are drawn-see Table 2. All results in this table are averages for ten problems, solved with elimination of non-optimal edges. For the CCP with n = 100 and distances drawn on ]O,lOOO[,nine out of ten problems were solved within 300 sec., with an average of 91.0 sec. The results for the TSP with I?= 60 are somewhat unexpected; possibly these problems are too simple to differentiate clearly between the two cases. Finally we generated five problems with n = 150 and five with II = 200, all with distances drawn on ]O,lOOO[. Table 3 gives the results for the l-tree approach with elimination of non-optimal edges according to [5], using an upper bound of 1.01 times the initial lower bound. For all problems a solution was found that was lower than this upper bound, so no problem had to be rerun with a larger initial upper bound. The average running time for the five CCP’s with )I = 150 is 182.1, for the five problems with n = 200 at least 845 set, and for the four solved 200~nodes problems 681.3 sec.
results Solved problems
(W)
Average CPU time (set) for solved problems
,r=60
n=lOO
/1=60
60 80
0 0
16.7 89.2
80 100
40 0
6.5 6.8
n=lOO
-
Table 3 Computational Problem size and number ,1=150
78.1 ,1= 200
100 100
80 100
3.9 4.1
34.6 32.9
resuhs
1 2 3 4 5 1 2 3 4 S
for problems
with
ri = 150 and
,I = 200
Solution time (set)
Gap between initial lower bound and optimum (in %)
Initial W of eliminated variables
156.7 120.3 303.8 133.0 196.7 511.6 > 1500 682.6 899.0 631.9
0.17 0.27 0.34 0.27 0.09 0.25 < 0.45 0.23 0.11 0.29
92.2 91.1 87.8 91.0 80.3 90.6 79.5 91 .o 81.3 88.6
A. Volgenanr
er al. / A shortest
4. Conclusions The l-tree relaxation based TSP algorithm of Volgenant and Jonker [8] solves the symmetric CCP faster than the direct linear programming approach of Miliotis, Laporte and Nobert [7]. For the first algorithm the symmetric CCP is harder to solve than the symmetric TSP. The relaxed constraints in the CCP are an apparent advantage over the TSP, which disappears when the CCP is solved as a TSP, due to the introduction of alternative (optimal) solutions. The elimination of edges with the non-optimality criteria based on 2-optimality [5] improves the TSP based method further. The results for the TSP in [8] suggest that TSP’s larger than with n = 200 can be solved by the algorithm presented there. As indicated by the results in this paper, this is not the case for the CCP, where for this algorithm )I = 200 clearly is the limit.
complete
cycle in a graph
85
References 111Fleischmann,B., “A cutting planeprocedurefor the travelling salesmanproblem on road networks”,Report no. QM02-83,Universirit Hamburg, Hamburg, 1983. PI Fleischmann,B., “Distance conservingreductionsfor nonorientednetworks”, OR Spekrrm 5 (1983) 195-205. W.W., and Nemhauser, G.L., “On the relation 131Hardgrave, between the traveling-salesman and the longest-path problems”, Operations Research 10 (1962) 647-657. [41 Jonker,R. and Volgenant,A., “Identification of non-optimal arcs for the traveling salesman problem”, Operarions Research Letters 1 (1982)85-88. edges for the (51 Jonker, R. and Volgenant, A., “Nonoptimal symmetric traveling salesman problem,” to appear in Operations Research 32 (1984) 837-846. solutions of the traveling salesman 161Lin, S., “Computer problem”, Bell Sysfems Technical Journal 44 (1965) 2245-2269. Miliotis, P., Laporte, G. and Nobert, Y., “Computational comparison of two methods for finding the shortest complete cycle or circuit in a graph”, R.A.I. R.0 Recherche Opfiraotionelle / Operations Research 15 (1981) 233-239. Volgenant, A., and Jonker, R., “The symmetric traveling salesman problem and edge exchanges in minimal l-trees,” European Journal 01 Operational Research 12 (1983) 394-403.