Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Jon Pawley

MAT 392

The Traveling Salesman Problem at Taylor University


1

What is the Travelling Salesman Problem?


What is the shortest route to walk to every residence hall on the Taylor campus,
beginning and ending with the same hall? This problem can be solved with an understanding of
the Traveling Salesman Problem, an easy to understand yet hard to solve problem in the field of
discrete combinatorial optimization. The Traveling Salesman Problem is useful as an
introduction to optimization problems, and it also has immensely practical applications. This
paper will serve as an introduction to the computational difficulty of the Traveling Salesman
Problem and will also explore various approximation algorithms. After we have gained a
foundational understanding, we will apply our new understanding to our problem at Taylor
University.
The traveling salesman problem (TSP) is a combinatorial optimization problem, simply
stated as follows:
A traveling salesman wants to find the shortest tour to travel to every town on his list
exactly once, beginning and finishing with his hometown.

Examples
As an example of the purpose of the TSP, consider the following figures. In each of these
graphs the weight or cost of an edge is simply the Euclidean distance between the pair of
vertices. Intuitively, the shortest tour to travel between the vertices of Figure 1 is to follow the
edges highlighted in red on the left side. TSP solutions in general are roughly elliptical, thus the
tour highlighted on the right is intuitively suboptimal. To further show the power of intuition in
solving the TSP, experiments have even been done with animals including monkeys and pigeons
[1] to show that even they have an intuitive understanding of the shortest tour between
objects.
2

Figure 1: The tour on the left is intuitively shorter than the one on the right.

Figure 2: Pigeon solving a TSP

Figure 3: It is not intuitively clear which tour is shorter.


3

Our intuition becomes less helpful when the vertices in the graph have a less elliptical
layout. For example, in Figure 3 it is not obvious which tour is the shortest, thus the value of
analyzing the TSP mathematically.

Nonexamples
Figure 4 shows three nonexamples of TSP solutions. The leftmost tour is not a TSP
solution because the TSP requires that the tour be a circuit. The circuit in the middle does not
contain every vertex and is therefore not a TSP solution. The rightmost tour is a nonexample
since the TSP requires that no vertices be repeated except for the beginning and ending vertex.
Intuitively, repeating vertices will result in suboptimal travel cost.

Figure 4: Nonexamples of TSP tours

Applications
The TSP has many applications including optimizing school bus routing, circuit board
design, mail delivery, political campaigning, telescope guidance, and of course optimizing the
route taken by a traveling salesman. The software that my friend used to plan his forklift routes
while he worked at the Walmart distribution center near Gas City, IN almost certainly used
mathematics related to the TSP. Even without the numerous applications, the TSP would still be
important because it is an easy to understand yet hard to solve example of combinatorial
optimization.

Computational Difficulty
We will now further explore the difficult of the TSP. The TSP is a member of the NP-hard
complexity class. NP problems cannot be solved in polynomial time, but any potential solution
to an NP problem can be verified in polynomial time. Problems in the NP-hard class are even
harder than problems in the NP class in that they cannot even be verified in polynomial time.
4

