A Method for Ship Route Planning Fusing the Ant Colony Algorithm and the A* Search Algorithm

Route planning has always been an essential issue in navigation research and an important manifestation of ship intelligence. In order to get the shortest route that meets the actual navigation requirements, this paper proposes a shortest path planning method based on Automatic Identification System (AIS) data, which establishes a high-precision environment model and combines ant colony algorithm (ACA) and <inline-formula> <tex-math notation="LaTeX">$\text{A}^{\ast} $ </tex-math></inline-formula> search algorithm. We extract the key points from the initial route obtained by the <inline-formula> <tex-math notation="LaTeX">$\text{A}^{\ast} $ </tex-math></inline-formula> search algorithm and then introduce the Bézier curve method to smooth the route to obtain the planned route. This strategy assures that the planned route satisfies the global optimal and actual navigation needs. A bulk carrier is selected for experimental validation, and the experimental results verify the effectiveness of the method proposed in this paper. Compared with the other algorithm, the algorithm proposed in this paper can obtain shorter paths faster and more efficiently when performed.


I. INTRODUCTION
Maritime transport is responsible for 90 percent of worldwide cargo transportation and plays a vital role in global economic development. Before setting sail, navigators must prepare a sensible route based on the ship's cargo capacity, speed, departure time, topographical data, and weather data, as the route directly affects the ship's safety and economy [1]. With the continual advancement of ship intelligence levels and unmanned ship, automatic route planning has become a fundamental technology for autonomous ship navigation, with the level of route planning determining the intelligence level of the ship [1], [2], [3], [4]. Artificial intelligence technology, big data mining technology, and electronic information technology enable the gradual replacement of human route drawing with the utilization of existing route resources to produce more appropriate route proposals.
In recent years, numerous academics have presented a variety of route planning algorithms that considerably enhance the performance of route planning algorithms and make the automatically generated routes superior, more cost-effective, The associate editor coordinating the review of this manuscript and approving it for publication was Yiqi Liu . and dependable, with a more significant practical application value [5], [6].
Some academics rasterize electronic navigational charts (ENC) and construct grid environment models using obstacle extraction or obstacle grid setup. Wang et al. [7] developed the binary trees method based on the ENC, while Lyu et al. [8] proposed the stack method to bypass the barriers on the way back. Wang [9] incorporated the route's width into the algorithm so that the ship could avoid obstructions more practically and achieve automatic route planning. Guo [10] used the grid method to process the marine environment in the ENC into a two-dimensional simulation of the marine environment and used a deep Q network (DQN) based optimization algorithm to plan the coastal route automatically.
In addition, Automatic Identification System (AIS) databased automatic route planning is a popular study area. Many researchers have used route planning algorithms such as the Dijkstra algorithm [11], [12], dynamic planning algorithm [13], [14], ant colony algorithm (ACA) [15], and its optimization algorithm to generate optimal routes based on the navigable points or trajectory points in the AIS data [16].
Numerous researchers have also incorporated other algorithms to improve the route planning approach. Andersson and Ivehammar [17] devised a dynamic route planning algorithm to compute the maximum benefit of a route; their method can assist ship owners in reducing fuel consumption expenses and CO 2 emissions. Their proposed strategy can assist ship owners in reducing fuel expenses and carbon dioxide emissions. Dong et al. [18] modified the conventional ant colony algorithm and suggested a double ant colony algorithm to create an energy-efficient route planning system. Li et al. clustered the trajectory lines of AIS, with their suggested clustering technique employing the merge distance theory, and the improved DBSCAN algorithm able to determine the trajectory's direction [19]. The strategy suggested by Peng begins by performing noise-based density-based spatial clustering on a large number of vessel trajectories to construct distinct clusters of trajectory vectors. Then, calculate their centerlines iteratively in the clusters of trajectory vectors and design a canal network based on the node-arc topology link between these centerlines [20]. Zhang [21] accurately determined many turning sites by evaluating a significant amount of AIS trajectory data and then planned routes using an ant colony method. Both Liu [22] and Song [23] optimized the traditional A * algorithm in the process of route planning for unmanned vessels and gridded the map to obtain routes in complex obstacle environments finally.
However, relevant research and technology still need to resolve issues. First, the automatic ocean route planning algorithm based on electronic charts must rely on many electronic chart data [7], [8], [9]. Wang and Lyu's [7], [8] paper also mentions that further improvements in accuracy require access to more chart information, such as obstacles. Therefore, the latest ENC data needs to be updated in stages, and dynamically updating these electronic chart data incurs higher economic and time costs than AIS data. Secondly, whether based on ENC or AIS data, automatically planning routes must consider the environmental model's accuracy [7], [16], and the increase in accuracy will increase computational cost. However, if the precision of the environment model is lowered, the automatically generated path will cross land, which is dangerous and unusable. Thirdly, ACA and the Dijkstra algorithm can locate the globally best path, but the calculation time is lengthy [15]. Therefore, in response to the gap proposed in the previous paragraph, this paper proposes an automatic shortest-route planning method based on AIS data. The proposed method combines ACA with A * search algorithm to determine the shortest path. First, ACA restricts the initial shortest route region range, which can also reduce large calculation nodes. Then, we take advantage of the fast search speed of the A * algorithm to look for the shortest path within the initial range constraints. Finally, we optimize the projected route line by removing duplicate points, extracting key points, and utilizing the Bézier curve method to smooth the route.
The remaining sections of this paper are as follows: Section II introduces the process of constructing the environment model; Section III proposes the shortest path planning method combining ACA and the A * search algorithm; in Section IV, a bulk carrier is utilized as the target vessel to plan a part of its route with the method provided in this paper and compare it to the actual trajectory of the vessel to illustrate the algorithm's applicability. Section V provides a summary of the entire paper.

