An Improved Ant Colony Optimization Based on an Adaptive Heuristic Factor for the Traveling Salesman Problem

,


General Perspective.
e TSP is an optimization problem in which a traveler needs to pass through all cities once and only once in order to obtain the shortest path. e TSP is a typical combinatorial optimization problem that is highly relevant and is widely used in a variety of practical problems, such as computer networks, sensor placement, vehicle routing, logistics and distribution, circuit board wiring, and intelligent transportation [1]. e TSP is an NP-hard problem, and the traditional optimization algorithm is not effective, so a metaheuristic algorithm is often used to optimize the TSP, and the TSP is often used as the benchmark of the metaheuristic algorithm.
A metaheuristic algorithm is an implementation on a specific problem guided by a set of guidelines or strategies [2]. Metaheuristic algorithms do not require the problem itself to have precise mathematical characteristics and have good optimization performance and strong robustness. Compared with a traditional algorithm, metaheuristic algorithms do not guarantee an optimal solution, but they can obtain a satisfactory solution within a certain amount of time or computation [3]; at the same time, they are very adaptable and are used in almost all scientific fields and engineering applications.

Literature Review and Motivation.
For the reasons mentioned above, in recent years, many metaheuristic algorithms have been used to solve the TSP, such as the genetic algorithm (GA) [4][5][6][7], ant colony optimization (ACO) algorithm [8][9][10][11], particle swarm optimization (PSO) [12][13][14][15], artificial bee colony (ABC) algorithm [16,17], and spider monkey optimization (SMO) [18]. Most metaheuristic algorithms essentially obtain a feasible solution first, improve the feasible solution by using mechanisms such as movement, exchange, mutation, and cooperative perception, repeat the improvement process many times to gradually approach the optimal solution, and finally finish the optimization through certain conditions. Metaheuristic algorithms can generally obtain better results when solving small-scale optimization problems, but when addressing some large-scale optimization problems, such as large-scale TSP problems, there are often two concerns: (1) the convergence speed is too slow, resulting in a long computation time; (2) it is easy to fall into a local optimum and stagnate. ese two problems are interrelated: the former is due to the low speed of approximation, which is usually improved by improving some parameters or introducing some mechanisms, while the latter is mainly due to the lack of population diversity, which is directly linked to the final solution quality and can usually be improved by enhancing population diversity. Much research has been conducted on the shortcomings of metaheuristic algorithms, and improvements to the standard algorithm itself or mixing the standard algorithm with a variety of mechanisms have achieved good results.
In [4], the authors proposed a hybrid method of GA and PSO, while using the cross-mutation of GA and the position update of PSO, which greatly improved the convergence speed of the algorithm. Wang et al. [6] proposed multioffspring genetic algorithm (MO-GA), which improved the probability of producing excellent individuals and made the population competitive. Compared with the basic genetic algorithm, MO-GA has a greater improvement. In [7], the authors proposed a hybrid genetic algorithm with variable neighborhood search. e core idea in this study is the dualchromosome solutions, and the deleting and reinserting operator on them. In [15], the speed calculation method of the particles was improved. e calculation method in the standard PSO was not adopted immediately. Instead, a number of tentative tours were evaluated, and the most adaptable one was used.
is significantly improved the accuracy of the algorithm, but the calculation time increased. In [16], the authors applied ABC to the TSP problem through the defined swap sequence and swap operator. On this basis, they used the 3-opt algorithm combined with the mechanism of jumping out of the local optimum to avoid the stagnation of the algorithm. In [17], an improved ABC algorithm based a novel neighborhood selection mechanism was proposed to solve the TSP problem, which enhanced the solution quality. In [18], the authors discretized the SMO and made it suitable for TSP problems. Under the inherent grouping and regrouping strategy of SMO, they proposed a method of exchanging experiences between random individuals, global leaders, and local leaders, which improved the search ability of the algorithm. Ali et al. [19] improved the differential evolution (DE) algorithm by using k-means algorithm to classify nodes in TSP. It enhanced the quality of the initial solution, and they also used a mutation strategy with better search performance to substantially improve the solution quality.
ACO is a metaheuristic algorithm proposed by the Italian scholar Dorigo in the 1990s, inspired by the foraging behavior of an ant colony [20]. In ACO, a solution of the solution space is represented as an individual ant, which will leave pheromones on the path it passes when searching for food, and other individuals will prefer the path with more pheromones. At the same time, pheromones evaporate over time, and the longer the path from the nest to the food is, the less pheromones the ant will retain on the path, due to the evaporation mechanism. e ACO algorithm actually leverages the simple behavior of an individual ant to form a complete optimization system through intergroup collaboration. Unlike many continuous domain optimization algorithms, ACO has the feature of building paths step by step, which is comparatively more applied to discrete and combinatorial optimization problems, and many intensive studies have been conducted on ACO for solving TSP problems.
Sudipta et al. [8] introduced a transfer strategy based on a large neighborhood search in the standard ACO, which maintains population diversity and can more quickly reach the global optimal region, improves the search efficiency of the basic ACO, and reduces the search time for the optimal solution. DEACO [10] classifies cities based on the standard ACO, and the classification results are used to select the starting city. At the same time, it replaces the pheromone evaporation method in the standard ACO with a dynamic pheromone evaporation method that changes with the number of iterations. e proposed method enhances the evolution speed and avoids local optimum. Mahi et al. [14] proposed a hybrid algorithm using PSO to optimize the optimal parameters of the ACO and 3-opt algorithm to jump out of the local optimum, thus boosting the solution accuracy and robustness of the algorithm. In [21], the authors proposed an improved ACO algorithm, which introduces a strategy of dynamically adjusting pheromone evaporation and preserves a small amount of pheromones in the iterative initial path. It improves the search capability of the solution space, progressively increases the pheromones, and enhances the convergence speed of the algorithm to achieve a better balance between solution quality and convergence speed. Escario et al. [22] extended the ACO algorithm, which divides different class of colonies, which perform different actions, and proposed a transformation strategy, which can be dynamically transformed between individuals in different colonies, enriching the diversity of the population and improving the quality of the solution. Delévacq et al. [23] improved the roulette in the ACO by parallelizing optimization and implemented it on a CUDA-based GPU platform, which significantly reduced the running time of the algorithm. In [24], an improved ACO introduced a pheromone updating strategy for the best path, and metaheuristic information and pheromone density conversion rules were applied to find the best path. Chaos is the seemingly random irregular movement that occurs in a deterministic system, and many algorithms use it to provide better search capabilities than random. Xu et al. [25] introduced a dynamic moving method based on unidimensional chaotic mapping to improve the solution accuracy and overall efficiency of the algorithm. Lei and Wang [26] introduced an elite strategy and a max-min ant system in order to increase the search capability of the solution space and enhance the convergence speed, which ensures high quality solutions while preventing the algorithm from falling into stagnation.
Most current research has focused on certain improvements, e.g., improving the quality of the initial solution by some mechanism to cover the entire solution space at the initial stage, controlling pheromones such that they jump out of the local optimum to avoid degradation of the solution quality due to stagnation, introducing elite strategies to improve convergence speed, using a local search operator for tuning, providing multiple population strategies to maximize the diversity of populations, dynamically adjusting algorithm parameters with the number of iterations or other criteria to achieve a balance between solution speed and solution quality, and performing targeted parallel optimization based on parallel processors to improve the speed of the algorithm. However, the aforementioned algorithm improvements are mostly improvements to the algorithm itself, which fails to take full advantage of the spatial information of the TSP and performs poorly in some TSP instances. In view of this, this paper proposes an improved ACO algorithm (AHACO) that makes full use of the spatial information of the TSP with an adaptive heuristic factor. e specific description of AHACO is given in Section 3.