An example of an NP problem versus a problem in the P class (solvable in polynomial


2 3
time) can be found in linear algebra. Reducing an n × nmatrix requires roughly n operations
3
and has complexity P since it is solvable in polynomial time. Finding a determinant of an n × n
matrix (naively using the straightforward method) on the other hand requires n ! operations
and is therefore not solvable in polynomial. It follows then that finding a determinant has a
complexity level of at least NP. The complexity of the TSP comes from the fact that it involves
factorials, which require even more computational power than exponentials, which in turn
require more than polynomials. For instance, recall how when taking a limit in calculus over
time a factorial will overpower an exponent, which in turn will overpower a polynomial.
We will now develop a more concrete understanding of the complexity of the TSP.
When discussing the TSP, we will use the language of graph theory and refer to vertices instead
of cities/towns and edges instead of roads. If there are n vertices in a complete graph (a graph
in which there exists an edge between every pair of vertices), then there are (n−1¿ ! different
possible circuits that visit every vertex in the graph exactly once. This is because we begin at
one of the n vertices and can choose between n−1 vertices to travel to next. On each
successive vertex that we travel to we have 1 fewer vertices to choose from for our next trip
because of the condition that we visit each vertex exactly once. A brute force examination of a
larger TSP, for example with n=70, would require an impossible amount of computational
power. Thus, while there clearly is an exact solution to any sized TSP, once n becomes even
modestly large it becomes impossible to determine what the exact solution is. Because of the
impossibility of solving most TSPs by brute force, we need to examine algorithms that are more
computationally efficient.
We should note that the TSP problem can also be done with graphs that are not
complete, and that solving a TSP on a non-complete graph is potentially easier since there are
fewer edges to take into consideration.
5

Algorithms to solve the TSP


Solve by Listing all Permutations of Hamilton Circuits
Figure 5 is adapted from [5]. Since there are only 5 vertices in this graph, it will not be
too difficult to solve simply by listing all possible Hamilton circuits. As stated above in the
section on computational difficulty, there are ( n−1 ) ! circuits that need to be examined for any
( n−1 ) !
TSP. However, of these circuits there are only unique Hamilton circuits (a circuit that
2
1
includes every vertex in the graph exactly once). Intuitively, this is of the earlier number since
2
earlier we double counted each Hamilton circuit e.g., the circuit a,b,c,d,e,a is the same as the
( 5−1 ) !
circuit a,e,d,c,b,a only in reverse order. Therefore only =12 permutations need to be
2
listed in the table below.

Figure 5

Permutation Length
a,b,c,d,e,a 19
a,b,d,c,e,a 17
a,d,c,e,b,a 20
a,c,b,d,e,a 18
a,c,d,b,e,a 19
a,d,b,c,e,a 16
a,d,e,c,b,a 19
a,b,d,e,c,a 19
a,b,e,d,c,a 22
6

a,c,b,e,d,a 21
a,c,e,b,d,a 19
a,d,c,b,e,a 19
The permutation a,d,b,c,e,a has length 4 +2+2+5+3=16and is therefore the shortest Hamilton
circuit for the graph and the TSP solution to the tour.

Figure 6: Solution

Graph Reduction
There are no known algorithms in the polynomial complexity class that can solve the
TSP. Furthermore, it is strongly suspected that no such algorithm with polynomial complexity
exists. Thus, for any given algorithm we choose to use, any reduction in the number of vertices
in the graph has the potential of greatly reducing the computational time. Reductions generally
take two forms, either 1) deleting unnecessary vertices such as a vertex that is part of a sub-
path that must always be followed the same way in every Hamilton circuit of the graph, or 2)
deleting unnecessary edges, for example, any edge that is not the shortest edge between a
given pair of vertices. Another example of an unnecessary edge can be found in specific cases of
non-symmetric graphs (graphs such that for any vertices A and B, the travel cost
( A , B ) does not always equal(B , A )¿ .
For our application to the Taylor University campus and for the most general
applications, the graph being studied will be complete, non-directional, and will have only one
edge between each pair of vertices, thus neither of the two reduction methods will be helpful.
Even in other cases, reductions may not always be possible, and they may still not reduce the
7

problem enough for it to be solvable in a reasonable amount of time. In all these cases, we may
find that a good approximation of the solution is sufficient for our purposes.

High and Low Approximation and Christofides


A graph has symmetric travel costs if traveling from A to B costs the same as traveling
from B to A. The triangle inequality states that for any vertices A,B, and C, the travel costs
( A , B )+( B , C)≥( A ,C ). If the two previous conditions are fulfilled in a graph, then there is a
polynomial-time algorithm discovered by Christofides that can find a tour that is no greater
3
than times the travel cost of an optimal tour.
2
Christofides algorithm can be explained as follows. Given a complete graph G with
vertices V , the algorithm works as follows. First, we find a minimum cost spanning tree (a
minimum cost tree that contains every vertex) T ∈G . The travel cost of T is guaranteed to be
no more than the optimal tour. “We then compute a minimum-cost perfect matching (a set of
edges such that every vertex in the graph is adjacent to exactly one edge) M in the subgraph of
G spanned by the vertices that meet an odd number of edges in T ” [3]. Since any tour is the
1
union of two perfect matchings, then the travel cost of M is no more than times the cost of
2
an optimal TSP tour. The union of the edges on M and the edges on T form a graph H on the
vertices V such that every vertex meets an even number of edges. The graph H thus has an
Eulerian cycle, a tour that begins and ends at the same vertex and visits every edge of H (note
that this differs from a Hamilton circuit since the Hamilton is required to visit every vertex). The
Eulerian cycle visits every edge of H , which contains all the edges of T and M ; since the cost of
1
T is no greater than 1 times an optimal tour, and the cost of M is no more than times an
2
1 3
optimal tour, therefore the cost of the Eulerian cycle is no more than 1+ = times an optimal
2 2
tour. To transform the Eulerian cycle to a TSP tour simply traverse the cycle skipping over every
repeated vertex. Due to the triangle inequality, the cost of this new tour is no more than the
8

3
cost of the Eulerian cycle. The cost of the resulting tour is therefore no more than times the
2
cost of an optimal tour.
Christofides algorithm above requires that we find a minimum cost spanning tree. For
our specific application, this will not be too difficult to accomplish by hand using Prim’s
algorithm. Prim’s algorithm is likely familiar to any beginner computer scientist because of its
ease of programming and its usefulness as an example of a greedy algorithm (it uses the
heuristic of making the locally optimal choice at each stage of the algorithm). Prim’s algorithm
for finding a minimum cost spanning tree can be described as follows:
1. Start the tree by choosing an arbitrary vertex.
2. Connect the tree to a vertex not in the tree by choosing the minimum cost edge from
the tree to a vertex not on the tree.
3. Repeat step 2 until all vertices are in the tree.

Concorde Software
The computer program Concorde contains over 130,000 lines of code and has been used
to solve TSPs with up to 85,900 vertices. The goal of this program is to find exact solutions to
large TSPs and is not as concerned with quickly finding solutions to smaller problems. Concorde
can, within several minutes, find solutions to TSPs with thousands of vertices. However, even
this program has its limits. For example, the World TSP involving 1,904,711 cities is out of range
for an exact solution by Concorde because of its size. The algorithm used by Concorde is
extremely complex and is beyond the scope of this article.

Application to Taylor University


Defining Terms
The goal is to study the TSP with sufficient depth that we can apply the concepts to the
campus of Taylor University. Because of the tediousness of measuring distances between
buildings, we will limit our study to the residence halls only. We will also consider Breuninger
and Gerig to be one vertex, and will denote the residence halls as follows:
9

B: Bergwall
E : English
G : Gerig/Breu
O : Olson
M : Samuel Morris
S: Swallow Robin
W : Wengatz
The measured distance in meters of an edge–for example between Wengatz and Olson–will be
denoted as ( W , O )=134 . We will measure the distances with the Google Earth website, with
distances following walkways or streets on Taylor’s campus, and crossing streets only at
designated crosswalks. All distances will be measured roughly from the point of the front desk
in each residence hall, except for measurements from Gerig/Breu which will be measured from
the doorway between the Gerig and Breuninger lobbies. The goal is for any route between a
pair of dorms to be possible for a person of either gender provided that the lobby is open, thus
routes may go through any lobby door, but not through a wing or hallway.

Data Collection
Since there are 7 vertices, if I arbitrarily begin my measuring process at vertex W , I will
need to measure 6 paths between W and each member of the set {B , E , G, O , M , S }. For the
next vertex I choose to measure from, say O , we will have to measure 5 paths to every other
dorm except Olson and Wengatz. Thus, the number of edges to be measured is greater than or
6
equal to ∑ i=21. The actual number of distances we will need to measure may be greater than
i=1

21 since we may need to measure multiple paths between a pair of dorms to identify which is
the shortest. However, the final graph will contain exactly 21 edges since we will only retain the
shortest edge between any pair of vertices.
10

Figure 7: Weighted graph of Taylor University residence halls

( 7−1 ) !
There are therefore =360 Hamilton circuits for the set of set of vertices
2
containing dorms for Taylor University. This is clearly too many permutations to list out by hand
to determine the shortest.

Application of Christofides Algorithm


Prim’s Algorithm to find a Minimum Cost Spanning Tree
We will use X to denote the optimal TSP tour. The complete graph with vertices V
necessary for Christofides algorithm is displayed in Figure 6 above. Note that G now refers to
the vertex representing Gerig/Breuninger and does not represent the complete graph. Using
Prim’s algorithm, we can then construct the minimum cost spanning tree T as follows:
1. Arbitrarily begin at W . Thus T 1={W }
2. The closest vertex to T 1 is O , since ( W , O )=134 is the shortest edge adjacent to W . Thus
T 2={W , O }

3. Now G is the vertex in T 2' that is closest to T 2 since ( W , G )=178. Thus T 3={ W , O ,G } .
11

4. Now E is the vertex in T 3' that is closest to T 3, since ( G , E )=142 is the shortest edge
adjacent to T 3 that is also adjacent to a vertex in T 3 ' . Thus T 4={W , O, G , E }
5. Continue this process to find that the minimum spanning tree T spans G with the edges
{ (W ,O ) , ( W , G ) , ( G , E ) , ( W , B ) , ( O, M ) , ( M , S ) }.
According to Christofides algorithm, the sum of the edges of T ,c ( T ) , is no more than the travel
cost of X , c ( X ) (the cost of the optimal TSP tour). Thus c ( T ) =1416 ≤ c( X ).

Figure 8: Minimum spanning tree T

Find a Minimum Cost Perfect Matching


The next step in Christofides algorithm is to create a minimum cost perfect matching M
with only the vertices in G that are adjacent to an odd number of edges in T . By inspection of
Figure 8, we can see that the only vertices adjacent to an odd number of edges in T are
B ,W , S ,∧M . The 4 possible perfect matchings with those vertices are listed with the sum of
their edge weights:
 ( B , S )+ (W , E )=742+234=976
 ( B , E )+ ( S ,W )=410+623=1033
 ( B ,W ) + ( S , E )=345+780=1125
12

1
Thus M ={ ( B , S ) , ( W , E ) } . As stated above on page 7, c ( M ) ≤ ⋅c ( X ). Since c ( M )=976 , then by
2
algebra 1952 ≤ c ( X ) .
Combine T and M to find the Christofides Approximation
The union of T and M is shown in Figure 9 below. This graph contains an Eulerian cycle
3
and is guaranteed to be no more than times the travel cost of X . Thus,
2
3
2392=c ( T ∪ M ) ≤ ⋅ c (X ), and 1595 ≤ c (X ).
2

Figure 9: Union of minimum cost tree T and minimum cost perfect matching M

Notice that if we were to follow the red edges on Figure 9, arbitrarily beginning and ending at
vertex S, we would follow either S− M −O−W −E−G−W −B−S or
S− M −O−W −G−E−W −B−S . Neither of these tours satisfy the conditions of a TSP solution
because W is repeated. We can remove this issue and further decrease our travel costs by use
of the triangle inequality. The sub-paths G−W −B and E−W −B in the two tours can be
shortened using the triangle inequality to G−B and E−B , respectively. Thus, our two original
tours can be shortened to S− M −O−W −E−G−B−S or S− M −O−W −G−E−B−S. The
13

first tour has a travel cost of 107+510+ 134+234 +142+383+742=2252. The second tour has a
travel cost of 107+510+ 134+178+142+ 410+742=2223 . Thus, the second tour, shown in
Figure 10, is the best option for our Christofides approximation, denoted as C . We now have a
3
potential TSP solution, and we know from Christofides algorithm that 2223=c ( C ) ≤ ⋅ c ( X ) .
2
Thus, 1482 ≤ c( X ). Of the 4 lower bounds we have come up with so far, the most useful comes
from M . When we combine that lower bound with the upper bound of 2223 (since C is a
potential solution, any potential solution that costs more than C can be disregarded), we find
that 1952 ≤ c ( X ) ≤ 2223. In terms of the actual problem, this means that the TSP solution for the
Taylor residence halls has a travel cost more than 1952 meters and less than 2223 meters.

Figure 10: Christofides approximation

Robustness of Christofides Algorithm


We can see that the Christofides approximation is fairly robust in this case, that is, small
changes in the lengths of the edges will not affect the resulting tour that is used. This is largely
because of the nature of the greedy algorithms used for this approximation since algorithms
choose the locally optimal option. Another reason for the robustness of the algorithm in this
14

case is the high variability of the edge weights (σ =237.5 while μ=464.6). Step 2 of Prim’s
algorithm above provides a concrete example of how this variability increases the robustness of
the algorithm. Edge ( W , O )=134 and the second shortest edge adjacent to W is ( W , G )=178.
Edge ( W , G )would need to be more than 44 m shorter before it would be chosen over ( W , O ).
Thus, even moderate differences in the measurements still would not affect the choice of
(W , O) in constructing the minimum cost spanning tree.

Future Research
Specific Extensions
We have found a potential solution to our TSP at Taylor and have fairly close upper and
lower bounds to use with other approximation methods. I would like to try several other
approximation algorithms to try to close in the distance between our estimates. I also want to
learn how to use the Concorde program to find an exact solution, and to study the robustness
of the program itself. I am also intrigued by how the TSP solution would change based on
whether the traveler is male or female and can enter certain residence halls through side doors
rather than being restricted only to lobby doors. Another interesting question to investigate is
how the problem will change if we measure distance “as the crow flies” rather than on
sidewalks and crosswalks.
I am further interested in exploring other problems on Taylor’s campus using graph
theory and the TSP. For example, I am fascinated with the idea of working with the Admissions
Department to plan their tour routes for prospective students, or to partner with a computer
scientist to design an app to optimize walking between classes based on a person’s class
schedule.

General Extensions
In addition to the possible extensions to apply to the Taylor campus, I am curious about
some other applications of the TSP. For example, although many TSPs already consider 3-
dimensional changes in elevation, it would be interesting to study how the TSP could model a
more interesting 3D space than Upland, IN. Applications here could include graphs made in
more mountainous terrain or between planets. The graph theory in the TSP as I have studied it
15

models 3D space on a 2D graph, so I am also curious as to how graph theory could be used to
model higher dimensions, for example modeling 4D space onto a 3D or 2D graph.
I am also excited to see how further developments in quantum computing affect
whether even larger TSPs can be solved via Concorde or other algorithms.

Conclusion
In this paper we have examined some of the foundational knowledge necessary to
understand and approximate the TSP. Now, if you are ever a part of the next Swallow Robin
open-house that the men of Samuel Morris put on every year, you will know a lot more about
how to optimize your travel route as you begin at Swallow, tour through every dorm on campus
picking up partiers along the way, and end back in Swallow for the finale.
16

Bibliography
1. Cook, William J., David L. Applegate, Robert E. Bixby, and Vasek Chvatal. The traveling
salesman problem: a computational study. Princeton university press, 2011.

2. Hoffman, Karla L., Manfred Padberg, and Giovanni Rinaldi. "Traveling salesman
problem." Encyclopedia of operations research and management science 1 (2013): 1573-
1578.

3. Higham, Nicholas J., Mark R. Dennis, Paul Glendinning, Paul A. Martin, Fadil Santosa, and
Jared Tanner, eds. Princeton companion to applied mathematics. Princeton University
Press, 2015.

4. Jünger, Michael, Gerhard Reinelt, and Giovanni Rinaldi. "The traveling salesman
problem." Handbooks in operations research and management science 7 (1995): 225-
330.

5. Michaels, John G., and Kenneth H. Rosen, eds. Applications of discrete mathematics. Vol.
267. New York: McGraw-Hill, 1991.

6. “Minimum Spanning Tree.” Wikipedia. September 18, 2023.


https://en.wikipedia.org/wiki/Minimum_spanning_tree.

7. Nahin, Paul J. "When Least Is Best: How Mathematicians Discovered Many Clever Ways
to Make Things as Small (or as Large) as Possible." (2003).
17

8. “Perfect Matching.” Wikipedia. June 19, 2023.


https://en.wikipedia.org/wiki/Perfect_matching.

9. “Prim’s algorithm.” Wikipedia. October 17, 2023. https://en.wikipedia.org/wiki/Prim


%27s_algorithm

You might also like