II. ENVIRONMENT MODEL DEVELOPMENT A. PRE-PROCESSING AIS DATA
Before developing the environment model, one of the most crucial processes is pre-processing the vast quantity of AIS data. The AIS data selected for this study are mainly from the sea off China, totaling about 35,000 items. First, we cleaned the abnormal AIS data. The principles of excluding abnormal data are as follows: • The sailing speed < 0 or > 50 knots; • The depth < 0 meters; • The heading < 0 • or > 360 • ; After the first step of processing, about 34,000 items of data can be used for the subsequent study.
Second, the parameters, including latitude, longitude, speed, and draft data from the AIS data, were kept for the developing environment model. Filtering ship speed ensures that the environmental model is constructed to meet the speed requirements of the ship and that no obstacle areas are included in the environmental model. The filtering of the ship's draught ensures that the environmental model is constructed to meet the draught requirements of the ship and that the route is planned within the allowable water depth for the target ship. Finally, it is necessary to filter the AIS data ranges based on the target vessel's speed and actual draft further.

B. ENVIRONMENT MODEL DEVELOPMENT
This section employs the grid mapping approach to construct the environment model using the AIS data filtered in Section II-A. A ship's route in a particular navigation area may be simplified to the path of a ship between two locations on a plane. The grid mapping method breaks the supplied navigation area map into some grids and assigns the specified unit length to each grid's edge length. The free attribute grids designated with white color and the obstacle grids marked with black color are then decided based on the navigability of a single grid in the navigation area map. Using the grid mapping method, the route planning issue in a complex spatial navigation environment is converted into searching the path between two grid centroids in a two-dimensional grid that satisfies certain constraints.
Assuming that the length of the working environment map is L, the breadth is N , each square grid has a height and width of l, the environment may be partitioned into an information map of nn * mm cell grids, satisfying the Equation (1).
In route planning, AIS point data in a grid is used to determine a free attribute grid; if there is no AIS data, the grid is an obstacle grid.
Chart represents the whole environment, grid i,j represents all the information of a grid unit, i denotes horizontal, i.e., east-west direction, and j denotes vertical, i.e., north-south direction, all grids are placed in the set P, n and m are the maximum values of i and j in the environment space, and the expression is shown in Equation (2)