Outline of is Paper.
e remainder of the paper is organized as follows: Section 2 gives the mathematical model of the TSP problem and describes the standard ant colony algorithm for solving the TSP problem; Section 3 describes the proposed AHACO algorithm for solving the TSP problem; Section 4 performs experiments on the standard TSPLIB [27] dataset and discusses the results; and Section 5 provides the conclusion of the work in this paper.

Principle and
indicates a response to a city edge set, so the optimization problem of TSP can be described as follows. where indicates Euclidean distance, and Π indicates the solution space of the TSP.

Principle and Methodology of ACO to Solve the TSP.
e solution of the TSP problem by ACO is a process in which a number of ants search for paths in parallel. When an ant completes one search of the path, the path on which it travels is a feasible solution to the TSP problem. Using ACS [20] as an example, the algorithm starts by putting m ants randomly into n cities. So, the k-th ant at moment t uses a roulette strategy with probability p k ij to determine the next city.
where τ iu (t) denotes the amount of pheromones between city i and city u at time t, α denotes the relative importance of the pheromones, η iu stands for the heuristic factor from city i to city u, d iu is the distance between city i and city u, β indicates the importance of the heuristic factor, and allowed k represents the set of cities not traversed by the k-th ant, i.e., the set of allowed cities. e ant completes the solution path search under the influence of pheromones and heuristic factors. During the search process, the ants release pheromones to enhance the positive feedback of the whole system, which helps the algorithm to converge faster. e pheromone updating strategy is divided into three models: an ant quality model, ant density model, and ant cycle model. e ant cycle model is more biased towards global information and is more widely used [8,10,23,24]. e formula for updating pheromones using the ant cycle model is as follows: where ρ is the evaporation coefficient. If ρ increases, it will enhance the randomness of the algorithm, and if it decreases, it will speed up the algorithm's convergence, but the algorithm is more likely to fall into a local optimum. Q is the total amount of pheromones. (i, j) represents the path from city i to city j. L k is the length of the path traveled by the k-th ant in the current iteration. Guided by pheromones τ and distance η, the ant colony progressively improves the quality of the solution, and the algorithm is completed when a specified number of iterations is reached or the current optimal solution satisfies the expectation.

