Improved Ant Colony Algorithm for AGV Path Planning

: Given the shortcomings of the ant colony algorithm in the path planning process, such as low convergence speed and easiness of falling into local optimization, an improved ant colony algorithm (ACO) suitable for AGV path planning was proposed. The initial pheromone concentration was differentiated on the grid map according to the distance, which avoided the blind search in the early stage of the ant colony and sped up the convergence speed of the algorithm. The distance between the current grid and the grid to be selected and the distance between the grid to be selected, and the target grid were synthesized to improve the heuristic function to increase the direction of ant colony pathfinding. The dynamic heuristic factor was introduced to avoid the phenomenon of prematurity and falling into local optimization. It was proposed to label the direction of the adjacent grid of each grid, which increased the distance between the optimal path and obstacles, enhanced the security of the optimal path, avoided the occurrence of the dead corner phenomenon, and improved the robustness of the algorithm. The simulation results show that in the same environment, the improved algorithm's search efficiency and iterative stability are better than that of basic ACO algorithms in AGV path planning.

environment model. A 5×5 grid environment is shown in Figure 1, with the lower left corner of the environment as the coordinates, upwards as the positive direction of the Y-axis and to the right as the positive direction of the X-axis, a plane right angle coordinate system established and a grid cell length of 1cm is selected (Zhao & Cheah, 2023).
The grid environment is labelled from left to right and from top to bottom. In an m x m grid environment, the serial number S corresponds to the coordinates (x, y) of the raster in which it is located, and the correspondence is: Where mod is a remainder operation, ceil is an upward rounding operation. Thus, the travel path of an AGV can be represented as a series of sequences of numbers.