III. METHODOLOGY
The proposed method consists of three steps. In the first step, the estimated grid range of the shortest path is determined. Utilize ACA to calculate the range through which the shortest path goes on the low precision environment model. Second, locating the shortest route in an improved environment model. This step will rebuild a high-precision environment model based on the first step's approximate grid range and calculate the shortest route using the A * search duplicate points, extract critical points, and then smooth the path using the Bézier curve method. The flow chart is depicted in Figure 1. Thirdly, optimize routes, so the planned path corresponds to the actual route.

A. DETERMINE THE GRID RANGE WITH THE LEAST DISTANCE USING ACA
This section's primary purpose is to determine the grid range of the shortest route. First, the low-precision environment model is generated, the grid width is set to 0.5 • , and ACA is used to determine the shortest route under the low-precision environment model. The free attribute grids in eight directions of each node along the route are then included in the grid range, while the free attribute grids and obstacle grids in other places are classified as obstacle grids.

1) CONSTRUCTING THE ADJACENCY MATRIX
An environmental model-compliant adjacency matrix is utilized to record the distance between adjacent navigable grids, as shown in Figure 2. As depicted in Figure 2, grid i−1,j+1 and grid i,j−1 are obstacle, thus, ant in grid i,j can travel to other six free attribute grids, the distance between two free attribute grid is given by Equation (3), and the distance between free attribute grid and obstacle grid is infinity. where lat i,j denotes the latitude of grid i,j ; lon i,j denotes the longitude of grid i,j ; lat i,j+1 denotes the latitude of grid i,j+1 ; lon i,j+1 denotes the longitude of grid i,j+1 .

2) ANT COLONY ALGORITHM (ACA)
ACA is an intelligent evolutionary algorithm based on parameterized probability distribution, where the model parameters are the pheromones generated by the individual ant colony; hence, ACA is, in essence, an intelligent pheromonebased optimization method. The core of ACA for ship route planning is the update of state transfer probability and pheromone [15]. Assume that the total number of ants is m. The transfer probability (p k ij ) from route node i to route node j at time t for the k th ant is given by Equation (4).
where the parameter α is information heuristic factor, indicating the importance of pheromone concentration. The parameter β is expectation heuristic factor, indicating the importance of the distance between the route nodes. The symbol τ ij (t) is the pheromone concentration between the route nodes i and j at time t. The symbol η ij (t) is the heuristic function, which represents the expectation of an ant individual from the route node i to j, takes the value 1/d ij , as Equation (5) shown, d ij is the distance between the current node i and the next node j.
If the value of the distance d ij between the current node and the next node is larger, the value of the heuristic function η ij (t) will be smaller; consequently, the probability of ants choosing this node will be smaller, as will the transfer probability; conversely, if the value of the distance d ij between the current node and the next node is smaller, the value of the heuristic function η ij (t) will be larger. Therefore, the distance between the present node and the next node influences, to some extent, the probability that this ant will choose that node. In order to prevent the ants from selecting the same nodes multiple times, a taboo table is created and updated whenever the ants reach a new node. The symbol allowed k is the turn point of the path that the k th ant can pick during the search process, and the transfer probability takes the value 0 if it is not within this range. This assures that the ants will not continually pass a node and form a loop. Consequently, the ants select numerous possible paths based on the pheromone and the length of the path.
According to the idea of ACA, the algorithm achieves optimal path solution by constantly passing ants via a shorter path over time, while leaving pheromones on this road to attract more ants. Due to the existence of this positive feedback mechanism, if the pheromone on this shorter path is too strong, the heuristic information of the ant colony will lose its effectiveness and the ants will not explore other solutions in the space, causing the ant colony algorithm to reach a local maximum. To remedy this issue, a volatile mechanism must be added to the ant colony algorithm to update the pheromone, and the pheromone is updated after each iteration based on this volatile mechanism. Therefore, the pheromone on the path at the moment (t + 1) is updated in the manner shown in Equation (6) and (7).
We chose Ant-Cycle model to update the pheromone. Equation (8) represents the update of pheromone using global information, i.e., when the ant reaches the end point, the algorithm updates the pheromone on the whole path searched out this time.
where the symbol τ ij (t + 1) is the pheromone of the route node i to node j at time t + 1. The symbol τ k ij (t) is the increment of pheromone released by the k th ant on the path at time point t, and the initial value is 0. The parameter ρ is The pheromone volatility factor, taking values between [0, 1] and 1 − ρ is the pheromone residual factor. The parameters Q is the pheromone intensity. The parameter Lk is the length of the route traversed by the k th ant in this iteration.
As shown in the Equation (7) and (8), the heuristic function, the pheromone, and the collaboration among ants all have a significant impact on the convergence of the algorithm; in this case, the pheromone correlation factor α, (1−ρ), β, the number of ants m, the pheromone strength Q, and the iteration number in the model are also crucial factors that affect the algorithm's performance and efficiency [25].