Problem Mapping of AHACO for TSP
Based on the standard ACO, AHACO has the following three main improvements. (1) It fully considers the information contained in the solution space, uses k-means to classify the TSP cities, and sets a special colony from the original colony. It applies a reward-punish factor. When the special colony selects the next city, it will prefer interclass or Journal of Advanced Transportation 3 intraclass cities according to the reward-punish factor, and the reward-punish factor changes dynamically by iteration.
(2) A simplified 2-opt optimizer is implemented. (3) e scout bee mechanism in ABC is introduced, which can make the algorithm jump out of the local optimum. Improvement 1 fully enhances the diversity of the population and is mainly used to enhance the search ability of the algorithm. e ant colony algorithm is a method with a feedback mechanism (pheromone). If there is an error in the order of two adjacent cities on an obtained better path, then this path will be strengthened by pheromone accumulation. It is difficult for the ant colony algorithm to optimize this situation through its own mechanism. us, improvement 2 is introduced to tune the optimal solution. Finally, the ant colony algorithm has a widely criticized shortcoming: it is easy to fall into a local optimum. erefore, improvement 3 is introduced, which is used to jump out of the local optimum. Figure 1 shows a simplified flowchart of the AHACO, in which the thick border indicates the improved part. e specific algorithm flow is given by Algorithm 1.

Classification of TSP Cities.
Existing algorithms treat TSP cities indiscriminately, ignoring the spatial information contained in the TSP itself. is algorithm uses k-means to classify the cities and introduces confidence intervals to separate the classless cities from the already classified classes. Prerequisites are provided for the execution of different search strategies for multi-role ant colonies.

