N-body Approach to the Traveling Salesman Problem (TSP)
Johnny Seay, Edwin Gonzalez, Stephen Lowe, Jesse Crawford, Bryant, Wyatt

TL;DR
This paper introduces a novel N-body computational approach to solving the Traveling Salesman Problem, aiming to improve efficiency in finding optimal routes in complex, real-world applications.
Contribution
The paper proposes a new N-body based method for TSP, offering an alternative to existing approximation techniques with potential for enhanced performance.
Findings
Demonstrates the effectiveness of the N-body approach on benchmark TSP instances
Shows potential for faster convergence compared to traditional methods
Provides insights into the physical simulation analogy for combinatorial optimization
Abstract
In the Traveling Salesman Problem (TSP), a list of cities and the distances between them are given. The goal is to find the shortest possible route that visits each city exactly once and returns to the original city. The TSP has a wide range of applications in many different industries including, but not limited to, optimizing mail and shipping routes, guiding industrial machines, mapping genomes, and improving autonomous vehicles. For centuries, traveling salesmen, politicians, and circuit preachers have tackled their own versions of the problem. Within the last century, the TSP has become one of the most important problems in the fields of mathematics and computer science. The time to find an exact solution is often impractically long, which has led to the development of numerous approximation techniques, ranging from linear programming methods to nature-inspired models. Here, we…
| Number of Cities | Average N-body Percent Error | Average Nearest Neighbor Percent Error |
| 8 | 1.2311% | 8.0474% |
| 9 | 2.5020% | 9.7363% |
| 10 | 2.1861% | 9.9390% |
| 11 | 2.4125% | 11.2259% |
| 12 | 4.0270% | 13.4567% |
| Instance | Number of Cities | Simple N-body Percent Error | Pressure N-body Percent Error | Bubble N-body Percent Error |
| 4x4 Grid | 16 | 10.355% | 10.355% | 0.000% |
| att48 | 48 | 15.927% | 10.272% | 6.576% |
| bayg29 | 29 | 15.413% | 8.227% | 3.445% |
| ch150 | 150 | 32.193% | 15.636% | 29.118% |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsOptimization and Search Problems · Vehicle Routing Optimization Methods · Metaheuristic Optimization Algorithms Research
N-BODY APPROACH TO THE TRAVELING SALESMAN PROBLEM (TSP)
Johnny Seay1
Edwin Gonzalez
Stephen Lowe
Dr. Jesse Crawford
Dr. Byrant Wyatt
N-BODY APPROACH TO THE TRAVELING SALESMAN PROBLEM (TSP)
Johnny Seay1, Edwin Gonzalez2, Stephen Lowe3,
Dr. Jesse Crawford4, Dr. Byrant Wyatt5
Department of Mathematics, Tarleton State University
Box T-0470, Stephenville,TX 76402
Abstract
In the Traveling Salesman Problem (TSP), a list of cities and the distances between them are given. The goal is to find the shortest possible route that visits each city exactly once and returns to the original city. The TSP has a wide range of applications in many different industries including, but not limited to, optimizing mail and shipping routes, guiding industrial machines, mapping genomes, and improving autonomous vehicles. For centuries, traveling salesmen, politicians, and circuit preachers have tackled their own versions of the problem. Within the last century, the TSP has become one of the most important problems in the fields of mathematics and computer science. The time to find an exact solution is often impractically long, which has led to the development of numerous approximation techniques, ranging from linear programming methods to nature-inspired models. Here, we present a novel N-body approach to the TSP.
Introduction
Background
Before the invention of railroads or automobiles, traveling was a demanding and time consuming part of life. What would take us hours or days would take them weeks, months, or even years. Because of this, some professions (such as traveling salesmen, politicians, and circuit preachers) greatly benefited from carefully planned routes [1]. However, when narrowing the scope to just mathematical history, touring problems have been studied since the mid-1700s, when Leonhard Euler presented his famous Seven Bridges of Königsberg problem to the St. Petersburg Academy [3]. Despite this, it took roughly 200 years before the Traveling Salesman Problem received its first mathematical consideration when Merrill Flood was looking to solve a school bus routing problem [7]. Since then, the TSP has become a popular problem in mathematics and computer science. It is one of the most intensively studied problems in optimization and is often used as a benchmark for optimization methods.
Approximation Algorithms
Running times for exact algorithms have a lower bound of and an upper bound of [8]. For many real-world applications of the Traveling Salesman Problem, these running times are impractical. As a consequence, it may be more beneficial to work with a good approximation than to spend the time finding the exact solution. Because of this, approximation methods and algorithms are often chosen over exact algorithms. Some of these include the nearest-neighbor algorithm, the convex-hull-and-line algorithm, the Christofides algorithm, and Ant-Colony optimization. The nearest-neighbor simply has the traveling salesman pick the closest unvisited city to move to next. The convex-hull-and-line algorithm considers the fact that “in the euclidean plane the minimal (or optimal) tour does not intersect itself” in order to find solutions [4]. The Christofides algorithm combines a minimum spanning tree and a minimum-weight perfect matching to produce approximate solutions [5]. A nature-inspired method, the Ant Colony optimization models the observation that ants prefer to follow trails containing pheromones deposited by other ants [2]. Of course, there are many other approaches and algorithms inspired from all facets of life, nature, and mathematics.
N-Body Simulation
Before we delve into how we use N-body simulations in our approach to the Traveling Salesman Problem, it may be useful to describe what an N-body simulation is. In essence, an N-body simulation is a dynamical system of particles. These particles interact with each other through forces (e.g. gravitational or spring forces). The particles may also be influenced by additional external forces. Typically, N-body simulations are used to simulate physical processes with the scale of such phenomena ranging from intramolecular dynamics to galaxy formations [6]. However, we will be using N-body simulations to solve a combinatorial optimization problem. In simpler terms, and to highlight the novelty of our approach, we are using physics to find solutions to an abstract mathematical problem.
Methodology
General/Simple
With our N-body approach, each city is treated as a particle. The particles interact with each other through an attractive-repulsive force; for this we use a Lennard-Jones type force. To briefly describe this interaction, consider a pair of particles and the initial distance between them. This initial distance will be referred to as the natural distance. If the two particles are further apart than their natural distance, they will be attracted to each other. If the particles are closer together than their natural distance, they will be repulsed by each other. To penalize moves between distant cities, the magnitude of the repulsive force is much greater than that of the attractive force. For a more detailed explanation and analysis of the Lennard-Jones type force functions, see Appendix B.
We define the origin of the system to be the geometric center (or center of mass) of the particles. To keep the system contained, the particles will be surrounded by a minimum bounding circle, centered at the origin (see Figure 1(a)). This bounding circle acts as a wall, pushing particles inward. We refer to this bounding circle as the outer wall. Additionally, a circle with an initial radius of zero will be placed at the origin (see Figure 1(b)). This inner circle works as a wall pushing particles outward and will be referred to as the inner wall.
Over time, this inner wall will grow, increasing its radius until it reaches the outer wall. As the inner wall grows, it will push against the particles it comes into contact with. In turn, those particles will push or pull on the other particles. This process is visualized in Figures 1(c)-1(f). By the time the inner wall has reached the outer wall, all of the particles will have been forced into a ring, trapped between the inner and outer walls (see Figure 1(g)). We observe the order in which the particles fall on this ring to obtain a path in the initial city configuration (see Figure 1(h)). The outer and inner circles being treated as walls acting on the particles allow us to squeeze this two-dimensional system into a one-dimensional path. The motivation behind this approach is that the system will try to minimize its energy as the particles are being forced into a ring. The idea is that a connection between the minimal energy state of the ring and an optimal path exists.
Preliminary Results
In order to determine if this approach was feasible, we first ran our N-body simulation on relatively small sets of independent randomly generated instances and compared our results with the exact cost and the nearest-neighbor algorithm. These results are shown in Table 1. The data for these results can be found online by following the link provided in the Supplemental Material section. To find the exact costs for these randomly generated instances we used the brute-force approach; hence the cutoff at 12 cities. The percent error presented in the results is a measurement of how close the approximated cost is to the exact cost, as a percentage of the exact cost (shown below).
[TABLE]
Looking at the results presented in Table 1, we saw potential in this approach. Moving on to slightly bigger instances, the N-body results for a 4x4 grid instance are presented in Figure 2. Finding an optimal solution for full grid instances is relatively simple and can be done by hand, even for a large number of cities. For these instances, an optimal solution can be found by minimizing the number of diagonal edges within the path. Next, we tried our approach on the att48 instance. This instance consists of the capitals of the 48 contiguous states. The optimal cost for this instance is known. These results are presented in Figure 3. The average runtime of the simulation for these specific instances are included in order to provide the reader with some insight into the time it takes to find a solution with this approach. More results for these two instances will be provided throughout this text. Results for additional instances are provided in Appendix A.
Variations/Features
As the number of cities increases, the system may become dense. Consequently, the potential energy within the system increases. As a result, the system has a propensity to become increasingly more erratic as the area between the two walls approaches zero. This erratic behavior results in undesirable solutions. Another complication arises when dealing with non-uniform instances of the TSP. With non-uniform instances, denser groups of particles tend to move as a single unit. As these clumps of particles are squished between the walls, they exhibit similar erratic behavior to that mentioned previously but on a smaller scale. We have found that breaking these clumps up can yields better results. Addressing these erratic phenomena is crucial in optimizing our N-body approach.
Pressure/Global Density
As mentioned earlier, erratic behaviour appears when working with dense instances for two reasons. The particles do not have sufficient time to readjust themselves into a desirable configuration and the total force in the system can go beyond the limits of the numerical scheme as the separation of the walls approaches zero, resulting in the particles breaking through the walls. This can be seen in Figure 4. To address this, we initially added sufficient perimeter to the outer wall to handle the total force generated. However, this resulted in the entire system clustering to one side of the inner wall, as seen in Figure 5. This also produced undesirable results. Our next step was to allow the outer wall to adjust accordingly to the state of the system by measuring the forces exerted on the outer wall. We refer to the summation of these forces divided by the perimeter of the outer wall as pressure. If the pressure falls outside of an acceptable range, the outer wall will grow or shrink accordingly. This achieves the desirable effects of giving the system more time and room to move into lower energy states while maintaining the integrity of our numerical scheme. This can be seen in Figure 6.
Some results of our N-body simulation with pressure implemented are shown in Figure 7 and Figure 8. For the 4x4 grid instance, this pressure variation resulted in a different path but yielded the same cost as the simple N-body. However, for the att48 instance, this pressure variation resulted in a significant improvement over the results produced by the simple N-body approach. Additional results showcasing the improvements provided by adding pressure can be found in Appendix A, Figures 16-18.
Clumping/Local Density (“Bubble” Method)
As stated earlier, non-uniform instances can result in localized clustering which can produce undesirable results (see Figure 9). In order to address this issue, additional circles are inserted in the denser areas of the system in an attempt to break them apart. These additional circles also act as walls pushing on the particles; we refer to these additional circles as bubbles to differentiate them from the outer and inner walls. To decide where to insert these bubbles, a rough density map is created by partitioning the space into cells and counting the number of particles in each cell. For each non-empty cell, the center of mass of the particles within that cell is calculated. For cells with density above a given value, their center of masses are used as the insertion points for the bubbles. This process is visualized in Figure 10.
Some results of our N-body simulation with bubbles implemented are shown in Figure 11 and Figure 12. These additional bubbles result in much better approximations compared to the simple N-body approach described earlier.
Comparison Of The Different Method Variations
Table 2 summarizes the results of the different variations across different TSP instances. These results are shown here in an effort to highlight the improvements provided by the different variations of our N-body approach, as well as to showcase the potential future variations may have. From these results, we see that bubbles do not always provide an improvement, as seen with the ch150 instance. Additional results for the bayg29 and ch150 instances are provided in Appendix A.
Conclusion
Considering the early results presented in this text and the direction of recent improvements, we believe this is a promising approach. So far, we are able to rapidly obtain good solutions. Additionally, this approach showcases that perhaps solutions or better approximations can be found by approaching the problem in a unique and novel way. By viewing abstract problems with a physical perspective, one can draw on the vocabulary and intuition built in the physical world. This will hopefully allow us to describe the theoretical ideas and characteristics of the problem with physical terms. Furthermore, our work may be the foundation to approaching other problems related to the Traveling Salesman Problem, such as the popular open millennium problem of whether or not .
Future Work
The motivation behind our future work is the desire to obtain accurate results on larger datasets in less time. To do this, there are many directions we are considering. For instance, we find it necessary to perform some type of parameter optimization. These parameters include the parameters for our Lennard-Jones type force functions, wall strength, the rate of change of wall radius, the simulation time step, the lower and upper bounds of the pressure range, local density cutoffs, and the number of bubbles to insert. Understanding the relationships between these parameters and the impact they have on the final result is important in trying to improve results. Another facet to consider is our implementation of the N-body simulation. Currently we are utilizing a brute-force approach in the N-body simulation. However, there are other N-body implementations that may allow us to reduce the runtime of our simulations. We also need to investigate other force functions. Perhaps there exists other force functions that are better suited for this approach than the Lennard-Jones type force functions we are currently using. In a more interesting direction, we would like to explore moving the simulation into higher-dimensional spaces. At the moment, our simulation only exists in a two-dimensional space. Perhaps letting the simulation run in higher-dimensional spaces will produce better results and allow us to tackle multi-weighted graphs. Current thoughts revolve around the idea of using a torus to facilitate the process of taking an -dimensional system and constricting it to a one-dimensional path. Finally, we would like to extrapolate and investigate the relationships between the physical parameters and the abstract ideas of the problem.
Acknowledgements
Tarleton State University’s College of Science and Technology for research and travel funds. Tarleton State University’s Mathematics Department for valuable suggestions and feedback. Tarleton State University’s High Performance Computing Lab for space and computational resources. Nvidia for providing us with graphical processing units (GPUs) used for computational acceleration.
Supplemental Material
For further reading, data, results, and videos visit https://seayjohnny.github.io/NBodyTSP
Appendix A More Results
Appendix B Reparameterizing Lennard-Jones Force Functions
Given a Lennard-Jones potential function, the negative of its derivative is the corresponding Lennard-Jones force function (LJF), which can be written in the following form.
[TABLE]
where , , , and are positive real numbers, and .
Equation (B.1) expresses the force acting on two particles based on their distance from each other, with positive and negative values corresponding to repulsive and attractive forces, respectively. The parameters , , , and govern the relative strength of the repulsive and attractive terms in , but unfortunately these parameters are difficult to interpret geometrically. The goal of this section is to reparameterize Lennard-Jones force functions using more geometrically meaningful parameters.
Proposition B.1 below shows that every LJF essentially has the same shape, as displayed in Figure 19. Arbitrarily large repulsive forces occur at small distances , followed by a unique root and a unique absolute minimum . As increases beyond , asymptotically converges to zero. In other words, there is an equilibrium distance at which the force is zero, followed by a point where the maximal attractive force is attained, after which the attractive force decays to zero. As a side note, Proposition B.1 also shows that every LJF is convex until reaching a unique inflection point and is concave afterwards.
Proposition B.1**.**
*Let be a Lennard-Jones force function determined by parameters
, where .*
** 2. 2.
** 3. 3.
* is uniquely satisfied by*
[TABLE] 4. 4.
* attains a unique absolute minimum at*
[TABLE] 5. 5.
The absolute minimum value is , where
[TABLE] 6. 6.
* has a unique inflection point at*
[TABLE] 7. 7.
.
Proof.
Properties (1) through (3) follow from the factorization
[TABLE]
The first and second derivatives of are
[TABLE]
Equation (B.4) shows that is strictly decreasing on the interval and strictly increasing on , establishing the existence of a unique minimum at
[TABLE]
Similarly, equation (B.6) shows that is convex on and concave on , with a unique inflection point at
[TABLE]
All that remains is showing . This is easily verified by using to rewrite Equation (B.2) as follows:
[TABLE]
∎
We now have three geometrically meaningful parameters , , and . A fourth parameter of interest, , will later be shown to control the decay rate of the attractive force. Proposition B.1 shows that the parameter vector determines the values of the parameter vector . Conversely, the following proposition shows that determines .
Proposition B.2**.**
Assume , where . Then there exist unique parameters , where , such that the corresponding Lennard-Jones force function satisfies the following.
** 2. 2.
* attains an absolute minimum at * 3. 3.
.
Proof.
The following equations sequentially define , , , and in terms of , , , and .
[TABLE]
These equations are derived by algebraically manipulating the equations from parts (3) through (5) of Proposition B.1.111This observation establishes uniqueness of . In practice, it is necessary to apply these equations in the order listed. For instance, must be computed using (B.8) before it can be used in (B.9) to compute . Similarly, and must both be computed before they can be used in to compute .
Because , Equation (B.8) defines a positive value for . It is then easy to verify that and . Therefore, Equations (B.8) through (B.11) define a parameter vector corresponding to a Lennard-Jones force function . Applying part (3) of Proposition B.1 to implies that it has a unique zero at
[TABLE]
Similarly, parts (4) and (5) of Proposition B.1 prove that is the absolute minimum. ∎
Propositions B.1 and B.2 establish a one-to-one correspondence between the parameter sets
[TABLE]
[TABLE]
reparameterizing Lennard-Jones force functions in terms of more geometrically meaningful parameters. All that remains is to investigate the role of the shape parameter , which requires the following lemma.
Lemma B.3**.**
If is a Lennard-Jones force function with parameters , and , then
[TABLE]
Proof.
First, we rewrite Equation (B.7) using the -parameterization
[TABLE]
The parameters and are simply horizontal and vertical scale parameters, so without loss of generality, assume . Because is an increasing function, if and only if .
[TABLE]
[TABLE]
After considerable algebraic simplification, we have
[TABLE]
Keeping in mind that , and , this denominator is positive, so it suffices to show the numerator is positive. Making the substitution , and , the numerator is
[TABLE]
Making a second substitution and , and noting that , it suffices to show that the following expression is positive:
[TABLE]
Rewriting this expression using the exponential function’s Maclaurin series, whose radius of convergence is infinite, and factoring out yields
[TABLE]
[TABLE]
by the Binomial Theorem. The second series is absolutely convergent, so we can rewrite the order of summation to obtain
[TABLE]
[TABLE]
∎
We are now prepared to discuss the impact of on the decay of the attractive force. After an LJF attains its minimum , it monotonically converges to [math]. Given , the Intermediate Value Theorem guarantees the existence of some unique , such that . For example, if , then is the point where the attractive force has decayed to 1% of its maximum magnitude. Choosing the value of provides control over the decay rate of the attractive force. For example, choosing to be much greater than means that the attractive force is still at 90% of its maximum magnitude for values of much larger than , i.e., the attractive force is decaying very slowly. On the other hand, choosing to be very close to implies a very rapid decay of the attractive force. The following theorem illustrates the importance of the parameter in determining .
Theorem B.4**.**
Consider a Lennard-Jones force function with fixed parameters , , and , assume , and define the function
[TABLE]
There exists , such that . 2. 2.
The set of possible values of is . 3. 3.
There is a one-to-one correspondence between the values of and . 4. 4.
** 5. 5.
.
Proof.
Because , it is routine to verify that is decreasing on , with and . Property (1) then follows from the Intermediate Value Theorem. Given , applying L’Hopital’s rule to Equation (B.13) provides values for the following limits:
[TABLE]
[TABLE]
Furthermore, by Lemma B.3, is a monotonically decreasing function of . Therefore, there exists , such that if and only if
[TABLE]
which holds if and only if . This inequality is equivalent to , since is decreasing on , which establishes Property (2). Properties (3) through (5) now follow from Lemma B.3 and the limits (B.14) and (B.15). ∎
In summary, this section has shown how to reparameterize Lennard-Jones force functions in terms of more geometrically meaningful parameters. Given desired values and , a Lennard-Jones force function can always be specified with equilibrium length and maximal attractive force . Choosing near results in an attractive force that ramps up quickly, while choosing much larger than corresponds to a slow increase of the attractive force’s magnitude. The decay of the attractive force is then specified as follows:
Choose some . 2. 2.
Compute by solving using a numerical method, such as Newton’s method. 3. 3.
Choose a desired value . 4. 4.
Use a numerical method and Equation (B.13) to solve for . 5. 5.
Use Equations (B.8) through (B.11) to compute , , , and , which fully specify the Lennard-Jones force function.
Only one value of can be specified, e.g., it is not possible to simultaneously choose arbitrary values for and , but overall, this approach still provides a great deal of flexibility. Hopefully this reparameterization allows researchers engaged in particle modeling to intuitively choose realistic parameter values for a variety of applications.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] William J. Cook “In Pursuit of the Traveling Salesman: Mathematics at the Limits of Computation” Princeton University Press, 2012
- 2[2] Marco Dorigo “Ant Colonies for the Travelling Salesman Problem” In Biosystems 43 , 1997, pp. 73–81
- 3[3] Leonhard Euler “Solutio Problematis ad Geometriam Situs Pertinentis” In Commentarii Academiae Scientiarum Petropolitanae , 1741, pp. 128–140
- 4[4] Vladimir G.Deineko “The Convex-Hull-and-Line Traveling Salesman Problem: A Solvable Case” In Information Processing Letters 51 , 1994, pp. 141–148
- 5[5] Michael Goodrich “The Christofides Approximating Algorithm” In Algorithm Design and Applications Wiley, 2015, pp. 513–514
- 6[6] Donald Greenspan “N-Body Problems and Models” World Scientific Pub. Co. Inc., 2004
- 7[7] Eugene L. Lawler “The Traveling Salesman Problem: A Guided Tour of Combinatorial Optimization” John Wiley Sons, 1985
- 8[8] Gerhard J. Woeginger “Exact Algorithms for NP-hard problems: A survey” In Combinatorial Optimization - Eureka! You Shrink! , Lecture Notes in Computer Science 2570 Springer, 2003, pp. 185–207
