Converting MST to TSP Path by Branch Elimination
Total Page:16
File Type:pdf, Size:1020Kb
applied sciences Article Converting MST to TSP Path by Branch Elimination Pasi Fränti 1,2,* , Teemu Nenonen 1 and Mingchuan Yuan 2 1 School of Computing, University of Eastern Finland, 80101 Joensuu, Finland; [email protected] 2 School of Big Data & Internet, Shenzhen Technology University, Shenzhen 518118, China; [email protected] * Correspondence: [email protected].fi Abstract: Travelling salesman problem (TSP) has been widely studied for the classical closed loop variant but less attention has been paid to the open loop variant. Open loop solution has property of being also a spanning tree, although not necessarily the minimum spanning tree (MST). In this paper, we present a simple branch elimination algorithm that removes the branches from MST by cutting one link and then reconnecting the resulting subtrees via selected leaf nodes. The number of iterations equals to the number of branches (b) in the MST. Typically, b << n where n is the number of nodes. With O-Mopsi and Dots datasets, the algorithm reaches gap of 1.69% and 0.61 %, respectively. The algorithm is suitable especially for educational purposes by showing the connection between MST and TSP, but it can also serve as a quick approximation for more complex metaheuristics whose efficiency relies on quality of the initial solution. Keywords: traveling salesman problem; minimum spanning tree; open-loop TSP; Christofides 1. Introduction The classical closed loop variant of travelling salesman problem (TSP) visits all the nodes and then returns to the start node by minimizing the length of the tour. Open loop TSP is slightly different variant, which skips the return to the start node. They are both NP-hard problems [1], which means that finding optimal solution fast can be done only for very Citation: Fränti, P.; Nenonen, T.; small size inputs. Yuan, M. Converting MST to TSP The open loop variant appears in mobile-based orienteering game called O-Mopsi Path by Branch Elimination. Appl. Sci. (http://cs.uef.fi/o-mopsi/) where the goal is to find a set of real-world targets with the 2021, 11, 177. https://dx.doi.org/ help of smartphone navigation [2]. This includes three challenges: (1) Deciding the order 10.3390/11010177 of visiting the targets, (2) navigating to the next target, and (3) physical movement. Unlike in classical orienteering where the order of visiting the targets is fixed, O-Mopsi players Received: 23 November 2020 optimize the order while playing. Finding the optimal order is not necessary but desirable Accepted: 24 December 2020 Published: 27 December 2020 if one wants to minimize the tour length. However, the task is quite challenging for humans even for short problem instances. In [2], only 14% of the players managed to solve the best Publisher’s Note: MDPI stays neu- order among those who completed the tour. Most players did not even realize they were tral with regard to jurisdictional claims dealing with TSP problem. in published maps and institutional Minimum spanning tree (MST) and TSP are closely related algorithmic problems. In spe- affiliations. cific, open loop TSP solution is also a spanning tree but not necessarily the minimum spanning tree; see Figure1. The solutions have the same number of links ( n − 1) and they both minimize the total weight of the selected links. The difference is that TSP does not have any branches. This connection is interesting for two reasons. First, finding optimal Copyright: © 2020 by the authors. Li- solution for TSP requires exponential time while optimal solution for MST can be found in censee MDPI, Basel, Switzerland. This polynomial time using greedy algorithms like Prim and Kruskal, with time complexity very article is an open access article distributed close to O(n2) with appropriate data structure. under the terms and conditions of the The connection between the two problems have inspired researchers to develop heuris- Creative Commons Attribution (CC BY) tic algorithms for the TSP by utilizing the minimum spanning tree. Classical schoolbook license (https://creativecommons.org/ algorithm is Christofides [3,4], which first creates an MST. More links are then added so licenses/by/4.0/). Appl. Sci. 2021, 11, 177. https://dx.doi.org/10.3390/app11010177 https://www.mdpi.com/journal/applsci Appl. Sci. 2021, 11, 177 2 of 17 that the Euler tour can be constructed. Travelling salesman tour is obtained from the Euler tour by removing nodes that are visited repeatedly. This algorithm is often used as classroom example because it provides upper limit how far the solution can be from the Appl. Sci. 2021, 11, x FOR PEER REVIEW 2 of 17 optimal solution in the worst case. Even if the upper limit, 50%, is rather high for real life applications, it serves as an example of the principle of approximation algorithms. Figure 1. MinimumFigure 1. spanningMinimum tree spanning(MST) (left) tree and (MST) open loop (left) travel andling open salesman looptravelling problem (TSP) salesman solutions problem (right) for (TSP) the same problemsolutions instance. (right) The branching for the same nodes problem are shown instance. by blue, and The the branching links that nodesare different are shown in the two by blue, solutions and have the thicker blacklinks line. that In addition are different to the inbran theches, two there solutions are only have two thicker other places black (red line. circles) In addition where tothe the two branches, solutions differ. there Among all links, 29/37 = 78% are the same in both solutions. are only two other places (red circles) where the two solutions differ. Among all links, 29/37 = 78% are the same in bothThe solutions. connection between the two problems have inspired researchers to develop heu- ristic algorithms for the TSP by utilizing the minimum spanning tree. Classical schoolbook MST hasalgorithm also been is usedChristofides to estimate [3,4], which lower first limit creates forthe an MST. optimal More TSP links solution are then in added [5], so and to estimatethat the the difficultyEuler tour ofcan a be TSP constructed. instance Travel by countingling salesman the number tour is obtained of branches from the [6]. Euler Prim’s and Kruskal’stour by removing algorithms nodes can that also are been visited modified repeatedly. to obtainThis algorithm sub-optimal is often solutions used as class- for TSP. Classroom of insertion example algorithms because itwere provides studied upper in limit [7]. Theyhow far iteratively the solution add can new be nodesfrom the to opti- the current path.mal Thesolution variant in the that worst adds case. a new Even node if the to eitherupper endlimit, of 50%, the existingis rather pathhigh canfor bereal life seen as modificationapplications, of the it Prim’sserves as algorithm an example where of the additions principle areof approximation allowed only algorithms to the ends. of the path. Similarly,MST has algorithm also been called used Kruskal-TSPto estimate lower[8] modifieslimit for the Kruskal’s optimal algorithmTSP solution so in [5], that it allowsand to merge to estimate two spanningthe difficulty trees of (pathsa TSP instan in casece ofby TSP)counting only the by number their end of points.branches [6]. In this paper,Prim’s we and introduce Kruskal’s aalgorithms more sophisticated can also been approach modified to obtain utilize sub-optimal the minimum solutions spanning treefor to TSP. obtain Class solution of insertion for travellingalgorithms were salesman studied problem. in [7]. They The iteratively algorithm, add called new nodes to the current path. The variant that adds a new node to either end of the existing path MST-to-TSP, creates a minimum spanning tree using any algorithm such as Prim or Kruskal. can be seen as modification of the Prim’s algorithm where additions are allowed only to However, instead of adding redundant links like Chirstofides, we detect branching nodes the ends of the path. Similarly, algorithm called Kruskal-TSP [8] modifies Kruskal’s algo- and eliminaterithm them so bythat a it series allows of tolink merge swaps, two spanning see Figure trees2. (pathsBranching in case nodeof TSP)is aonly node by their that connectsend more points. than two other nodes in the tree [6]. We introduce two strategies. First, a simple greedyIn thisvariant paper, removeswe introduce the a longest more soph of allisticated links approach connecting to utilize to any the of minimum the branching nodes.spanning The tree resulting to obtain sub-trees solution are for thentravelling reconnected salesman by problem. selecting The the algorithm, shortest called link betweenMST-to-TSP leaf nodes., Thecreates second a minimum strategy, spanningall-pairs tree, considers using any allalgorithm possible such removal as Prim and or Krus- reconnection possibilitieskal. However, and instead selects of adding the best redundant pair. links like Chirstofides, we detect branching We test thenodes algorithm and eliminate with them two datasetsby a series consisting of link swaps, of open see Figure loop 2. problem Branching instances node is a node with known groundthat connects truth: more O-Mopsi than two [2] other and Dotsnodes [ 9in]. the Experiments tree [6]. We introduce show that two the strategies. all-pairs First, variant providea simple average greedy gaps variant of 1.69% removes (O-Mopsi) the longest and of 0.61% all links (Dots). connecting These areto any clearly of the better branching than those ofnodes. the existing The resulting MST-based sub-trees variants are then including reconnected Christofides by selecting (12.77% the shortest and 9.10%),link between leaf nodes. The second strategy, all-pairs, considers all possible removal and reconnection Prim-TSP (6.57% and 3.84%), and Kruskal-TSP (4.87% and 2.66%). Although sub-optimal, possibilities and selects the best pair. the algorithm is useful to provide reasonable estimate for the TSP solution.