3) DETERMINE THE GRID RANGE WITH THE LEAST DISTANCE
We apply ACA algorithm to determine the shortest path given the present environment model, with the primary procedure being as follows.
1) Convert the specified starting point A and ending point B to their respective grid positions in the grid map, starting grid A and ending grid B; 2) Initialize and set the parameters for each ant population; 3) Select the next neighboring free attribute grid using the roulette wheel approach. The adjacent free attribute grid and its distance are determined based on the findings of the free attribute grids partitioning model; 4) Each ant follows the pheromone's trail until it reaches ending point B; 5) Document the passable path and total distance traveled by each grid; 6) Update the pheromone; 7) Determine if the population has reached its maximum iteration; 8) Return the shortest route; Figure 3 is the flow chart of finding the shortest path based on ACA.
Second, the free attribute grid range is further reduced according to the calculated shortest path. The five grid nodes through which the shortest route travels, as depicted in Figure 4.a, the free attribute grid adjacent to each node is within the range determined by the shortest path. As shown in Figure 4.b, the blue grid is the range of grids chosen by the shortest route, while grids outside of this range become obstacle grids.
Finally, we employ ACA to determine the shortest path's grid range under low-precision environment model.

B. SHORTEST ROUTE PLANNING MODEL BASED ON A * SEARCH ALGORITHM
This section employs the A * search algorithm to compute the shortest route in the exact environment based on the grid range involved in the shortest path found in section III-A  to assure the route's safety. In the first step, the high-precision environment model is produced under the grid range initially defined in Section III A. In the second step, the A * search algorithm is applied to find the shortest path in the high-precision environment model. The grid range provided by ACA is a somewhat coarse model, and we must still improve the grid to provide a more precise environment model. The width of the unit grid is lowered to 0.0625 • to generate a more accurate environment model based on the navigable range determined in Section III-A. The grid width of this environment model is 1/8 of the grid width of the section III-A environment model.
The A * search algorithm chooses the route that minimizes Equation (9), a heuristic function of the A * search method.
where G(n) is the true cost of moving between the starting nodes of the current grid, as demonstrated by Equation (10), while d(n, n − 1) is given by Equation (3). And H (n) represents the predicted movement cost between the current and end grid. The A * search algorithm and Dijkstra algorithm are identical if H (n) = 0 [26]. The current grid's distance function to the ending grid is substituted for H (n) in Equation (3).
A * search algorithm uses the open list to hold nodes waiting to be examined and the close list to store nodes that have been previously explored. The A * search algorithm follows these steps: Step 1: Insert the starting point S into the open list; Step 2: If the endpoint E is present in the open list, the path search is complete. If no open list exists, the path does not exist; Step 3: Choose the node u in the open list with the most minor estimated value F as the active node and add it to the close list; Step Repeat Step 2 to 4 until the process is complete. Finally, the each node of shortest route is output.