K-Means
Clustering. K-means clustering is a very classical clustering algorithm, which is simple, efficient, easy to understand, and widely used in reality. For the TSP problem, its basic procedure is as follows: Step 1: randomly select k cities as class centers from the set of cities cities � c 1 , c 2 , . . . , c n to construct the set center � s 1 , s 2 , . . . , s k .
Step 2: ∀c i ∈ cities classified in class j as where ‖ · ‖. indicates Euclidean distance.
Step 3: update the class center according to equation (9), class j (t) is the set of cities of the class j at moment t, and n j (t) is the number of cities in class j (t).
Step 4: if center is updated, go to Step 2 and Step 3; otherwise, end the algorithm.
If the number of city classes is too large, the algorithm will converge quickly and be trapped in a local optimum; if it is too small, the algorithm will take too long to search and the number of optimal iterations will increase. In the following, some discussions about the number of city classes are carried out. e number of city classes should be determined according to the following formula: where k is the number of city classes to be determined, n is the number of TSP cities, and floorrepresents the largest integer less than or equal to the parameter. e population diversity in the ACO mainly depends on the way the city is selected. First, when the value of k is 1 or the number of cities, AHACO degenerates into ACO because all cities are intraclass cities or interclass cities, and the reward-punish factor will become invalid (related descriptions are given in Section 3.2). When k is the square root of the number of cities, the probability of each class being selected is equal. At the same time, once the ant chooses an interclass city, the class of the interclass city becomes the class of the ant, and the interclass city within a class can be regarded as a whole. When the value of k is the square root of the number of cities, the number of cities in the class is equal to the number of classes. In this case, the diversity of the population is expected to be the highest. However, the distribution of cities is not always uniform. K-means is very sensitive to the choice of centroid, and its anti-noise ability is relatively poor. erefore, equation (10) is only an approximate formula defined from experience.

Classless Cities.
In the process of selecting the next city, the algorithm encourages or penalizes the ant colony based on the city class relationship. By introducing confidence intervals and separating the classless cities, the barriers between city classes can be buffered, further increasing the diversity of the algorithm.
For the TSP problem of n cities, the distance of each city to the center of its respective class constructs the set. e cities satisfying equation (11) are then separated into classless cities.
where μ is the distance mean, σ is the distance standard deviation, and ε ∈ [1, 2] is the separation factor; taking its values too small will increase the number of unclassified cities, and making its values too large will decrease the number of unclassified cities. e value taken in this experiment is 1.5. Figure 2 shows a classification map of TSPLIB [27] examples eil51, kroA100, kroB150, and gil262, where "+" denotes classless cities, circles denote cities with classes, and cities with classes are distinguished by different colors.

Multi-Role Colony and Corresponding Strategies.
AHACO divides the ant colony into two roles: a normal ant colony and a special ant colony. At the beginning of the algorithm, the two colonies perform a path search simultaneously with different strategies, and the difference is reflected in the different city selection strategies. e ant selection strategy is based on city class relations, and to represent the differences between city classes, a class operator is first introduced: where i and j are both city numbers, class l denotes cities of class l, and class m denotes cities of class m. When sgn(i, j) returns 1, city i and city j are in the same class; when sgn(i, j) returns −1, city i and city j are in different classes; when sgn(i, j) returns 0, city i and city j are in at least one of the uncategorized cities.
For different class relationships, this paper proposes three search strategies, as follows. Strategy 1. Take into account intraclass, interclass, class, and no-class searches in order to achieve a balance between global optimality and convergence speed.  Equation (13) is used in AHACO to determine the probability of moving to the next city: where c ∈ −1, 0, 1 { } determines the choice of strategy. A normal colony uses Strategy 1, c � 0, which treats the various city class relationships indiscriminately. In fact, in this case, equation (13) is equivalent to equation (2).
Special ant colonies at t ≤ t max /2, c � −1, improve the selection probability of interclass cities and shrink the selection probability of intraclass cities. Special ant colonies at t > t max /2, c � 1, improve the probability of selection for intraclass cities and narrow the probability of selection for interclass cities. ξ ∈ [1, ξ max ] is the reward-punish factor, which indicates the ant colony's preference for class relationships. ξ decreases linearly from ξ max to 1 with Δξ � 2 (ξ max − 1)/t max when t ≤ t max /2. ξ increases linearly from 1 to ξ max with Δξ � 2 (ξ max − 1)/t max when t > t max /2. Different search strategies directly influence the formation of the final path. In Figure 3, all ants in TSPLIB instances eil51, kroA100, kroB150, and gil262 start from the same city under ξ max � 8. Figure 3 shows the path diagram for 10 iterations at c ∈ −1, 0, 1 { }, with all instances starting from the city numbered 1 that is indicated by a square. e results show that, although there is a random factor, the focus of individual ants is significantly different under different strategies. e diversity of the population is directly related to the search ability of the algorithm. At present, many algorithms use various mechanisms to improve the diversity of the population, but most of them are improvements of the algorithms themselves, and fail to use the characteristics of the problem.
e standard ACO uses a set of parameters to perform spatial search successively, but AHACO divides ants into different roles. One type of ants treats intraclass and interclass cities indiscriminately, and another type of ant prefers intraclass cities or interclass cities based on dynamically changing parameters. e innovation is that different ants perform different searches based on the information of the TSP instance itself, which is the maximum use of TSP spatial information. From the perspective of population diversity, this is a problem-oriented adaptive diversity enhancement mechanism. AHACO divides the population into normal ants and special ants, each of which accounts for half of the population size. In order to facilitate the implementation on the computer, during the operation of the algorithm, odd-numbered ants are classified as special ants, and even-numbered ants are classified as normal ants. e pseudocode of the division process can be seen in lines 17-21 of Algorithm 1.