Figure 1 AGV Grid Environment
The directions of motion of the AGV are shown in Figure 2. Except for the edge grids, each grid generally has eight directions of motion: top left, top, top right, left, right, bottom left, bottom right and bottom right, which are numbered 1, 2, 3, 4, 5, 6, 7 and 8 numbers respectively (Zheng, Sayed, & Essa, 2019

Grid Environmental Processing
During indoor movement of the AGV, it is one of the considerations in AVG path planning to ensure that the optimal path avoids collisions with static obstacles and improves the safety of the path. If the optional grid contains an odd number of grids, it is determined whether two neighboring grids perpendicular to the direction of the path are obstacles. If one of the two neighboring grids is an obstacle, the grid is considered a "forbidden grid". This method reduces the likelihood of collision between the AGV and the obstacle. The correct path of travel is away from the edge of the obstacle as shown in Figure 3, reducing the possibility of collision between the AGV and static obstacles and increasing the safety of AGV indoor operations (Yu, Yuan, Li, Yuan, & Deng, 2023).

Figure 3 Collision Avoidance Effect
The "dead corner" phenomenon frequently occurs during the iterative process of the algorithm, affecting the efficiency of the ant colony search and the final result of the algorithm.
This affects the search's efficiency and the algorithm's final result. As can be seen from Figure   4, both the basic ACO and the improved algorithm only consider the distance between the grid to be selected, and the target grid as the criterion for route selection, resulting in the grid labelled 3 still being included in the queue of selectable grids when the AGV travels to grid .
When the AGV travels to grid 3, it finds that it can only travel toward grid 2 or grid 4.

Figure 4 Comparison of Algorithm Results
To solve the problem of "dead corner" during the iteration of the algorithm, this paper extends a layer of the raster on top of the neighbouring raster for calculation. As shown in Figure 5, the neighbouring grid of grid , labelled 3, is a feasible grid, and the two neighbouring grids perpendicular to it (grids 2,4) are both feasible grids, so grid 3 satisfies the path safety criterion. However, the neighbouring grids of grid 3, marked 2 and 4, are obstacles, so grid moves to grid 3 and eventually moves to the left or down. Therefore, for grid , grid 3 is called a "dead corner". In contrast to a colony that is trapped in a "dead-end" situation, this algorithm reduces the computational effort, the number of turns and the length of the optimal path by marking grid 3 as a "forbidden grid" in advance and moving directly from grid to grid 2 or grid 4. This reduces the computational effort of the algorithm as well as the number of turns and the length of the optimal path, speeds up the convergence of the algorithm based on the search for the global optimal path and saves energy in the operation of the AGV.

State transition probability
At time , ant is moved from node to node by calculating the state transition probability ( ); then, the next node is selected according to the roulette method, which is defined as: is the heuristic function and represents the Euler distance from the current node to the candidate node, ( ) is the pheromone concentration between two nodes, allowed is the set of next mobile nodes to be selected by the ants, and and are the pheromone importance factor and heuristic function importance factor, respectively.

Pheromone update strategy
The pheromone update strategy is a process in which the ant colony algorithm continuously realizes positive feedback. Through this method, the ant colony guides the descendants of the ants to continuously converge to obtain an optimal path (Xiao et al., 2022). After all contemporary ants have reached the target, each ant will update the pheromone concentration according to Equation 3, Equation 4, and Equation 5. Where ∈ (0,1) is the pheromone volatilization coefficient, Δ ( ) is the sum of pheromone increments for all ants, Δ ( ) is the pheromone increment of the th ant on the path ( , ), is the pheromone intensity, and is the total path length of the th ant after one iteration.

Improvement Ant Colony Algorithm
In the early iterations of the ant colony algorithm, the lack of differentiated initial pheromone concentration in the map environment and the lack of guiding factors in the pathfinding process leads to blind searching by the ant colony in the early stages of the algorithm and slow convergence of the algorithm. Therefore, this paper designs a differential initial pheromone concentration based on the Euclidean distance, the known map environment model, and the initial pheromone's differential distribution around the starting point and the "sub-optimal path" produced by the target point (Sun et al., 2021).
Where Tau( , ) is the pheromone concentration between the feasible grid and the feasible grid , is the Euclidean distance between the departure grid and the current grid , is the Euclidean distance between the departure grid and the current grid , is the Euclidean distance between the departure grid and the current grid , is the Euclidean distance between the starting grid and the target grid, min( ) is the minimum Euclidean distance of grid from the "suboptimal path", , , , are the Euclidean distances between two grids on the "suboptimal path", is the discretization factor. A larger represents a larger discrepancy in the initial global pheromone concentration (Cenerini, Mehrez, Han, Jeon, & Melek, 2023).
The straight line between the two points is the shortest distance, but if only the line between the start and end grid is treated as a "sub-optimal path" and the static obstacle between the start and end grid is not considered, a direct pheromone concentration initialization of the line between the two grids will instead mislead the ant colony to search for the pheromone. As shown in Figure 6(a), the dashed line is the global optimal path and the solid line is the path finding result according to the initial pheromone. As the initialization of the pheromone does not consider the influence of static obstacles between the connecting lines, the ant colony needs to continue searching randomly along the obstacles to find the shortest path when it reaches the obstacles, which is inefficient and difficult to converge to the global optimal. The initial pheromone concentration between the grids is then determined based on the Euclidean distance, with the shorter the distance from the "next best path", the higher the initial pheromone concentration and the lower the opposite. The specific method for determining the 'second best path' is as follows: first determine the line between the starting grid and the ending grid, and when there is an obstacle in the line of grid ( , ), form a breakpoint at the obstacle. If the obstacle is located to the left or right of the breakpoint, a search will be carried out up and down the obstacle, recording the number of obstacles until a workable grid is found.
Compare the number of obstacles in both directions and select the feasible grid in the direction with fewer obstacles as the next starting point. Compare the number of obstacles in both directions and select the feasible grid in the direction with fewer obstacles as the next starting point until you reach the end grid and finally find the 'next best route'. As shown in the solid line in Figure 6(a), there is an obstacle in the connection of grid (s, e), and the obstacle is located to the right of the breakpoint, so search up and down along the obstacle, and find that the number of obstacle grids downward is less, so the feasible grid below the obstacle is used as a new starting point to continue the search, which eventually forms the "second-best path" shown in the dashed line in the figure. The dashed line in Figure 6(b) shows that grid is the grid to be selected from grid . Grid is the grid to be selected from grid . The closest grid m to the "next best route" is selected as the origin. The initial pheromone concentration between grids ( , ) can be calculated using Equation 6.

Figure 6 Principle of Pheromone Initialization
As shown in Figure 6, when grid and grid are closer to the "second-best path", the higher the concentration of initialized pheromone between grid and grid , the more likely the ant colony will search in the direction of that path in the pathfinding process, improving the

Improvement Heuristic Function
In the basic ant colony algorithm, the heuristic function is determined only by the distance between the current grid and the grid to be selected. However, the difference in distance between the grids is small and it is difficult for the colony to select the best grids from the many available grids simply by the distance d between the grids. The best grid is selected by the ant colony only by the inter-grid distance . For example, when the unit grid width is 1 , the minimum distance between adjacent grids is 1 and the maximum distance is about 1.4; after the distance heuristic function of the basic ACO algorithm, the difference between the nearest adjacent grid and the farthest adjacent grid is only about 0.3 . The distance heuristic function has a weak pathfinding effect on the ant colony, which cannot combine the pheromone concentration between grids and the distance between grids. This reduces the search efficiency of the ant colony algorithm as well as the final pathfinding effect. Therefore, this paper improves a heuristic function whose value is determined by the distance between the current grid and the grid to be selected and the distance between the grid to be selected and the target grid , as shown in Equation 7.
( ) = * + * To avoid the problem of weak guidance of the heuristic function value on the ant colony pathfinding process due to the small distance difference between the grids, the method of amplifying the distance difference is used to enhance the "superiority and inferiority" between the grids to be selected.
To facilitate the heuristic function calculation, the neighbouring grid of each grid is created distance matrix 2 ×8 , as shown in Equation11: Where is the width per unit grid, and ( ) is the state of grid . A value of 0 indicates a feasible grid, and a value of 1 indicates a static obstruction. is the direction of the grid to be selected with respect to grid . , ′′ , 1 , 2 are the neighbouring grids perpendicular to the direction of the slash.

Pheromone Update Strategy
The pheromone factor determines how important it is for the ant to be influenced by the pheromone concentration as the ant travels to the next grid in the pathfinding process. To enhance the colony's global search ability and avoid the occurrence of local optimum or "early maturity," the pheromone factor was set smaller to reduce the pheromone guidance to the colony's pathfinding. As the number of iterations increases, the ant colony accumulates more pheromones on better paths and fewer pheromones on worse paths during pathfinding. By increasing the pheromone factor, the ant colony follows the paths with higher pheromone concentration, narrowing the search range and speeding up the algorithm's convergence. As shown in Equation 12: Where max is the maximum number of iterations, and is the current number of iterations. To avoid the algorithm falling into local optimum due to excessive pheromone importance in the later stages of the algorithm, max is set as the upper bound threshold of pheromone importance.

Experimental Preparation
All algorithms in this paper have been implemented by MATLAB simulation. The map is modelled using the grid method with a map size of 20 x 20. To avoid errors from a single experiment, 30 simulations are carried out and the experimental data are averaged. To increase the realism of the map, static obstacles were randomly distributed in the map grid.
The performance of the basic and improved ant colony algorithms was analyzed in a 20×20 raster size environment, and the relevant parameters are shown in Table 1.

Comparison of Algorithm Performance
The basic ACO algorithm was compared with the improved ACO algorithm on a map size of 20×20 grid. The simulation results are shown in Figure 7 and Table 2.   Figure 7 (a) and Figure 7 (b) show the optimal planning paths for the basic and improved ant colony algorithms for a grid map size of 20 × 20, respectively. It can be seen from the diagram that the improved ACO algorithm avoids "dead ends" and reduces the length of the path and the number of turns. And as can be seen from

Conclusions
Improvements to the ACO's initialization of pheromone concentrations and heuristic functions in the construction of 2D planar maps have improved the overall performance of the ACO, for example, by increasing the speed of convergence, finding the global optimal path and increasing the stability of the algorithm. By introducing a "directional numbering" for each raster to avoid "dead ends" and a "cornering" mechanism, the distance between the optimal path and the obstacle is reasonably increased. This improves the safety and reliability of the AGV path. By introducing a dynamic pheromone factor, the algorithm avoids the phenomenon of "premature" in the early stage and partial optimization in the later stage. Simulation experiments and results show that the algorithm can achieve the optimal ratio between path length reduction and the number of turns and plan a safe and reliable optimal path for the AGV. Compared with other algorithms, the algorithm in this paper outperforms in terms of convergence, stability and finding the shortest path. The algorithm performs better than others regarding convergence, stability and finding the shortest path. The algorithm plans the global optimal path based on the AGV path's safety, which improves convergence speed and enhances the algorithm's stability. In future research, the particle swarm algorithm can be combined with parameter optimization to plan more intelligent paths. The sliding window method can be introduced to enable the AGV to achieve dynamic obstacle avoidance in dynamic environments.