<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JAMP</journal-id><journal-title-group><journal-title>Journal of Applied Mathematics and Physics</journal-title></journal-title-group><issn pub-type="epub">2327-4352</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jamp.2024.124095</article-id><article-id pub-id-type="publisher-id">JAMP-132998</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  On the “Onion Husk” Algorithm for Approximate Solution of the Traveling Salesman Problem
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Mikhail</surname><given-names>E. Abramyan</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Nikolai</surname><given-names>I. Krainiukov</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Boris</surname><given-names>F. Melnikov</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Faculty of Computational Mathematics and Cybernetics, Shenzhen MSU-BIT University, Shenzhen, China</addr-line></aff><pub-date pub-type="epub"><day>11</day><month>04</month><year>2024</year></pub-date><volume>12</volume><issue>04</issue><fpage>1557</fpage><lpage>1570</lpage><history><date date-type="received"><day>20,</day>	<month>February</month>	<year>2024</year></date><date date-type="rev-recd"><day>27,</day>	<month>April</month>	<year>2024</year>	</date><date date-type="accepted"><day>30,</day>	<month>April</month>	<year>2024</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  &lt;div style=&quot;text-align:justify;&quot;&gt; The paper describes some implementation aspects of an algorithm for approximate solution of the traveling salesman problem based on the construction of convex closed contours on the initial set of points (“cities”) and their subsequent combination into a closed path (the so-called contour algorithm or “onion husk” algorithm). A number of heuristics related to the different stages of the algorithm are considered, and various variants of the algorithm based on these heuristics are analyzed. Sets of randomly generated points of different sizes (from 4 to 90 and from 500 to 10,000) were used to test the algorithms. The numerical results obtained are compared with the results of two well-known combinatorial optimization algorithms, namely the algorithm based on the branch and bound method and the simulated annealing algorithm. &lt;/div&gt;
 