Local Optimization.
e ant colony algorithm obtains the final solution by a stepwise search, which is prone to form two adjacent points reversed and is difficult to optimize further when approaching the optimal solution, as shown in Figure 4. e 2-opt [9] is a local optimization operator, and the time complexity is O(n 2 ). Local tuning in AHACO uses simplified 2-opt with a time complexity of O(n). route � c 0 , c 1 , . . . , c n−1 , n is the number of cities in the route, and d(i, j) is the distance between c i and c j . To facilitate the description of the algorithm flow, in the case of ∀i ∈ Z, when i ≥ n, c i equals c i%n . e algorithm starts with i � 0. Step Step 2: if i < n, then i ⟵ i + 1 and go to Step 1. Otherwise, the algorithm is complete. e optimized results are shown in Figure 4. [16] to jump out of the local optimum. Whenever an optimal solution cannot be updated in a certain number of times in ABC, the solution is discarded. AHACO uses a combination of an elite strategy and jumping out of the local optimum. If the optimal path obtained by the population has not been updated for more than a certain number of times, on the one hand, it shows that the path is a sufficiently good solution; on the other hand, it shows that there is a large amount of pheromones on the path. AHACO will retain this path as an elite to speed up the convergence of the algorithm. At the same time, AHACO reinitializes the pheromone on this path because a large amount of pheromones easily causes the algorithm to fall into a local optimum. In this paper, the parameter "a certain number" is defined as tries and the value is set to t max /10. If tries is too small, normal optimization will be interrupted, and if it is too large, stagnation will not be prevented. is not only retains the higher quality solutions but also avoids stagnation and enhances the search capability of the algorithm. e pseudocode of this process can be seen in lines 30-38 of Algorithm 1.

Modalities for Updating Pheromones.
e traditional way of pheromone updating is shown in equations (4)- (6), where all ants perform pheromone updates after one iteration. is update method enhances the positive feedback of the system and helps the algorithm to converge faster, but it affects the diversity of the algorithm and leads to the degradation of the solution quality. AHACO only selects the shortest path for pheromone update from the two roles of ants. It improves the diversity of the algorithm while avoiding the degradation of the algorithm to random greedy search. e update formula is as follows: , (i, j) on tour done by best ant, s ∈ normal, special , 0, otherwise, where Δτ normal ij represents the pheromone increment of the normal ant, Δτ special ij represents a pheromone increment for the special ant, Q is the total amount of pheromones, (i, j) represents the path from city i to city j, and L s best denotes the current optimal path length of the ant colony for role s.
3.6. Pseudocode of the AHACO. AHACO primarily classifies cities at the beginning and subsequently rewards or penalizes them according to different city relationships to maintain population diversity during roulette. e specific pseudocode is given in Algorithm 1.