C. ROUTE OPTIMIZATION BASED ON BÉZIER CURVE METHOD
The A * search algorithm's suggested path includes numerous redundant steering points and sharp turning points significantly different from the actual route. To ensure that the designed route meets the exact turning radius of the ship, we introduce the bezier method of smooth route planning so that the vessel does not change direction sharply at a specific turning point and affect the standard navigation of the ship. For this issue, we presented a Bézier curve-based path optimization approach. The main steps are as follows. Firstly, eliminate redundant points and extract key points. Suppose the current path node is on the same line as the preceding and subsequent nodes. In that case, the current node is deleted, the path is updated, the subsequent nodes are found to be on the same line, and the last remaining node is the critical point. Furthermore, extract key points and ensure that the reconnected line segment does not cross the obstacle grid. For instance, after the first step, the key points (M 1 , M 2 , . . . , M k ) are gathered, and M 1 and M 3 are linked to generate the line l (The line function: Ax + By + C = 0). Determine whether the connected M 1 and M 3 will pass through the obstacle grid N ((x, y), (x, −y), (−x, −y), (−x, y) for the four vertices of the obstacle grid N ) using the Equation (11). If it does not pass through the obstacle grid N , point P 2 can be deleted, the path can be updated, and subsequent M k and M 1 can be joined in succession until the new line segment goes through the obstacle grid N . The final processed route {P i |i = 1, 2, 3, . . . , n} is obtained.
Secondly, the processed route is smoothed using the thirdorder Bézier curve method, as shown in Equation (12). Given the coordinates of control points P i to P i+3 , the first point P i = {x i , y i }, the second point P i+1 = {x i+1 , y i+1 }, and so on. The parameter t moves from 0 to 1, the step is 0.05, and the loop goes over 0, 0.05, 0.1, 0.15, . . . , 0.95, 1. Figure 5 briefly illustrates the route after the two-step process. Figure 5.a is the initial route generated by the A * search algorithm, Figure 5.b shows the route after eliminating redundant points, Figure 5.c shows the route after extracting key points, and Figure 5.d shows the route after smoothing with the Bézier curve method.

A. EXPERIMENTAL DESIGN
This experiment's target vessel is a bulk ship whose major parameters are detailed in TABLE 1. The vessel sails from the west coast of Africa via the Cape of Good Hope and the Strait of Malacca to the Chinese city of Tianjin. A portion of the ship's itinerary was chosen as the subject of this investigation. The ship set sail for the sea of Zhoushan Islands, China, on June 4, 2022, at 13:00 (UTC), when the longitude was 123.981 • E, the latitude was 30.875 • N, and the port berth was located at 118.485 • E and 38.826 • N. Accordingly, we confined the search area to latitudes 30 • N to 41 • N and longitudes 117 • E to 125 E. In addition, we kept AIS data with a depth of 10m or more and a speed of more than 5kn based on data from TABLE 1 and principle in Section II-A.
The code used in this study both written in python, and the program was run on a particular laptop with 4 Core i5 for testing.