</p></abstract><kwd-group><kwd>Branch and Bound Method</kwd><kwd> Contour Algorithm</kwd><kwd> “Onion Husk” Algorithm</kwd><kwd> Simulated Annealing Method</kwd><kwd> Traveling Salesman Problem</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Combinatorial optimization problems and methods for solving them are constantly evolving and improving; one such problem is the traveling salesman problem (TSP), which belongs to classical NP-complete problems [<xref ref-type="bibr" rid="scirp.132998-ref1">1</xref>]. It should be noted that the combinatorial optimization methods used to solve this problem can be used more widely―for optimization, search and processing of complex data and other combinatorial objects.</p><p>A large number of numerical methods for approximate solutions have been developed for the traveling salesman problem [<xref ref-type="bibr" rid="scirp.132998-ref2">2</xref>]. We discuss various aspects of the implementation of an algorithm that has received relatively little attention in the literature. This is the contour algorithm, or “onion husk” algorithm, which can be applied to approximate the solution of the so-called geometric TSP for which not only the distance matrix, but also the points themselves (“cities”) in the plane are given. The contour algorithm is based on the construction of nested convex contours connecting the initial points (<xref ref-type="fig" rid="fig1">Figure 1</xref>) and the subsequent integration of these contours into a final closed path. The advantage of this algorithm is its high speed, while the obvious disadvantage is the approximate nature of the solution. At the same time, by applying additional heuristics at the main stage of the algorithm―merging the initial convex contours into the final closed path―it is possible to improve the results obtained.</p></sec><sec id="s2"><title>2. Construction of a Set of Convex Contours and Related Cutoff Heuristics</title><p>We start with brief discussion of the ways of implementing the first stage of the contour algorithm where a family of nested convex contours is constructed. The problem of constructing a convex hull is a classical problem in computational geometry, and there are a number of efficient algorithms for its solution, in particular the Graham and Jarvis algorithms.</p><p>The Graham algorithm consists of two stages. At the initial stage (preprocessing), the initial set of points is sorted by a certain characteristic (increasing angle formed by the given point and some fixed point). At the main stage (traversal), the sorted points are bypassed and the required convex hull is constructed. Due to the preprocessing step, the complexity of this algorithm is O (n log n), where n is the number of points.</p><p>The Jarvis algorithm, also called the “gift wrapping” algorithm, also consists of two stages. In the first stage (preprocessing), some edge point of the set (e.g. the</p><p>point with minimum abscissa min (X)) is chosen; this point is obviously included in the convex hull. In the second stage (traversal), the remaining points of the convex hull are successively constructed by analyzing the angles formed by one or two last obtained points of the hull and all points of the original set. Thus, the complexity of this algorithm is O (nq), where q is the number of points in the constructed convex hull (when finding each of the q points of the convex hull, all n points of the original set are processed, see <xref ref-type="fig" rid="fig2">Figure 2</xref>).</p><p>To implement the first stage of the contour algorithm described in this paper, the Jarvis algorithm was chosen, and two heuristics were considered to speed up this algorithm. These heuristics cut off a part of the source points that are guaranteed not to be included in the convex hull. For this purpose, the set of edge points of the initial set is defined, after which all points of the initial set are analyzed and those that lie strictly inside the convex hull constructed by the edge are discarded. Thus, the implementation of this heuristic is a generalization of the preprocessing stage of the Jarvis algorithm, in which several points are found instead of one edge point, after which an additional cutoff is performed. Obviously, the complexity of this stage is O (kn), where k is the number of edge points.</p><p>In the simplest version of this heuristic (Cutoff4), a set of four edge points is selected: with minimum and maximum abscissa and ordinate (min (X), max (X), min (Y), max (Y)). In special cases, two of these points may coincide, resulting in a set of three points, but this will not affect the subsequent stages of the algorithm (although it will result in cutting off fewer points). <xref ref-type="fig" rid="fig3">Figure 3</xref> shows the result of this heuristic for a set of 90 points. The edge points are highlighted with black circles; their number is 4. The cutoff points are marked with red circles; their number is 51. The remaining 35 points, which are likely to be included in</p><p>the convex hull, are highlighted with blue circles, with labels indicating at which stage they were selected (e.g. label “0” means that these points are located “above” the segment connecting the min (X) and max (Y) points).</p><p>Given a uniform random distribution of points in a square region, we can expect that the Cutoff4 heuristic will, on average, halve the number of points to construct a convex hull. In the above example, 39 points out of 90 (including edge points) were selected.</p><p>A more significant reduction of points can be achieved if in addition to the specified edge points with the characteristics min (X), max (X), min (Y) and max (Y), we add points with the characteristics min (X + Y), max (X + Y), min (X − Y), max (X − Y). These edge points with respect to the lines with angles 45˚ and −45˚ are also obviously included in the convex hull. In this case, the final number of edge points can vary from 3 to 8. We will denote this heuristic by Cutoff8.</p><p><xref ref-type="fig" rid="fig4">Figure 4</xref> shows an example implementation of the Cutoff8 heuristic for the same set of source points as in <xref ref-type="fig" rid="fig3">Figure 3</xref>. In this example, the number of edge points is 7 because it turned out that the same point has the characteristics min (Y) and max (X − Y). The number of cutoff points is 76, the number of remaining points for the second stage of the Jarvis algorithm is 14 (including 7 edge points), i.e. reduced by more than 6 times.</p><p><xref ref-type="fig" rid="fig5">Figure 5</xref> summarizes the results of different algorithms for constructing a family of convex contours for different numbers of initial points. The original Jarvis algorithm and its two modifications, supplemented with Cutoff4 and Cutoff8 heuristics, were used. For each number of points, 20 sets generated randomly in a square with side 1 were processed. The average number of points used in the main stage of the Jarvis algorithm (i.e. traversal) for all contours constructed is indicated. The average running times of these versions (in milliseconds) are summarized in <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p><p>Because of the additional time spent on finding the edge points and on performing the cutoff actions, the acceleration of the algorithms with cutoff heuristics is not as large as one would expect based on the analysis of <xref ref-type="fig" rid="fig5">Figure 5</xref>, but it is significant enough to make it worthwhile to apply these modifications of the basic algorithm for a large number of points.</p></sec><sec id="s3"><title>3. Merging Two Contours into a Single Path and Handling Special Cases</title><p>After finding a set of convex contours, we need to combine these contours into a single closed path. To do this, it is sufficient to select segments [a<sub>1</sub>, b<sub>1</sub>] and [a<sub>2</sub>, b<sub>2</sub>] of two neighboring contours and replace these segments with two new segments connecting the corresponding ends of the removed segments ([a<sub>1</sub>, a<sub>2</sub>] and [b<sub>1</sub>, b<sub>2</sub>] or [a<sub>1</sub>, b<sub>2</sub>] and [b<sub>1</sub>, a<sub>2</sub>]). The choice of segments [a<sub>1</sub>, b<sub>1</sub>] and [a<sub>2</sub>, b<sub>2</sub>] should ensure the “minimality” of the obtained closed path. The simplest variant of such a choice, which we will call Simple, is the variant in which the added segments have total minimum length, i.e. the expressions dist (a<sub>1</sub>, a<sub>2</sub>) + dist (b<sub>1</sub>, b<sub>2</sub>) or dist (a<sub>1</sub>, b<sub>2</sub>) + dist (b<sub>1</sub>, a<sub>2</sub>) are minimal. As an example, <xref ref-type="fig" rid="fig7">Figure 7</xref>(a) shows a set of two contours (the points have coordinates between 0 and 1, as usual) and <xref ref-type="fig" rid="fig7">Figure 7</xref>(b) shows the result of their merging using the Simple algorithm (the segments of the contours connection are represented by lines of greater thickness). The total length of the resulting path is 3.05.</p><p>However, this method does not take into account the lengths of the contour</p><p>segments to be removed. Therefore, a more optimal variant is the one that minimizes the expressions dist (a<sub>1</sub>, a<sub>2</sub>) + dist (b<sub>1</sub>, b<sub>2</sub>) − dist (a<sub>1</sub>, b<sub>1</sub>) − dist (a<sub>2</sub>, b<sub>2</sub>) or dist (a<sub>1</sub>, b<sub>2</sub>) + dist (b<sub>1</sub>, a<sub>2</sub>) − dist (a<sub>1</sub>, b<sub>1</sub>) − dist (a<sub>2</sub>, b<sub>2</sub>), in which the lengths of the removed segments are included with “+” sign, and the lengths of the added segments are included with “−” sign. The result of such a variant of the algorithm, which we will call AddSub, is shown in <xref ref-type="fig" rid="fig7">Figure 7</xref>(c). In this case, the total path length is 2.77.</p><p>When programmatically implementing the algorithms of contours merging, it is convenient to use the contours descriptions in the form of a cyclic chain of points included in each contour. In the example shown in <xref ref-type="fig" rid="fig7">Figure 7</xref>, the outer contour is described by the chain (1, 4, 3, 2, 1) and the inner contour by the chain (6, 7, 5, 6). Note that exactly such chains are constructed in the Jarvis algorithm if the point with minimum abscissa min (X) is chosen as the initial point of the contour. In the Simple algorithm, link (2, 1) is removed from the first chain, link (5, 6) is removed from the second chain, and links (1, 6) and (2, 5) are added to the resulting path. In the AddSub algorithm, link (1, 4) is removed from the first chain, link (6, 7) is removed from the second chain, and links (1, 6) and (4, 7) are added to the resulting path. All other links of the original chains are retained; the result, for example, for the AddSub algorithm is the following change in the set of links (deleted links are underlined):</p><p>(1, 4, 3, 2, 1), (6, 7, 5, 6) &#174; (4, 3, 2, 1), (7, 5, 6) + (1, 6), (4, 7)</p><p>The same actions are required in the two special cases where the inner “contour” consists of one or two points (it is clear that for any set of nested convex contours there can be at most one such special contour). If we use representations of contours as cyclic chains, then the Simple and AddSub algorithms described above do not require any modifications. <xref ref-type="fig" rid="fig8">Figure 8</xref> and <xref ref-type="fig" rid="fig9">Figure 9</xref> illustrate these special cases. Note that in the case shown in <xref ref-type="fig" rid="fig9">Figure 9</xref>, the Simple and AddSub algorithms lead to the same result.</p><p>In the first case, we have cyclic chains (1, 4, 3, 2, 1) and (5, 5), while in the second case, we have (1, 4, 3, 2, 1) and (6, 5, 6). In all special case, we still remove two links from the original chains and add two links. For example, in the Simple algorithm, for the first case, we remove links (2, 1) and (5, 5) and add links (2, 5) and (1, 5):</p><p>(1, 4, 3, 2, 1), (5, 5) &#174; (1, 4, 3, 2), () + (1, 5), (2, 5)</p><p>In both algorithms for the second case, links (2, 1) and (6, 5) are removed and links (1, 6) and (2, 5) are added. Note that we retain the link (5, 6) of the second chain, as in the general case:</p><p>(1, 4, 3, 2, 1), (6, 5, 6) &#174; (1, 4, 3, 2), (5, 6) + (1, 6), (4, 7)</p><p>Thus, the algorithm for merging two contours does not need to provide any additional handling of special cases.</p></sec><sec id="s4"><title>4. Merging Several Contours into a Single Path: Algorithm Variants and Comparison of Their Efficiency</title><p>If there are more than two contours, then the merging process described above can be performed, for example, for each pair of neighboring contours, starting from the pair of outermost contours to the pair of innermost contours. When processing each subsequent pair of contours, the segment of the outer contour removed in the previous step must be excluded from consideration.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>0 shows the image of a set of contours taken from <xref ref-type="fig" rid="fig1">Figure 1</xref> and the result of applying the AddSub algorithm to this set in the direction from the outer contours to the inner contours (we denote this variant by the Up algorithm).</p><p>Note, however, that the choice of connecting segments reduces the number of possible choices for the next pair of contours. This may result in the loss of the optimal connection for the next pair of contours. Therefore, we can consider two more modifications of the contour algorithm: in one of them (the Down modification) connections are built in the reverse direction (from inner to outer contour), and in the other (the “greedy” Mid modification) at each step all pairs of neighboring contours that have not been joined yet are analyzed and the contours of the pair for which the value of the AddSub expression described above is minimal are merged.</p><p>Examples of application of the Down and Mid modifications are shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>1. For this set, all three modifications give different results, and the Mid algorithm gives the best result.</p><p>A numerical study of the above described Up, Down and Mid modifications of the contour algorithm was carried out. We use 20 randomly generated sets of 90 points located in a square with side 1. The initial parts of these sets consisting of 4, 6, 8, 10, 12, 15, 20, 25, 30, 35, 40, 50, 60, 70, 80 and 90 points were analyzed. <xref ref-type="fig" rid="fig1">Figure 1</xref>0 and <xref ref-type="fig" rid="fig1">Figure 1</xref>1 show an example of 35 points for one of the test sets.</p><p>The value</p><p>D<sub>i</sub> = 100 (S<sub>i</sub> − S<sub>0</sub>)/S<sub>0</sub> (1)</p><p>was used to characterize the efficiency of the contour algorithm modifications, where S<sub>0</sub> is equal to the length of the final path obtained with the Simple algorithm (by enumerating the contours from outer to inner), and S<sub>i</sub> is the length of the path obtained by one of the three modifications (Up, Down, Mid) of the AddSub algorithm. Thus, this value shows by how many percent the result has improved (i.e. decreased) compared to the Simple algorithm. The average values of D<sub>i</sub> for the 20 test sets are summarized in <xref ref-type="fig" rid="fig1">Figure 1</xref>2.</p><p>Thus, on average, the Mid algorithm gives the best results and Up algorithm comes next in terms of efficiency. However, the differences in the efficiency of these algorithms are negligible (of 1% - 2%).</p></sec><sec id="s5"><title>5. Comparison of the Contour Algorithm with Other Approximate Algorithms for TSP Solving</title><p>It has been noted above that for the contour algorithm, results close to optimal cannot be expected. For a more accurate assessment of the applicability of this algorithm, we compared it with two known and quite efficient approximate algorithms for solving the traveling salesman problem. The first one is based on a variant of the method of branches and bounds [<xref ref-type="bibr" rid="scirp.132998-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.132998-ref4">4</xref>], and the second one uses the simulated annealing algorithm [<xref ref-type="bibr" rid="scirp.132998-ref5">5</xref>]. Both of these algorithms are real-time algorithms and provide the current pseudo-optimal solution at any point in their execution.</p><p>Each of these algorithms was applied to the same test point sets as the contour algorithm. The Branch-bound algorithm was constrained to have a maximum number of branches of 100,000. A software implementation of the branch-and-bound method by one of the authors of this paper (B. F. Melnikov) was used.</p><p>Simulated annealing is a stochastic minimization method based on random wandering through space at successively lower temperatures, where the probability of performing a step is determined by the Boltzmann distribution [<xref ref-type="bibr" rid="scirp.132998-ref5">5</xref>]. For the simulated annealing algorithm, we used the function gsl_siman_solve of the GNU Scientific Library (GSL) with the following parameters: initial temperature T_INITIAL = 5000, final temperature T_MIN = 5.0e−6, Boltzmann constant K_B = 1.0, temperature reduction factor MU_T = 1.03.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>3 shows the results of these algorithms for the set of 35 points previously considered for the contour algorithm (see <xref ref-type="fig" rid="fig1">Figure 1</xref>0 and <xref ref-type="fig" rid="fig1">Figure 1</xref>1).</p><p>The Branch-bound algorithm, which showed the best results, was used as the base algorithm. Among the versions of the contour algorithms, the Mid algorithm was selected. To determine the relative efficiency of the Anneal and Mid algorithms compared to the Branch-bound algorithm, the previously described characteristic D<sub>i</sub> (1) was used, for which in this case the final path length obtained by the Branch-bound algorithm was used as S<sub>0</sub> and the path length obtained by the Anneal and Mid algorithms was used as S<sub>i</sub>. Here, this characteristic is positive and shows by how many percent the results deteriorated compared to the Branch-bound algorithm. The average values of D<sub>i</sub> for the 20 test sets are summarized in <xref ref-type="fig" rid="fig1">Figure 1</xref>4.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>5 summarizes the minimum path values found by Branch-bound, Anneal and Mid algorithms for the first test set.</p><p>Thus, although the Branch-bound and Anneal algorithms give better results, the deterioration of the Mid algorithm results does not exceed 90% even for 90 points.</p><p>Large sets of points (500, 1000, ..., 10,000) were also analyzed. In this case, the branch and bound method was able to process only sets of size 500 and 1000, as</p><p>the available memory was insufficient for larger sets. It should also be noted that the running time of the simulated annealing method varied from 98 seconds (for 500 points) to 45 minutes (for 10,000 points), while the Mid algorithm ran less than 1 second for all sets.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>6 summarizes the results for the first larger test set. The number of contours varied from 31 (for 500 points) to 225 (for 10,000 points).</p><p>The numerical results of the algorithms for large size point sets show that</p><p>starting with point sets of a certain size, the Mid algorithm performs better than other approximate algorithms and also runs much faster.</p></sec><sec id="s6"><title>6. Conclusions</title><p>The paper considers various aspects of the implementation of the contour algorithm related to both the first stage (construction of a set of convex contours) and the second stage (merging contours into a closed path). Numerical comparison with other known algorithms for approximate solution of the traveling salesman problem shows that for a small number of points, the deterioration of the results obtained using the described variants of the contour algorithm does not exceed 90%. For a large number of points (starting from 6000), the contour algorithm allows to obtain better results, and for a very short running time (about 1 s).</p><p>The main problem with the considered variants of the contour algorithm is that neighboring contours are bypassed completely except for one or two removed segments (<xref ref-type="fig" rid="fig1">Figure 1</xref>7(a)). It can be expected that the inclusion of additional heuristics in the algorithm to provide a more efficient merging of neighboring contours (<xref ref-type="fig" rid="fig1">Figure 1</xref>7(b)) will significantly improve its performance. The development and analysis of such heuristics is the subject of future research.</p></sec><sec id="s7"><title>Founding</title><p>This work is supported by a grant from the research program of Chinese universities “Higher Education Stability Support Program” (Section “Shenzhen 2022―Science, Technology and Innovation Commission of Shenzhen Municipality”).</p></sec><sec id="s8"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s9"><title>Cite this paper</title><p>Abramyan, M.E., Krainiukov, N.I. and Melnikov, B.F. (2024) On the “Onion Husk” Algorithm for Approximate Solution of the Traveling Salesman Problem. Journal of Applied Mathematics and Physics, 12, 1557-1570. https://doi.org/10.4236/jamp.2024.124095</p></sec></body><back><ref-list><title>References</title><ref id="scirp.132998-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Garey, M. and Johnson, D. (1979) Computers and Intractability. A Guide to the Theory of NP-Completeness. W. H. Freeman &amp; Co., San Francisco.</mixed-citation></ref><ref id="scirp.132998-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Applegate, D.L., Bixby, R.E., Chvátal, V. and Cook, W.J. (2002) The Traveling Salesman Problem: A Computational Study. Princeton University Press, Princeton.</mixed-citation></ref><ref id="scirp.132998-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Goodman, S. and Hedetniemi, S. (1977) Introduction to the Design and Analysis of Algorithms. McGraw-Hill, New York.</mixed-citation></ref><ref id="scirp.132998-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Melnikov, B. and Melnikova, E. (2022) On the Classical Version of the Branch and Bound Method. Computer Tools in Education, 2, 41-58.</mixed-citation></ref><ref id="scirp.132998-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Aarts, E.H.L. and Korst, J. (1989) Simulated Annealing and Boltzmann Machines: A Stochastic Approach to Combinatorial Optimization and Neural Computing. Wiley, Chichester.</mixed-citation></ref></ref-list></back></article>