Experimental Results
To verify the validity of AHACO, 39 classical examples from TSPLIB [27] are selected in this paper for experiments. It is worth noting that full floating-point operations are used in all experiments without any additional numerical manipulation. TSP instance names are composed of letters and digits, where the digits represent the number of cities corresponding to the instance, that is, its scale. e language used for the implementation is C/C++, the IDE is Visual Studio 2013, the computer CPU is i7-4790K, the memory is 32GB, and the Windows 7 64-bit operating system is used.

Comparisons.
To compare the optimal solution, ACO, DMSO [18], VTPSO [15], and ABCSS [16] were used. e following was implemented: 20 independent runs, respectively, 500 iterations of ACO, DMSO, and VTPSO, and 1000 iterations of ABCSS, with a population size of 300. All other parameters are based on the literature [18]. AHACO uses the following parameters: α � 1.0, β � 3.0, Q � 120, ρ � 0.9, ε � 1.5, and ξ ∈ [1,8]. Since AHACO uses ABC scout bees to jump out of the local optimum, the convergence rate will decrease slightly and the number of iterations will have little impact on the final result [18]. e number of iterations in this experiment was chosen to be 1000. e experimental results are shown in Table 1. Table 1 shows the shortest paths obtained from 20 independent runs of each algorithm. e values are two decimal places, and the optimal terms are in bold. e experiment was conducted to verify the quality of the algorithm's solution, and the values in parentheses in the table are the deviations, in percentages, between the solution obtained by the corresponding algorithm in the corresponding TSP instance and the optimal solution obtained in that instance.
From the data in Table 1, it can be seen that the proposed AHACO algorithm is substantially ahead of the comparison, with 36 out of 39 groups of examples obtaining the optimal solution, accounting for 92.31% of the examples, followed by DSMO, which obtained 7 groups of optimal solutions, accounting for 17.95%. Comparing purely in terms of solution quality, AHACO is 74.36% higher than DSMO, and 76.92%, 82.05%, and 100% higher than ABCSS, VTPSO, and ACO, respectively. e amount of deviation is proportional to the optimization capability of the algorithm. From the data, the AHACO's deviation was 0.09 and the mean deviation was 0.002, compared to 1.53, 2.07, 12.45, and 11.79 for DSMO, VTPSO, ABCSS, and ACO, respectively, which were much higher than that of the AHACO. Overall, almost all algorithms can obtain the optimal solution when the TSP size is less than 70; however, as the TSP size increases, the optimization ability is insufficient and the results obtained are not comprehensible. ABCSS obtains the optimal solution six times, but the average deviation is 12.45%, indicating that the algorithm is unstable and the solution quality varies greatly for different TSP instances. From the data, ABCSS performs very well in solving TSP instances with a scale of less than 300, while it performs poorly for TSP instances with a scale of more than 300. e average deviations of both VTPSO and DSMO are low, and accordingly the algorithm is more stable. AHACO classifies cities and enhances population diversity from the location relationship of cities, which makes it easier for the algorithm to enter the optimal solution region by maximizing the search solution space during the iterative process. At the same time, AHACO uses the method of jumping out of the local optimal solution in the ABC algorithm to better control the precocity of the algorithm. From the data, both the number of optimal solutions and the average deviation of AHACO are significantly ahead of the comparison algorithm, which can obtain the optimal solution more reliably with better overall performance. Figure 5 shows the path diagram of the optimal solution obtained by AHACO on some TSP instances. A more intuitive comparison is shown in Figure 6.