B. EXPERIMENTS RESULTS AND ANALYSIS
Firstly, determining the shortest route's grid range. Moreover, the grid width is set to 0.5 • in this step as mentioned in Section III-A. As a result, the low-precision environment model consists of 16 * 22 grids, as depicted in Figure 6, where white represents the free attribute grid and black represents the obstacle grids. The inital values of ACA are given in TABLE 2, which is referred from Wu et al. paper [1].    the ACA, the navigable area is reduced further. This step restricts the initial shortest route region range and reduces the number of search nodes, improving search efficiency and saving search time for subsequent searches.
In this stage, the A * search algorithm was utilized to determine the shortest route based on the navigable grid range determined in the previous step. As illustrated in Figure 8, we began by refining the environment model by reducing the grid width to 0.0625 • to obtain a more precise environment model. As a result, the high-precision environment model consists of 128 * 176 grids.
Based on the grid range obtained by the ACA, we reconstructed the grid depicted in Figure 8 and use the A * search algorithm to determine the shortest route to acquire the results depicted in Figure 9; the red line represents the A * search algorithm's computed route. After the initial determination of the shortest route range by the ACA algorithm, the number of free attribute grids decreased from 3172 to 2108. More importantly, a comparison of Figure 8 and Figure 9 demonstrate that the range of free attribute grids is significantly reduced, free attribute grids that are not related to the route were excluded.
According to the method described in Section III-C, the red path in Figure 9 was optimized, with a total of 176 turning points. Firstly, we obtain the processed route depicted in Figure 10 by eliminating the unnecessary points and   extracting the key points, five turning points remaining. Then, we used the Bézier curve method to smooth the processed route depicted in Figure 10, resulting in the optimal route depicted in Figure 11, and the final 45 points were generated. We used Equation (11) to check the safety of the 45 points shown in Figure 11. None of the 44 line segments made up of the 45 points pass through the obstacle and can be sailed safely. The total distance of the three routes is calculated as indicated in TABLE 3. Following optimization, the total distance of the routes is decreased by 12.8 nautical miles. The difference between the distance of the route before and after smoothing is around 0.05 nm. Selecting some of the segments for evaluation, as shown in Figure 12, the original route's meandering route requires only two crucial locations to reach the ending point. Therefore, this can further prevent the rise in navigation miles produced by the A * algorithm's local optimum. As illustrated in Figure 13, we also employed the Bézier curve method to smooth the route's turning points, making the planned route close to the real navigation.  To verify the effectiveness the proposed algorithm, we compared the planned route proposed by in this paper and actual trajectory of the target ship, as depicted in Figure 14. It can be observed that after passing through the Zhoushan Islands, the target ship did not take a straight line to the north but instead slightly changed its direction and sailed towards the outer sea before heading north to the Bohai Sea. As a   result, the total distance of the actual trajectory is 662 nautical miles. Compared to the planned route, the distance of the actual trajectory is approximately 40 nautical miles longer than the planned route. In addition, the route safety check demonstrates that all planned routes meet navigational safety requirements and allow transit through waterways safely. The planned route in the figure also indicates that the planned path safely traverses the Bohai Strait via the Old Tieshan waterway before arriving at its destination, which is identical to the actual route.Therefore, the planned routes obtained with the algorithm proposed in this paper are able to meet the route safety requirements.
To verify the advancement of proposed algorithm, we compared it with A * algorithm. Figure 15 shows the result of A * search algorithm, and Table 4 shows the planned route length and planning time. From Table 4, The algorithms proposed in this paper all outperform the results calculated by the comparison algorithms. Compared with the single A * search algorithm results, the proposed algorithm's planning time is reduced by about 42%. The length of the planned route is reduced by about 2.5%, and the number of turning points is reduced by about 74.5%, so the proposed algorithm can significantly improve the search efficiency and plan a shorter route.

V. CONCLUSION
This paper proposes an automatic planning algorithm that combines the ACA and the A * search algorithm for the shortest route. Firstly, a low-precision environment model is constructed based on the AIS data, and the grid range of the shortest route is determined using the ACA to ensure the global optimum and reduce the calculation nodes. Secondly, the A * search algorithm determines the shortest route under a more refined environment model. Thirdly, the path's key points are extracted and optimized using the Bézier curve method to obtain the shortest route that meets the actual requirements.
The experiments show that the algorithm proposed in this paper can reduce the computation nodes and obtain the shortest route that meets the safety requirements. The proposed algorithm has strong optimization capabilities and can provide meaningful guidance for shortest-path planning for intelligent ships or even unmanned ships in unknown obstacle environments, promoting the intellectual development of shipping.
This study proposes a method with some limitations, and we can still enhance the planning performance by following directions. Firstly, a high-precision environment model is required to compute the shortest and safe route. Building a high-precision environment model requires massive AIS data to prevent blind zones. Secondly, additional information, such as ENC data, needs to be introduced when building the environmental model to determine navigable areas. Thirdly, when the shortest distance is recalculated using the A * search algorithm, the heuristic function must be re-optimized, and the traditional 8-neighborhood A * search algorithm is used in this study. For better accuracy, 16-neighborhood and even 32-neighborhood A * search algorithm should be introduced.