Revealing a Rational Scheme of Level-By-Level Approximation to the Minimum Route

For the problem of routing tool movements between processing zones, in a formulation close to the traveling salesman problem, a method for calculating the minimum route, as a rule, leading to an optimum on tests with dimensions of up to 150 zones, is proposed and tested.


Introduction
The applied problems of routing idle movements of the tool between a set of machining zones on CNC equipment are united by one common problem found in the symmetric traveling salesman problem. It is the computational complexity of finding the shortest route. Keeping track of the specifics of technological processes themselves, such as milling, laser cutting, drilling, etc. in these tasks, as well as the presence of accompanying technical limitations, makes it possible, as a rule, to somewhat simplify the search for the minimum route. In particular, it is the case due to natural reduction in dimension (impossibility to process a number of zones until others have been processed, or imperative implementation of some technological prescriptions). Nevertheless, in many cases this still does not allow the use of exact methods [1][2][3][4][5] that provide optimal solutions. Thus, the limit of applicability of Little's algorithm is no more than 45 objects [3], dynamic programmingup to 30 [4,5,6], some sources [7] substantiate the theoretical possibility of solving such problems with up to 60 -65 objects, but without practical confirmation of this. For a possible assessment of feasibility of calculating the exact solution, for example, in [8], a statistical analysis of the complexity of problems with 25 to 50 objects is presented with a forecast of the computer time consumption for cases of higher dimension.
Nevertheless, more often for practical purposes, approximate algorithms are implemented [9,10,11]. In addition to varying degrees of approximation to the minimum route and different computation speed [12,13], there is no guarantee of obtaining a route close to the optimum, even in the best (from an applied point of view) local search algorithms [14,15]. In addition, in the general case, the number of steps in some of them may turn out to be exponential [16]. This situation stimulates the development and research of methods that give a sufficiently close to optimal result, and at the same time, provide the possibility of moving away from exponential complexity of the solution. This category includes the method of level-by-level approximation to the minimum route [17,18], which implements the following idea.
Minimization of touring N objects (let's call them points) can be started from arbitrary 2, 3, or another number of points. They form the starting closed order of the sequence of idle tool movements. If, for example, 3 points are selected, then at the first stage the fourth point will be included in this three-term closed round (one of the totality of the remaining N-3 points). First, it is embedded between the 1 st and the 2 nd points of the three-term route, followed by automatic completion of all other points according to the general empirical algorithm. Thus, we get the first complete tour. Out of these three routes, the best one (the shortest in length) is fixed together with the 'four-term sequence of points' from which it is actually built. Since any of the remaining N-3 points can appear as the fourth point, in the end we have N-3 routes.
Such calculations can be performed according to the same rules 'outward' (independent, where other combinations of starting points are used), as well as 'inward' (inherited, where the calculation continues from any fixed sequence of points). Thus, there is a basis for identifying the most universal and acceptable version for practical needs from various options of level-by-level approximation to the minimum route.

Basic procedure and general calculation scheme
To begin with, let us formulate a general setting in terms of the traveling salesman problem. It is required to find the shortest closed route passing through n cities. Each city should be visited exactly once. The distance (or cost of moving) between pairs of cities is generally determined by a symmetric matrix of real numbers C=||c i,j ||, где i≠,j и i,j=1,2,…,n.
One should emphasize the deliberate avoidance of the explicit use of coordinates, which would seem natural for CNC equipment. This is done because for different types of equipment and, accordingly, technological processes, different metrics can be used (calculations of distances between processing zones), therefore, for greater generality, we will not rely on the metric space. It should also be noted that for practical calculations 'computer' (and not integer, as is customary in theoretical research) accuracy of calculations is used here. This is due to the desire to obtain the most accurate results for utilitarian use.
The essence of the basic procedure [18] is as follows. Let i1, i 2 , …, i n be an order of the cities, where i 1 , i 2 are two arbitrary cities. One needs to build a tour from i 1 to i 2 and back, i.e. a two-term closed tour (i 1 , i 2 , i 1 ). Next, one needs to include the city i k (k=3) in the existing two-term tour. This can be done in 2 ways: (i 1 , i k , i 2 , i 1 ) or (i 1 , i 2 , i k , i 1 ). Let us explain the building process using the example of the first of them.
After including i k (k=3), it is necessary to perform a chain of consecutive steps, starting from step l=4. So, at step l (l=4, 5, ..., n) into the existing (l-1)-term tour, one needs to include one of the remaining cities i x (x=l, l+1, l+2, …, n) into the place of the tour where the minimum increase in the tour from the inclusion of this city will be ensured. In this case, the city of inclusion i x should be chosen in such a way that the value of the minimum increment of the tour from its inclusion is the maximum among the similar values of the minimum increment from other cities of potential inclusion. Thus, at step l=4, we get a four-term closed tour, and as a result, at the last step (l=n), we get an n-term closed tour corresponding to the complete route. A similar chain of steps must be performed for the second initial three-term tour (i 1 , i 2 , i k , i 1 ), as a result of which we can get the second complete route. Next, one needs to fix one of the complete routes with the shortest length (in fact, their length is the same, and the routes themselves coincide, the only difference is in the direction of the tour in the forward or backward direction). Thus, the basic procedure has been worked out and the first of the approximate routes has been obtained, which correlates with its progenitor -the three-term tour i 1 , i k , i 2 , i 1 .

(k=3).
Then one should return to the original two-term route (i 1 , i 2 , i 1 ) and perform similar calculations for each of the remaining cities i k (k=4, 5, ... n). The result will be n-2 variants of approximate routes. Each route is determined by uniform constructions from its original three-term tour i 1 , i k , i 2 , i 1 , (k=3, 4, ... n). Let us call the routes formed this way from the initial three-term tours level 0 routes and for convenience we assign them indices (0 0 , 0 1 , 0 2 , …) in accordance with the order of increasing their lengths. Level 0 0 route(s), is the minimum of all (n-2) received.
Similar constructions can be continued to obtain routes of level 1. In general, they can be constructed in a similar way, for each of the available n-2 initial three-term tours i 1 , i k , i 2 , i 1 , (k = 3, 4, ... n). In this case, at least one of the new routes (for each value k=3, 4, ... n) will be, by construction, no longer than the corresponding related route of level 0.
Let us explain the present constructions by the example of calculating the first of the level 1 routes. In the initial route (i 1 , i k , i 2 , i 1 ), (for the convenience of describing k=3), one needs to include city i m (for definiteness m=4) alternately between pairs of adjacent cities. Accordingly, one will get three 4-term closed tours (i 1 in each of the available (l-1)-term tours, one needs to include one of the remaining cities i x (x=l, l+1, …, n) at that place of the tour, where the minimum increase in the tour from the inclusion of this city will be ensured. The city of inclusion should be such that the value of the minimum increment of a tour from its inclusion is the maximum among similar values of the minimum increment from other cities of potential inclusion. Thus, at the last step (l=n), there will be three complete routes. Fix one of them with the shortest length. This is the first of the approximate routes of level 1. Together with it, the initial 4-term tour for it is also fixed (the value of m, k and the location of cities relative to each other in the considered four-term tour).
To build the remaining routes of level 1 (for k=3), one needs to return to the original three-term tour (i1, i k , i 2 , i 1 ) and perform similar actions with other admissible values of i m (m=5, 6, ..., n), as when building the first route of level 1. As a result, for the considered value of k=3, one obtains n-3 Hamiltonian cycles -approximate routes of level 1. One also needs to assign them indices (1 0 , 1 1 , 1 2 , …) in accordance with the order of increasing their lengths.
To form the remaining routes of this level (n-3 routes for each new k, where k=4, 5, ..., n), one needs to return to the original three-term tours (i 1 , i k , i 2 , i 1 ). For each of the values of k, one needs to perform similar actions with the admissible values of i m , as in the building of the first group of level 1 routes. As a result, for each of k (k=4, 5, ..., n), we get n-3 full routes of level 1. All received routes in each group (fixed value k) are also assigned indices (1 0 , 1 1 , 1 2 , …) in accordance with the order of increasing their lengths (several routes can have the same index if their lengths are equal to each other). Routes of levels 2, 3 and subsequent ones are built, if necessary, in the same way, respectively, depending on the identified at previous levels 4, 5, etc. -term initial tours.
Since the general building scheme contains an exponential growth of full routes, it is necessary, within the framework of the described general process, to identify some rational, possibly polynomial, computation schemes that provide (at least in the mass segment: 50 -150 routing objects) optimal or sufficiently close to it result for applied problems.

Directions of computation organization from an arbitrary two-term tour
Within the framework of the considered approach of the level-by-level approximation, in [18], possible directions of organizing computations for finding the minimum route were analyzed. There the features of different level-by-level approximation strategies were demonstrated.
• Calculation based on non-deteriorating routes can be roughly represented by the following scheme: The smallest length is among level 1 routes in each k-th group (k=3, 4, ..., n) for routes with index zero. By construction, their length cannot be greater than the length of the 'parent' route of level 0, which was obtained as a result of embedding city i k into the tour (i 1 , i 2 , i 1 ) and subsequent standard calculations. The same applies to all derived routes with a zero index of subsequent levels, i.e. the best level routes cannot be longer than their progenitors.
Therefore, the process of constructing routes in ascending order of levels continues, approximately as in the algorithms of 'thermal modelling', until a certain equilibrium is reached, understood as 'no deviations from the found length of the tour are observed for a long time' [9,19]. After that, level-by-level constructions in the considered direction are interrupted. Ultimately, a route is identified that is the smallest of all built. It is also a potential contender for compliance with the optimum.
In [20,21], the results of testing within the framework of the scheme (1) for several dozen problems from different sources with dimensions of up to 60 objects are presented, where the declared record results were invariably obtained or improved. Variants of organizing the process of finding the minimum route, for the selected example with 48 US cities from the att48.tsp file [22], are presented in [18] with a fixed stopping criterion. Here, in the current directions, it was as follows: 'threefold repetition of the value of the length of routes with a zero index during transition from level to level in the process of formation of hereditary directions.' In the present study, the computation halt criterion is tightened in order to greatly reduce the level-by-level calculations and to check whether the ability to build the same record (and known optimal) routes has been preserved. Thus, the short criterion for stopping calculations in the current direction is as follows: only a two-fold repetition of the length of routes with a zero index is allowed when moving from level to level in the process of forming hereditary directions.
This innovation has paid off -within the framework of each calculation scheme, record results are revealed. For example, in the test with 48 US cities, the optimum according to scheme (1) is achieved practically without branching after calculations at level 30, within the calculation framework (0 24 -1 0 -2 0 -3 0 ), schematically shown in Fig. 1.
Within the framework of scheme (1), as a rule, there are many options for building optimal routes [23], however, in some tests it is not always possible to quickly reach the optimal result. It is advisable to note the possibility of increasing the number of 'short' paths for constructing the minimum route by using extended schemes for non-degrading routes [21]. They allow, for example, in problems with a dimension of up to 50 elements, already at the initial stage, to obtain the optimum. Either they reveal new directions in which the optimal result is achieved in the absence of significant branching of the process, or at earlier levels than according to scheme (1), which may already be more relevant for problems in the range of dimensions, from 50 to 100 elements [24].
The first version of the extended calculation scheme:

(2) level (0 -1)i -level 20 -level 30… (i=0,1,2,…)
Here level (0 -1) represents conglomeration of level 0 and level 1 from the previous diagram. Full routes from level 0 are not built, and each of the n-2 original 3-term tours i 1 , i k , i 2 , i 1 , (k=3, 4, ..., n), is transformed into 3 four-term routes, from which routes are formed from the combined level (0-1). They are presented in the number (n -2)* (n -3)*3, which is a broader basis for the formation of routes of levels 2 0 and subsequent levels. Within the framework of scheme (1), formation of routes of level 2 0 , as practice shows, is in all directions (n 2) or several more closed initial routes (a subset of the analogue from scheme (2)).
Another extended scheme, similar to (2), but with three combined levels.

(3) level (0 -1-2)i -level 30 -level 40… (i=0,1,2,…)
It provides even greater opportunities for early record-breaking results due to the impressive 'sorting' component of the combined initial level (0 -1 -2) i . • Calculation based on the scheme with allowable route impairments is designed to provide significant flexibility in achieving record routes. This is a path to improvement from a slightly worse calculation position (having a greater length than the best route of the current level), which at the next or later levels can lead to a change in the current minimum in the considered direction of calculation. It is essential that this enables one to bypass rather than discard situations such as 'for a long time there are no deviations from the found tour length'. This approach is implemented on basis of using the index variation not only as earlier at the zero (or starting extended) level [17], but also at subsequent levels of building. The general calculation scheme is as follows: 0i0 -level 1i1 -level 2i2 … (i0, i1, i2, …=0,1,2

, …)
The total number of calculations is much greater here, relative to schemes (1)-(3). Therefore, the potential excessive growth of tiered calculations should be artificially limited here.

Organization of computations from many combinations of initial binomial tours
The main directions of calculations from a conditionally arbitrary pair of cities and the statistics of earlier calculations [17,20,21,23,24] in various test examples with dimensions of up to 100 and more elements, show the achievability with a varying degree of laboriousness of the optimal result. The optimum for each of the possible calculation schemes, as a rule, is achieved in many different ways. The least time-consuming of the paths was often the one where the optimal route was built at earlier levels. Less often -at later levels, provided there was no large number of branches. The broader the base of the starting (initial) level, as happens when using extended schemes, the more likely it is to reach the optimum 'earlier'.
There is a natural opportunity to significantly increase the number of starting rounds of the zero level, if we carry out calculations from each unique pair of source cities. In this case, the number of starting two-term tours increases to n*(n-1)/2, where n is the number of cities. However, this approach is rather redundant. Apart from the repeated reproduction of the best route, it only allows to identify the 'best pair' of cities, from which the route is built the fastest. To some extent, it is possible to successfully deal with redundancy, for example, in the following ways: -find in some way 'good pairs' of cities, from which the minimum route is relatively comfortable to build; -on basis of a simple calculation model of the type of scheme (1) or its extended versions, calculate all options for each of the pairs or a unique combination of cities to a certain fixed level and be limited to this, or develop only certain directions.
The first path is constructions representing an attempt to define a 'good pair' of cities. Suppose that in practice such a large number of initial two-term tours is not needed (in our example about 48 cities -it is 1128). Let us restrict ourselves to considering only such starting binomial tours, from which, when forming the routes of the zero level, the smallest ones with the zero index are obtained (i.e., the smallest among all possible routes of levels 0 0 ). In our example, there are 68 of them. It should be noted that with the updated stopping criterion, as in [18], the optimum is repeatedly reached after calculations from level 10 , but there are still no stable indications for choosing a two-term tour in order to obtain the 'shortest' calculation.
The second path is a massive calculation (for each of the existing pairs of cities) according to scheme (1) of all routes of level 1 0 and their ranking by length. In the absence of explicit priorities, in order to isolate the two-term tour with the shortest path of building, we calculate according to scheme (1) for completeness of the experiment all the options from all two-term tours of the formation of level 1 routes (i.e. routes resulting from the inclusion of a third city in a two-term tour).
After such calculation, several two-term tours are indeed identified, for which the optimum is achieved immediately when constructing from level 00 or level 0i (where i#0). This is an unconditional record among other constructions for the test in question. However, this path entails the need to consider in this case all 17,296 possible combinations of three-term tours. In general, this is n*(n-1)*(n-2)/6, where n is dimension of the problem.

Generalization of the rational calculation scheme
As a result of calculations from each unique pair, already at the initial stage of calculations, we have a large number of directions, from which it is potentially possible to obtain an optimal route. In examples with dimensions of up to 50 cities, it is still possible to authorize the determination of not only the best route, but also the establishment of the lowest of the levels where it is reached. With samples with dimensions from 50 to 150 elements, this approach (i.e., 'outward' calculation) in general will be quite laborious.
Therefore, a different option (rational scheme) for organizing 'outward' calculations is proposed. Let us explain it using the example of eil76.tsp test [22]. The declared optimal route of length 538 (in integers) is shown in Fig. 2 first from the left. Its real length is 545.3876 (rounded up to 4 digits). Basic calculation for all two-term tours and indexing among zero-level routes reveal the best route 556.9420 (Fig. 2 second from the left). It is generated from the two-term tour 4 53 4 with the potential inclusion of city 23 (the numbering sequence is the same as in [22], but starts from 0). In the terminology used, this is a 00,0 level route, representing only one three-term tour. All subsequent 'outward' constructions will be built exclusively from it. This is a rather serious reduction in computations and at the same time, the likely loss of reaching the 'short' construction of the minimum route. We will try to compensate for these losses by modifying the final calculation scheme from [18]. Let's call such an innovation by scheme (5):
If at level J for the first time several routes with index 0 appeared, then further constructions are carried out for this level J not only from the initial (J + 2) -term tours with zero index, but also from all other (J + 2) -term tours, initial for routes of a given level with corresponding nonzero indices, i.e. as in scheme (4). At subsequent levels J + K, where K> 0, constructions are carried out only from the initial (J + K + 2) -term tours with zero index.
At the same time, in order to reduce computations, it is possible not to consider the directions of calculations from non-zero indices, when constructing from which the full route of the next level, which has a zero index, coincides with the parent route (i.e., in the absence of a decrease in the length of the route).
Thus, from the three-term tour 4 23 53 4 we get 6 level 1 0 routes, the length of which remains the same, which means that at this and only at this level we will use in our calculations, in addition to the 6 corresponding four-term tours, all other four-term tours obtained here.
In this paradigm, the direction from level 1 52 is interesting, leading to an absolute record (544.3691 (Fig. 2 on the right) or in the integer metric 538), which was not noted in the original source [22]. This is bypass sequence 22 55 40 42 41 63 21 61 72 0 32 62 15 2 43  31 8 38 71 57 11 39 16 50 5 67 3 74 75 25 66 33 45 51 26 44 28 47 29 1 73 27 60 20 46 35  68 70 59 69 19 36 4 14 56 12 53 18 7 34 6 52 13 58 10 65 64 37 9 30 54 24 49 17 23 48 22 (when the initial data is numbered from 0). It is far from the shortest (the record is achieved here after passing the 19 th level). Its beginning corresponds to embedding in tour 4 23 53 4 city 35 between 4 and 23 with the result as in (Fig. 2 third from the left). Further, up to level 5 0 , there is an unambiguous chain of constructions of improving routes, presented in one copy, each at its own level. Then, from level 5 0 to the end of calculation, with level-by-level constructions, there are routes with zero index as in Fig. 3.  (Figure 3) also exceed the known record. Moreover, three out of four routes exceeding the record and in the integer metric also have a record length equal to 538 (which is an integer optimum).
Thus, the calculation from the only starting direction of 0 0,0 level (a three-term tour representing the minimum route of 0 0,0 level) led, despite the restrictions introduced, to obtaining several valid records, albeit at the cost of going deep through a large number of levels.
Similar calculations from another three-term tour, located somewhat further from the minimum route in terms of starting indicators, confirm stability of the result (Fig. 4). This is tour 22 30 60 22 with the resulting single route of level 1 0 with a length of 559.8204, from which up to level 5 0 there is an unambiguous chain of constructions of improving routes, each presented at its own level in one copy. The same absolute record is here achieved at an earlier level and with fewer branches. In addition, starting from level 8 0 (Fig. 4), along the way, there are again 5 more record routes, which are shorter in length than the control route.

Conclusion
A significant layer of applied problems related to the efficient operation of CNC equipment, equivalent in formulation to the symmetric traveling salesman problem, can be solved on basis of the method of level-by-level approximation to the minimum route. Some problems with a dimension of up to 50 elements, close to the current limit of the possibilities of exact methods, can be solved with an optimal result already at an early stage of calculations at the level of possible combinations of two-term (formation and ranking of zero-level routes) or three-term (level 1 0 routes) tours.
Also, for problems with a dimension of up to approximately 150 elements, a rational scheme of level-by-level approximation (5) with an accelerated criterion for stopping calculations, as a rule, leading to the identification of an optimal route, has been proposed and tested (primarily on tests from [22,25]).
As the testing shows, routes are formed with an average length of 1% -2% more than the optimal one at the initial zero level of calculations. This allows, in the case of noncritical accuracy requirements, to be limited only to the initial stage of the calculation.
In addition, the described approach of the level-by-level approximation to the minimum route can be used to obtain a good upper bound in theoretical studies.