Comparison with GA-Based Algorithm.
Genetic algorithm is a very classic intelligent algorithm. At present, many studies have applied it to solve the TSP problem and achieved good results. In order to reflect the effectiveness of the proposed AHACO, tests compared with the MO-GA [6] are introduced. In this test, the parameters selected by MO-GA are the same as those in [6], and the population size and number of iterations of AHACO are also set to the same values. From the data in Table 2, it can be seen that the proposed AHACO algorithm can converge to a better solution faster, and the performance is stronger than that of MO-GA. It is worth noting that on the instance kroB100, the results obtained by AHACO are worse than those of MO-GA. is is because the proposed AHACO algorithm uses k-means to classify cities, and the distribution of cities in kroB100 is uniform. Relatively, the classification result is greatly affected by the initial center. On this basis, although this improvement speeds up the convergence of the algorithm, it makes the algorithm easier to fall into the local optimum to a certain extent.

Statistical Comparison of Convergence.
In the comparison described in Section 4.1, the solution quality and stability of the proposed algorithm AHACO are compared, and this section carries out the comparison of convergence speed. AHACO is an improvement on ACO, while VTPSO and DSMO are non-ACO class algorithms with very different mechanisms; in order to reflect the fairness of the experiment, ACS [20] is chosen as the comparison for the  convergence speed in this paper. ACS is an improved and widely used algorithm proposed by the proponents of the ant colony algorithm, which is more balanced in terms of convergence speed, solution quality, and stability.
In this experiment, examples of eil51, krob150, lin318, and d493 were selected. e reason for selecting these TSP instances is that the number of cities in these four TSP instances ranges from 51 to 493, covering different scales, which can better test the convergence speed of the proposed algorithm. AHACO and ACS use the same parameters as in Section 4.1. Four TSP instances were tested 100 times, with 1000 iterations performed each time. e statistical distribution is shown in Figure 7. e horizontal coordinate in Figure 7 is the number of iteration generations when the optimal solution is obtained, and the vertical coordinate is the number of iterations. It can be seen from the figure that the number of iteration generations for AHACO to reach the optimal is significantly smaller than that of ACS and relatively concentrated, indicating that the AHACO is very stable and has a strong convergence rate. In contrast, the ACS graph is more scattered, indicating that the algorithm converges at a low rate and is less stable. Meanwhile, the number of iterative generations for AHACO to reach the optimum increases steadily with the problem size, indicating that the algorithm is highly robust. In addition, in combination with the solution quality of Table 1, the high quality of the solution is obtained in fewer iterations, indicating that the algorithm has a good ability to jump out of the local optimum.
Compared with ACS, AHACO mainly has three additional operations: (1) k-means at the beginning of the algorithm; (2) an exponential operation every time the next city is selected; and (3) a 2-opt operation with O (n) time complexity for the optimal solution. Considering the computing power of a modern computer, the sum of these operations is far smaller than the operations required for one iteration, so this can be ignored to some extent. On the whole, AHACO has a high convergence speed and a strong ability to jump out of the local optimum.

Discussion of Parameter ξ.
e ξ parameter has a large influence on the algorithm and is the core improvement point of AHACO.
is section takes ξ min � 1, ξ max ∈ 2, 4, 8, 16 { }, respectively. Experiments on TSP instances eil51, kroA100, gil262, and pr439 use the same parameters as in Section 4.1. Figure 8 shows a graph of the experimental results. e vertical axis for the logarithm of the obtained value minus the difference between the known optimal value plus 1 is log 10 (value − optimal + 1), and the horizontal and vertical axes for the number of iterations correspond to the value obtained. Among them, the initial population optimal solutions of the improved algorithm are all much better than ACS (ξ � 1), which means that when ξ > 1, the population diversity is higher, and the algorithm searches the solution space to a greater extent. In both instances, stagnation occurred at ξ � 1, while at ξ > 1, although the quality of the solution was different, both were  continuously optimized and did not stagnate, which clearly benefited from a better population diversity. For the four cases where ξ > 1, ξ max works best when it is 8, followed by 4, and there is little difference in effect between values 2 and 16. When ξ max � 16, individual ants are more likely to choose interclass cities, the randomness of the population is enhanced, which is not conducive to convergence, and the overall effect is poor. When ξ max � 2, individual ants select interclass cities with less probability, the diversity of the population is not sufficiently enhanced, which is not conducive to searching the solution space, and the overall effect is, again, poor. e main reason why ξ max � 4 is not as effective as ξ max � 8 is that in the second half of the iteration, the convergence speed is insufficient, resulting in ξ max � 4 consuming more iterations for the same solution mass. From the present experiments, the setting of the parameter effectively improves the population diversity of the algorithm and substantially increases the convergence speed of the algorithm, which achieves the desired effect.

Ablation Experiment.
In order to verify the effectiveness of the improvements proposed in this paper, this experiment introduces two intermediate algorithms, corresponding to each improvement, defined as follows: (1) ACS + k-means (A1) and (2) A1 + 2-opt (A2). With the basic ACS and AHACO (A2 + scout-bees), a total of four algorithms are compared. In this experiment, four examples of eil51, kroA100, gil262, and lin318 are selected, and each algorithm is run separately on the example 20 times, with 1000 iterations performed each time, and the average value is calculated for comparison. Other parameters of algorithms are the same as in Section 4.1.
It can be seen in Table 3 that the result of A1 is significantly better than that of the ACS, which shows that the algorithm uses the spatial information of the TSP instance, and the population diversity is greatly improved. e result of A2 is slightly better than that of A1, which shows that the proposed 2-opt algorithm is tuning. AHACO is better than (except eil51) A2, which shows that the algorithm can jump out of the local optimum. Due to the small scale of instance eil51, the results are somewhat random, but the overall results are not affected. e idea of this paper is to use spatial information to improve the search ability of the algorithm to a large extent, introduce 2-opt for tuning, and introduce the scout bees mechanism to avoid stagnation. is experiment shows the effectiveness of the proposed improvement.

Analysis of Time Consumption.
In order to verify the running time of the proposed algorithm, this section conducts experiments on the TSP instances eil51, kroA100, kroB200, lin318, fl417, and d493 with the population sizes of 20, 40, 100, and 200. All parameters of the algorithm are the   same as in Section 4.1. e algorithm implementation does not use a parallel mechanism and is implemented in a single thread. e program only uses the "/O2" parameter during the compilation process, without other optimization parameters. e experimental results are shown in Table 4. Since AHACO has not changed the framework of ACO, this will not affect the analysis of time complexity, so the following analysis of ACO is carried out. Without considering system scheduling and other interference factors, it can be seen in Table 4 that the time consumption of ACO has a linear relationship with the population size and a square relationship with the number of cities. For the convenience of expression, we set m as the number of cities. e path generation part of the ACO is the most time-consuming process.
is part includes m selections, each time selecting m/2 cities on average. erefore, its time complexity is O(n 2 ). Each individual in the population performs the same calculation, so its time complexity is obviously O(n). Iteration is a process of repeated actions in a loop, and the time complexity is also O(n). e data show a great advantage of the ACO algorithm, that is, it has very strong robustness. In addition, the ACO will not increase rapidly in complexity as the scale of the problem becomes larger. From an implementation point of view, ACO is naturally easy to parallelize. A highly parallelized implementation, depending on the degree of parallelization, can almost reduce the time consumption of the algorithm proportionally. Compared with the precise algorithm, under the adaptive setting, ACO can obtain an acceptable solution within an acceptable time. In fact, this is a fundamental feature of metaheuristic algorithms.

Conclusions
Based on the study of the ant colony algorithm and the use of the information contained in the problem itself, an improved ant colony algorithm based on an adaptive heuristic factor (AHACO) is proposed in this paper. e traditional improved AHACO takes less consideration of the diversity of ant colonies, and its search ability is limited. Based on the TSP city classification, AHACO classifies the roles of ants and introduces the adaptive parameter ξ, which greatly improves the diversity of ants and improves the solution accuracy and convergence speed. AHACO is not limited to solving TSP problems. In the future, AHACO will be applied in other contexts.
Data Availability e data that support the findings of this study are openly available at https://doi.org/10.6084/m9.figshare.13492158. v1.

Conflicts of Interest
e authors declare that there are no conflicts of interest.