Grid-Based coverage path planning with NFZ avoidance for UAV using parallel self-adaptive ant colony optimization algorithm in cloud IoT

In recent years, with the development of Unmanned Aerial Vehicle (UAV) and Cloud Internet-of-Things (Cloud IoT) technology, data collection using UAVs has become a new technology hotspot for many Cloud IoT applications. Due to constraints such as the limited power life, weak computing power of UAV and no-fly zones restrictions in the environment, it is necessary to use cloud server with powerful computing power in the Internet of Things to plan the path for UAV. This paper proposes a coverage path planning algorithm called Parallel Self-Adaptive Ant Colony Optimization Algorithm (PSAACO). In the proposed algorithm, we apply grid technique to map the area, adopt inversion and insertion operators to modify paths, use self-adaptive parameter setting to tune the pattern, and employ parallel computing to improve performance. This work also addresses an additional challenge of using the dynamic Floyd algorithm to avoid no-fly zones. The proposal is extensively evaluated. Some experiments show that the performance of the PSAACO algorithm is significantly improved by using parallel computing and self-adaptive parameter configuration. Especially, the algorithm has greater advantages when the areas are large or the no-fly zones are complex. Other experiments, in comparison with other algorithms and existing works, show that the path planned by PSAACO has the least energy consumption and the shortest completion time.


Introduction
With the rapid development of the Internet of Things(IoT), the number of connected devices increases exponentially [1]. Due to the limited energy and computing power, terminal devices often offload computing tasks to servers with higher computing power. One approach is to apply edge computing(EC) technology which can offload tasks to edge servers to relieve the pressure of limited computing resources on terminal devices [2]. Generally, EC arranges edge servers at the network edge so as to ensure that the computation is performed near data sources [3]. The other approach is to offload computing tasks to cloud servers Page 2 of 28 Gong et al. Journal of Cloud Computing (2022) 11:29 by processing the data of these devices. This paper focuses on the application of UAV.
Over the past few decades, UAVs have been widely used in military and civilian applications [24]. The UAVs can be used for search and rescue [25,26], photogrammetry [27,28], structures inspection [29,30], model reconstruction [31,32], smart farming [33,34], post-earthquake assessment [35] etc. Many of these UAVs applications involve Coverage Path Planning (CPP) technique, which requires building a path that guarantees that an agent will explore every location in a given scenario [36] . CPP confronts a number of challenges, such as avoiding obstacles [37], data collection [38], avoiding no-fly zone(NFZ) [39], etc. Depending on the size and complexity of areas of interest, exact or approximate cellular decomposition can be applied to decompose the areas and build efficient paths [40]. In addition, planning paths for large areas requires a lot of execution time, using cloud computing is a good choice [41]. For simple CPP missions, the most common performance metrics found in the literature are: the total travelled distance or the path length, the time-to-complete a mission, the area coverage maximization, and the number of turning maneuvers [42]. These metrics depend mainly on two factors: the path length and the number of turns.
This paper, we propose a novel parallel self-adaptive ant colony optimization algorithm(PSAACO) to complete a grid-based CPP. And dynamical Floyd algorithm(DFA) is presented to avoid NFZs efficiently. These two algorithms require a lot of computing time, so they run on the cloud server. Our main contributions are as follows: • Apply grid-based techniques to decompose the area of interest into cells, map the NFZs using rectangles, and label the gird cells and NFZs with A-Type and N-Type points, respectively. Based on the labeled area, establish the model of the CPP problem, and put forward the formula for the model. • Improve the ACO algorithm and propose the PSAACO algorithm. Apply the inversion operator and the insertion operator in the PSAACO algorithm, and make it suitable for solving the CPP problem. • Introduce a self-adaptive setting method for parameters of PSAACO algorithm, and prove the superiority of self-adaptive setting method by experiments. • Apply multi-thread parallel computing in the algorithm, and prove the improvement of the algorithm performance by experiments. • Improve the Floyd Warshall algorithm and present the DFA. When vertices are added, only the changes caused by these vertices are calculated in DFA. Apply the DFA to address NFZ avoidance in the CPP problems.
• Compare the PSAACO algorithm with other algorithms and existing works.
The paper is structured as follows: Section 2 describes the related works; Section 3 presents the CPP problem model and provides details about the PSAACO algorithm and DFA; Section 4 presents the performance metrics and experiment results; and Section 5 concludes the paper.

Related Works
CPP is a critical issue for many UAV applications, and it has become also a research hotspot. According to whether the environment is known or not, CPP algorithms can be divided into two categories: online CPP and offline CPP [43]. Offline CPP algorithms only depend on static environmental information, assuming that all environmental information is known in advance. Online CPP algorithms don't need to know the complete information of the environment to be covered in advance, and plan local paths based on real-time sensor information.
According to the employed cellular decomposition technology, CPP algorithms can be divided into three main types: no decomposition, exact cellular decomposition and approximate cellular decomposition [42].
Using a single UAV to perform CPP tasks in a simple area with regular shape usually does not need cell decomposition. Back-and-forth(BF) and Spiral(SP) are two most common no decomposition CPP algorithms [42]. In the BF algorithm, the UAV starts from a certain point on the edge of the area and flies forward along a straight path in a specific direction. After reaching the edge of the area, the UAV flies back in the opposite direction along a parallel path, and the UAV flies back and forth until a path covering the entire area is generated. The specific process of the SP algorithm is as follows: The UAV moves clockwise or counterclockwise along the edge of the unvisited part of the area. If it encounters an obstacle, the UAV rotates clockwise or counterclockwise for a certain angle and then continues to move forward, and so on and so forth until the UAV completes covering the entire area.
Exact cellular decomposition divides the irregularlyshaped complex region into regular-shaped simple cells, and then the path planning is performed on the cells. The classical exact cellular decomposition methods include Trapezoidal Decomposition and Boustrophedon Decomposition [43]. Trapezoid Decomposition is applied on 2D polygonal areas consisting of polygonal boundaries and polygonal obstacles. Starting at each vertex of the boundary and obstacles, draw upper line segment and lower line segment in the non-obstacle part of the area. These line segments decompose the non-obstacle part into simple trapezoidal cells, and then plan paths on these trapezoidal cells. Boustrophedon Decomposition method is similar to the Trapezoid Decomposition, but the two endpoints of the line segment dividing the area need to be located on the boundary of the area. Boustrophedon Decomposition decomposes an area into simple convex polygons, which can be covered by a simple back-and-forth run. Compared with the trapezoidal method, the Boustrophedon Decomposition can reduce the number of cells, thereby shortening the total length of the coverage path.
Approximate cellular decomposition, also known as gridbased decomposition, decomposes an area of interest into regularly-shaped grids. These grids are usually square, but they can be triangular or hexagonal. Each grid is marked with a value to indicate whether there are obstacles in it. Grid-based decomposition tries to find out the optimal path to traverse these grids and avoid obstacles. Grid-based decomposition methods are easy to create, simple and intuitive to use, and are widely used methods at present.
Authors in [44] propose an cost-efficient multirobot CPP algorithm. This method consists of two parts. The first part divides the area of interest into sub-areas. The second part applies a single UAV on each sub-area, and uses an algorithm based on the wave-front planner to plan path for the sub-area. The algorithm creates an adjacency graph of the grids, and then applies a breadth-first search (BFS) on the graph to perform the distance transformation. The path planned by the algorithm takes the starting cell as the basic cell, selects the cell with the smallest gradient rise in the neighborhood of the basic cell as the next point of the path. Take this new path point as the basic cell, and repeat the above process to find the subsequent points for the path until the path covers the entire area.
Authors in [45] propose a method to plan coverage paths on irregular-shaped areas for image mosaicing. The algorithm uses a cost function designed to minimize the number of turns. This method consists of two parts. In the first part, the area is decomposed into regular-shaped grids, then this decomposed area is converted to a regular graph. The second part adopts a method similar to that in literature [44], applies the BFS on the grids to perform the distance transformation, then sequentially selects the cells with the smallest gradient rise in the neighborhood to form a coverage path. Deep-limited search is applied to ensure that the method can obtain a path that traverses all nodes and each node is traversed only once. A backtracking procedure is also used to solve the problems of same potential weight neighbor selection and trapping in local optima.
Cabreira et al. [39] introduce an energy-aware grid-based method. The approach is designed to minimize energy consumption of mapping tasks on the areas with irregular shapes. The method improves the grid-based approach proposed by [45], and proposes a new cost function to replace the original one in [45], which aims to minimize the number of turns. The new energy cost function takes into account not only the energy required for the UAV to turn, but also the energy consumed by the UAV when accelerating, decelerating and flying at a constant speed. The new approach is able to lower energy consumption in real flight experiments.
Ghaddar et al. [46] introduce an obstacle avoidance approach based on energy-aware grids. The method can be divided into two stages. The first stage is to plan one coverage path offline on the area of interest based on the top view girds. The second stage is an online obstacle avoidance process based on the information captured by the camera. If an obstacle is captured , the proposed method re-plans the path to avoid the obstacle. This literature presents the experimental results on two scenarios, showing that the proposed method can shorten the flight time and reduce the energy consumption.
In another paper [40], Ghaddar et al. propose an energy-aware CPP algorithm using grid-based technique to cover areas where NFZs exist. The algorithm includes three main stages. The first stage is to divide the area of interest into grids and graphically represent the NFZs. The second stage is to partition the area into sub areas around the NFZs. And the third stage is to plan one path on each sub area. To increase the percentage of covered area, the proposed algorithm selects the partition borders on the boundaries of cells. This approach applies filtering method to get rid of edges and nodes that are negligible for the coverage task. And this method uses a new cost function to build better turning points selection mechanism. The proposed approach is suitable for scenarios using single and multiple UAVs.

Materials and Methods
In this paper, our goal is to plan a coverage path over an area of interest where NFZs exist. The requirements to fulfill for the CPP are: • Complete coverage of the area of interest; • Ensure minimum completion time, by lowering the turning angle and the length of the planned path. • Avoid passing over the interior of NFZs, but the boundary lines of NFZs are passable; We use one UAV in offline mode to cover an area where NFZs exist. We build the CPP problem model using grid-based technique. We propose the PSAACO to make path planning on this problem model. Furthermore, to avoid the NFZs, we propose a DFA, which can dynamically add points and only need to calculate the changes caused by these points without recalculating the entire algorithm.

Problem Model
We consider planning a path for an area of size approximately 100m × 80m, the area is shown in Fig. 1a. In the figure, the grey polygon represents the area that needs to be covered and searched, while the red polygons represent the NFZs. Similarly to [40], this work uses the grid-based technique to model the investigated area. We map the geographical area to grid cells, and the mapped image is shown in Fig. 1b. The longest side of the area is aligned parallel to the X-axis or Y-axis of the mapped image by means of coordinate transformation. Each grid cell has rectangular shape, and its size is determined by the UAV footprint, what it means is the area the UAV can cover at one time [47]. In Fig. 1b, each grid cell is 20 meters long and 20 meters wide. Grid cells filled entirely or partially with grey represent areas that need to be covered, and grid cells filled with red represent NFZs, while the unfilled cells mean areas that do not need to be covered or are not prohibited to fly over. In Fig. 1c, we label the key points of the mapped image. The key points are divided into two categories, named as A-Type points and N-Type points, respectively. A-Type points are the center points of the grid cells that need to be covered and searched, marked with orange circular labels in the figure. N-Type points are the vertices of NFZ polygons, and marked with red circular labels. The key points in each row are numbered from left to right (x increasing direction), and the rows are numbered incrementally from top to bottom (y increasing direction). The text in each label consists of its type name and sequentially number.
In this work, a key point is represented as a vector V(te, sn, x, y) , where coord(x, y) is the coordinate, te is the type of the point, sn is the sequentially number. For example, in Fig. 1c, point V A10 can be represented by a vector V ("A ′′ , 10, 70, 50) , while point V N 7 can be represented by a vector V ("N ′′ , 7, 20, 60).
NFZs are described by rectangles, eg rectangle NR(V N 0 , V N 1 , V N 5 , V N 4 ) is an instance of NFZ. If some NFZ rectangles have common edges, try to combine them into a larger rectangle, eg rectangle NR(V N 6 , V N 7 , V N 10 , V N 9 ) and rectangle NR(V N 7 , V N 8 , V N 11 , V N 10 ) can be combined into rectangle NR(V N 6 , V N 8 , V N 11 , V N 9 ) . After the NFZs are combined, we can remove those redundant N-Type vertices that are not used to form the NFZ rectangles. Figure 1d shows the area image after removing the redundant vertices. Figure 1e shows an example of CPP, the back-and-forth is applied on the area. The blue polyline represents the planned path, which starts at point V A4 and ends at V A14 . In this paper, one path is described by one sequence of points it passes through, and the planned path without considering NFZ avoidance is as follows.
In this work, we detect whether all line segments in the path intersect the diagonal of the rectangle. If there is a line segment that intersects the diagonal of the NFZ rectangle, it is considered that the line segment has passed the NFZ, and NFZ avoidance processing is required. Use a set named NFZS to record the diagonals of all NFZ rectangles. In Fig. 1e, the diagonals in NFZS are represented by red line segments, and NFZS is as follows.
As a special case, the line segment LS(V N 7 , V N 8 ) is the common edge of two NFZs, which is considered to be the interior of the area. If there is an intersection between the (1) path P i and LS(V N 7 , V N 8 ) , NFZ avoidance is also required. The common edge LS(V N 7 , V N 8 ) is also recorded in NFZS, and the complete NFZS of the Fig. 1e is as follows.
As can be seen from Fig. 1e, the line segment LS(V A7 , V A8 ) of the path intersects LS(V N 0 , V N 5 ) in the NFZS , which means that the planned path P i passes through the NFZ, but this is not allowed.
In this paper, we use N-Type points to avoid NFZs. Two N-Type points, V N 0 and V N 1 , are inserted into the line segment LS(V A7 , V A8 ) . The update path P j successfully avoids the NFZ, the vector of P j is as follows, and it is illustrated in Fig. 1f.
In short, the CPP problem in this paper can be regarded as an optimization problem. The problem is described as follows: plan a path passing through all A-Type points, require each A-Type point to be traversed only once, use N-Type points to avoid the NFZs, and require the shortest time for a UAV to cover the path. The mathematical model of the CPP problem can be described by Eq. 5.
Where f is a function to calculate the completion time for a planned path. τ is the minimum completion time of all paths. P i is a planning path, as in Eq. 4. ν is UAV speed, and ψ is UAV rotation rate. G means area after decomposition, which is composed of several sets. VAS is the set of A-Type points, containing all A-Type points in the area, while VNS is the set of N-Type points. NFZS defines a set of line segments to determine whether NFZ avoidance is required, which consists of the diagonals of the NFZ rectangles and the common edge of two NFZ rectangles.
The mathematical model of the CPP problem subject to: Constraint formula 7 represents any point in the planned path P i , which must also exist in the set of A-Type points or N-Type points. Constraint formula 8 indicates that P i contains all A-Type points. Constraint formula 9 shows that each point in P i can only appear once, and no two identical points exist in the same path. Constraint formula 10 states that the line segment LS x in P i does not intersect with the line segment LS y in NFZS, that is, the path P i does not pass through the NFZs. Table 1 defines the notation of relevant sets, vectors, parameters and variables of our work.

PSAACO Algorithm for CPP
Ant colony algorithm(ACO) is a bionic optimization algorithm, which simulates the behavior of ant colony foraging in nature, and uses probabilistic search technology to find the optimal path. This technique is first introduced by Dorigo and his colleagues [48], and then many scholars have continuously enriched and improved it, forming an algorithm family. The well-known algorithms in the algorithm family include: Elitist Ant System (EAS) [49], Rank Based Ant System(ASRank) [50], MAX-MIN Ant System (MMAS) [51], Ant Colony System(ACS) [52], etc. ACO is used for many applications especially complex combinatorial optimization problems such as vehicle routing problem (VRP) [53], job-shop scheduling problem (JSP) [54], traveling salesman problem (TSP) [55], quadratic assignment problem (QAP) [56], and so on.
In this paper, we extend the ACO algorithm presented in our previous work [57], and propose a new PSAACO to deal with CPP problem. This new PSAACO algorithm is mainly expanded as follows: make some modifications to solve CPP problems, modify the self-adaptive strategy to construct and apply a new parameter vector at each iteration, apply the inversion and insertion operators to construct new solutions, use a multi-threaded parallel computing approach to improve the solution quality and search speed.
The pseudocode of the PSAACO is presented in Algorithm 1. As seen in the algorithm, procedure Initial-izeGlobalParameters() is used to initialize the global parameters G, ψ , ν , TdNum, Itmax,Itmax2, Cmax, Cmin, a, n and q, whose meanings are provided in the algorithm. The G is an instance of CPP model, as represented by Eq. 6. The CPP model instance contains three sets: A-Type points set VAS, N-Type points set VNS and line segments set NFZS. The following subsections elaborate on the other procedures in the algorithm.

Calculate the Sub-path Matrix after Avoiding NFZs
The pseudocode used for calculate the sub-path matrix is in Algorithm 2. As seen in the Algorithm 2, in steps 6 to 16, it is checked whether the line segment composed of any two points in VAS has an intersection with the line segment defined by NFZS. If there is no intersection, the corresponding element value in the sub-path matrix is assigned to the sub-path composed of these two points. If there is an intersection, it means that the line segment passes through the NFZs, then start the NFZ avoidance algorithm to obtain the sub-path and assign the obtained sub-path to the element in the subpath matrix. The procedure GetSubpathByFloyd in step 18 will be described in later subsection. For example, in the CPP model instance shown in Fig. 1, the line segment consisting of V A6 and V A7 has no intersection with any line segment in NFZS, so the value of PM [6] after NFZ avoidance processing.

The Procedures for Solution
As seen in the Algorithm 1, the main processing flow for the solution archive in the PSAACO algorithm is indicated below: • The first process applies the "InitializeSolution-Archive" procedure in step 10 to initialize the solution archive, and uses "UpdateSolutionArchive" procedure in step 11 to update the archive. • The second process corresponds to steps 21 to 23 in the algorithm. Each ant selects a base solution from the solution archive, constructs one new solution from the base solution by "ConstructSolution" procedure, and then adds the new solution into the solution archive. • The third process uses the "UpdateSolutionArchive" procedure to sort the solutions in the solution archive by their quality, then keep the best n solutions in the solution archive and remove redundant solutions. • Repeat the second and third process before a termination condition is satisfied.
The structure of solution archive The structure of solution archive S of PSAACO algorithm is shown in Fig. 2.
The solution archive stores n solutions. Each solution s j is represented by an m-dimensional vector, as shown in the following formulas: f (s j ) and ω j means the fitness value and selection weight of solution s j ,respectively.
For the CPP problem, each solution of PSAACO corresponds to a planned path without NFZ avoidance, and each variable in the solution corresponds to the sn of one point in the path. For example, the solution s i corresponding to the path P i described in Eq. 1 is as follows: Initializing solution archive The pseudocode used for generating the initial solutions for the solution archive is presented in Algorithm 3. As seen in the algorithm, each solution was randomly generated as a permutation of the set of the points in VSA. Then, each solution is converted to a path using the "getPathFromSolution" procedure in step 4. The fitness value of the path is calculated in step 5, and the new solution is added into the solution archive in step 6. 5,6,7,8,11,10,9,12,13,14) The pseudocode of the "getPathFromSolution" procedure is shown in Algorithm 4. Take out two adjacent points of the solution solu in turn, query their corresponding sub-paths from PM, and combine these subpaths into a complete path P. Since the sub-paths in PM are NFZs-avoiding, the new path is also NFZs-avoiding.
Constructing new solutions probabilistically First, each ant applies the roulette wheel selection algorithm, probabilistically selecting a solution from the solution archive S. As shown in the following equation, the selection probability PS j of the solution s j is calculated according to its selection weight ω j . Where ω j can be calculated by Eq. 14. In the equation, η represents the search size constant, and n is the number of solutions in S.
Then, a new solution is built based on the selected solution. Similarly to [58], this work uses the local search operators to construct a solution. The pseudocode to construct a new solution is shown in Algorithm 5. We use the inversion and insertion operators, which are among the most popular local search operators. The algorithm chooses to use the inversion operator with a probability of 50%, as shown in steps 6 and 7. And the insertion operator is selected with a probability of 25% in steps 8 and 9. In steps 10 to 22, we apply the inversion operator multiple times in a continuous loop, and take the best constructed solution as the new solution. The local search operators can be described as follows: • The inversion operator: The inversion operator simply inverses the variables of the solution between positions x and y. In other words, it randomly selects two positions on the solution and then reverses the sub-path between these two positions. For example, inversion(s i , x, y ) generates a new solution s j , which is , · · · , s n i ) , where 1 ≤ x < y ≤ n.
Updating the solution archive The "InitializeSolution-Archive" and "ConstructSolution" procedures add some new solutions into the solution archive S. The "UpdateS-olutionArchive" procedure performs the update S operation. First, the solutions in S containing new solutions are sorted according to their fitness function value, and the solutions with good quality are ranked above the solutions with poor quality. Then, the top n solutions with the best quality in S are retained, and other redundant solutions are removed.

The Procedures for Self-Adptive Parameters
Some parameters greatly affect the performance of PSAACO. The scheme of manually setting parameters depends too much on the experience of setting personnel. This paper adopts a self-adaptive parameters setting scheme for PSAACO. The self-adaptive parameter archive C is added to store these self-adaptive parameters. Assume that there are a parameter setting schemes, and each scheme is a vector composed of b self-adaptive parameters, the corresponding parameter archive is shown in Fig. 3. c i j is the i-th parameter value in the j-th parameter vector. f (c j ) is the fitness value of the c j . ω j means the weight of c j .
In the algorithm 1, the main processing flow for the self-adaptive parameters in the PSAACO algorithm is indicated below: • The first process applies the "InitializelParameter-Archive" procedure in step 7 to initialize the parameter archive. Randomly create a parameter vectors and store them into the parameter archive. • The second process corresponds to steps 15 to 29 in the algorithm. Each iteration selects a base parameter vector from the archive, constructs a new parameter vector from the base parameter vector by "Con-structParameter" procedure. Take this new parameter vector as the current parameter vector for this iterative calculation. Record the fitness value of the best solution constructed by ants in this iteration, and take this value as the fitness value of the new parameter vector. Add the new parameter vector and its fitness value into the parameter archive.
• The third process uses the "UpdateParameterArchive" procedure to sort the parameter vectors in C by their quality, then keep the best a parameter vectors in C and remove redundant parameter vectors. • Repeat the second and third process before a termination condition is satisfied.
The procedures for parameter archive are very similar to that for solution archive, and they have almost the same operations in initializing archive, selecting base vector from archive, updating archive, etc.
There is a big different procedure for parameter archive, and that is constructing a new parameter. Each variable in the base parameter vector probabilistically selects new value in its neighborhood, and these new values form a new parameter vector. The probability density function Pd(x) for each variable is as follows: and f (x, µ, σ ) is the Gaussian function, x is a variable in one parameter vector. σ denotes the mean square error , µ is the mean value , and ξ means the algorithm parameter.

Parallel Computing with Multiple Threads
Parallel computing can enhance the algorithm speed, and it introduces parallel computing elements to expand the search mode, which can often improve the quality of algorithm results [59]. In this work, we use a multithreaded parallel computing approach to improve the solution quality and search speed of PSAACO.
Step 6 of Algorithm 1 starts TdNum parallel threads, and steps 7 to 45 in Algorithm 1 are the running steps of each thread. Each thread runs an independent ACO algorithm, and it has its own solution archives, parameter archives and global parameters, etc. These threads have independent ant colonies to explore new solutions. And they independently update their own solution archives and parameter archives. After all threads run, take the best solution obtained by all threads as the result of the whole algorithm. The application of parallel computing speeds up the run of the algorithm, reduces the probability of PSAACO falling into a local optimum, and improves the overall performance of PSAACO. The relevant proof experiments are described in the later experimental part.

The Fitness Value
The most common performance metrics are: path length, number of turning maneuvers, completion time, energy consumption, and quality of area coverage. Path length and turning angle are the two main basic factors, and most common performance metrics usually rely on one of these factors or a combination of two factors. The completion time and energy consumption metrics include the evaluation of these two factors, so these two metrics are more comprehensive and reasonable. In this paper, the completion time is used as the fitness function value.

NFZ Avoidance Using DFA
The Floyd Warshall algorithm is used to search for the shortest path between any two points, and can handle the shortest path problem of undirected graphs or weighted directed graphs [60,61]. The idea of the algorithm is to insert different intermediate vertices between two points and find out the insertion scheme of the shortest path. Let d x ij be the shortest path from vertex i to vertex j , and its intermediate vertex is in the set 1, 2... y, where x is the iteration number and y is the total number of all vertices. Then for y > 1, Thus, d y ij is the shortest paths matrix calculated by the Floyd Warshall algorithm from the input graph. The Floyd Warshall algorithm cannot dynamically add points. When a new vertex is added into the graph, all shortest path needs to be recalculated, and the time complexity is O(n 3 ).
This paper improves the algorithm so that when vertices are added, only the changes caused by these vertices are calculated, and the algorithm are named DFA.
The DFA is presented in Algorithm 6. The algorithm has three input parameters. DistanceM1 represents the distance matrix that has been calculated so far, and DistanceM1[i][j] records the shortest distance from vertex i to vertex j. PathM1 indicates the path matrix that (17)  We apply the DFA to deal with NFZ avoidance. Assume we get a CPP model G and a sub-path P k = (V Ai , V Aj ) , then the main process for P k to avoid NFZs is as follows: • The first process is to calculate all N-Type points in G using DFA, and store the result in the distance matrix DistanceM1 and the path matrix PathM1. We take the CPP model shown in Fig. 1 as an example, The DistanceM1 is shown in Table 2. The data in the table represents the shortest distance between two N-Types points. In particular, ∞ indicates that there is no feasible path between two points. Table 3 describes the data of PathM1. From the table we can see that the shortest path from V N 1 to V N 10 is: (V N 1 , V N 5 , V N 10 ) , since 5 is the intermediate vertex between V N 1 to V N 10 . • The second process is to calculate the distance between the starting vertex V Ai and all N-Type points to obtain the distance array of DistanceA1. For example, the DistanceA1 for vertex V A7 in Fig. 1 is (14.1, ∞, · · · , ∞, 51.0). • The third process is to take DistanceA1, DistanceM1 and PathM1 as input parameters, apply the DFA to calculate and update the distance matrix DistanceM1 and the path matrix PathM1. • Repeat process 2 and process 3 to calculate the end vertex V Aj . And we can get the NFZ avoidance path from final path matrix PathM1. In the example, the final DistanceM1 is shown in Table 4 and the final PathM1 is shown in Table 5. It can be seen from the tables that the NFZ avoidance path of

Experiment Results and Discussions
In this section, we present experimental results and discussions of our work. In the following, two metrics for evaluating performance are introduced first. Next the performance improvement using self-adaptive parameters and parallel computing is presented. Finally the performance comparison with other algorithms and existing works is carried out.

Experimental Environment
The computer used for the experiments is Lenovo Xiaoxin Pro16 2021: AMD Ryzen 7-5800H CPU (8cores) , 16 GB memory, 1 TB SSD. The integrated development environment of the experiments is Visual Studio 2019 on Windows 11, and the experimental projects are programmed using C#.

Performance Metrics
Performance metrics, completion time and energy consumption are used to evaluate the experimental results. Their definitions are as follows.
Completion Time [62] is the total time required to complete the planned path. It can be calculated: Where β is total distance of a path, ϕ denotes total turning angles of a path, ψ is UAV rotation rate, and ν is UAV speed.  Table 3 Path matrix for N-Type points Page 13 of 28 Gong et al. Journal of Cloud Computing (2022) 11:29 Energy consumption [40] is the total energy consumption required to complete the planned path. It can be calculated: Where is the energy consumption required by the UAV to complete each 1m path length, and γ is the energy consumption required to complete each 1 degree turning angle. In this work, we use the same values as in [40], and   Table 5 Path matrix after NFZ avoidance · · · 5 10 1 12 Fig. 4 The CPP model2. [63] Page 14 of 28 Gong et al. Journal of Cloud Computing (2022) 11:29 set the values of and γ to 0.1164 KJ/m and 0.0173 KJ/ degree, respectively.

Performance Improvement using Self-Adaptive Parameters
Some experiments are carried out to test the performance improvement using self-adaptive parameters. Two CPP models are used in these experiments. One CPP model is depicted in Fig. 1, named CPP model1, which has a relatively small area. The other CPP model is from Reference [63] , which has a relatively large area and a complex no-fly zone. We make some modifications, and the adjusted model is named CPP model2, as shown in Fig. 4. Table 6 lists the parameter setting scheme and performance of five experiments. In the four experiments from ACO1 to ACO4, we manually set the values of the three self-adaptive parameters n, q and η for the ACO  algorithm, and the three parameters represent the solution number in solution archive, the ant number for each thread and the search size in archive area, respectively. The fifth experiment shows the experimental result of the PSAACO algorithm. In Table 6, the columns titled "CPP model1" and "CPP model2" show the experimental results of running PSAACO algorithm 10 times on CPP model1 and CPP model2, respectively. The sub column titled "Best" shows the completion time corresponding to the best solution of 10 runs, the sub column titled "Mean" shows the mean completion time, and the sub column titled "Worst" indicates the worst completion time. It can be seen from Table 6: • When planning the path on CPP model1, most experiments can obtain excellent solutions. This means that parameter settings are less important for small, simple areas. For the large and complex CPP model2, the performance of the third to fifth experiments is significantly better than the other experiments. This means that parameter settings are very important for this model. • The performance of ACO algorithm largely depends on parameter settings, especially when dealing with some complex models. While PSAACO shows excellent comprehensive performance, even when dealing with complex models. In conclusion, self-adaptive parameter setting can improve the performance of ACO algorithm to solve the CPP problem, and the performance improvement is more obvious when the areas are large or the no-fly zones are complex.

Performance Improvement using Parallel Computing
To test the performance improvement using parallel computing, we conduct some experiments on two CPP models. One CPP model is CPP model2. The other is a modified model based on the model in ref. [43] , which is illustrated in Fig. 5. Four experiments are done and each experiment runs 10 times. The number of parallel threads for these four experiments is set to 1, 5, 10, and 20, respectively. All experiments adopt self-adaptive parameter setting scheme. Table 7 shows the experimental results. It can be seen from Table 7: • The performance of PSAACO algorithm is improved as the number of threads increases. As shown in the Table 7, experiments with a large number of threads achieve better mean completion time metrics. • When the number of threads increases to a certain value, such as more than 10, continuing to increase the number of threads has little effect on performance improvement.
In short, parallel computing can improve the performance of PSAACO algorithm. And a small number of parallel threads can be selected for simple problems, while a larger number of threads, such as 10 or 20, can be selected for complex problems.

Performance Comparison between PSAACO and Other Algorithms
The BF and SP are the most common pattern for a single UAV to explore regular-shaped and non-complex areas   [42]. The wavefront algorithm(WF) is a popular coverage path planning approach suitable for irregular-shaped areas [63]. In this work, we modify these three algorithms to solve the CPP problem as described in Eq. 5.
The main process of this modified BF algorithm is as follows: • Find the points on the four corners in VSA, for example, the four points in Fig. 1 are V A0 , V A4 , V A14 , V A12 ,respectively. • Take each point as the starting point and go back and forth along the horizontal, vertical and diagonal directions to generate paths. For example, Fig. 1e depicts the generated path in the horizontal direction starting from V A4 . Each point can generate three paths, and four points can get a total of twelve paths. • These paths are processed by the DFA for NFZ avoidance, and the fitness values of these paths are calculated. The path with the smallest fitness value is taken as the result of the BF algorithm.
The modification to SP is similar to the modification to BF. First, find the four corner points in the VSA.
Next, take these points as starting points, and make a spiral motion in a clockwise or counterclockwise direction to generate paths. Then, these paths are processed for NFZ avoidance, and their fitness function values are calculated. Finally, the best path is taken as the result.
In the modified WF algorithm, we select each point in the VSA as the goal point, and use the wavefront method and NFZ avoidance to generate paths, then take the best path as the algorithm result.
We do some experiments to compare our algorithm with the three algorithms. CPP model1, CPP model2 and CPP model3 are used in these experiments. CPP model1 has a relatively small area and a simple NFZ, CPP model2 has a relatively large area and a complex NFZ, and CPP model3 has a larger area and a very complex NFZ. The three models cover scenarios of different area and NFZs of different complexity, which can comprehensively test and compare the performance of these algorithms.
Set the number of parallel threads to 20, make 10 path planning for each scenario, and select the optimal solution in the 10 path planning experiments as the final solution of the algorithm. Figure 6a-d represent the CPP on model1 done by BF,SP,WF and PSAACO, respectively. Figures 7 and 8 show the paths planned by the four algorithms on model2 and model3. As can be seen from these figures, PSAACO algorithm has shorter distance and fewer turns than other algorithms. Table 8 shows that PSAACO generate a shorter path on model1 than BF, SP and WF by 6.5%, 8.2% and 2.8% respectively, decreasing the turning angles by 21.4%, 9.7% and 31.3%, lowering the energy consumption by 10.0%, Table 9 Experiments for Performance Comparison between PSAACO and algorithm in [45] Ref. [ It can also be seen from the Table 8 that the path generated by PSAACO on model3 is 31.2%, 22.4% and 4.5% shorter than BF, SP and WF, respectively, and the rotation angle is reduced by 40.3%, 37.6% and 46.2%, the energy consumption is reduced by 32.5%, 24.8% and 13.1%, and the completion time is shortened by 33.7%, 26.9% and 19.9%, respectively.
In short, PSAACO has excellent comprehensive performance on CPP. Compared with BF, SP and WF, PSAACO has a great gain in the four indicators of total path length, total turning angle, energy consumption and completion time.

Performance Comparison with Existing Works
In this section, we consider comparing our work with different scenarios in existing works: • The work in [45], where the deep-limited search is applied to build coverage path. • An energy-aware grid based algorithm with obstacle avoidance, proposed in [46], • An grid-based coverage path planning over irregularshaped area, presented in [39].
The experimental settings are the same as the previous section, we set the number of parallel threads to 20, and choose the optimal solution in 10 runs as the final solution. For a fair comparison of different methods, we assume that the UAV flies with the same speed and rotation rate in the same scenario.

Scenario 1
In this scenario, our approach is compared with that of Valente et al. [45]. The area size of scenario 1 is approximately 327 m × 195 m. In [45], the distance transform function is used over the grid, the deep-limited search is applied to plan coverage paths, and the path with the smallest number of turns is selected. Figure 9a represents the CPP generated in the [45], Fig. 9b shows the CPP in our work, and Table 9 presents a comparison of the results of the two Fig. 11 Paths planned on area 2 by the algorithms in [39,46] and PSAACO Table 11 Experiments on area 2 for performance comparison between PSAACO and algorithm in [39,46] Ref. [39] Ref. [  approaches. Table 9 shows that the path length obtained by PSAACO is not much reduced compared with that obtained in Reference [45], but the turning angle is greatly reduced, and the angle of PSAACO is reduced by 28.6%. Benefiting from the smaller path length and turning angle, the energy consumption and completion time of PSAACO are improved by 6.0% and 8.5% respectively.

Scenario 2
In this scenario, our approach is compared with the energy-aware grid based solution for obstacle avoidance(EAOA) provided by Ghaddar et al. [46]. Two areas, named area 1 and area 2, in [46] are selected for comparison. In order to fit the CPP model in our work, we make minor adjustments to the paths of these two areas.
Area 1 Figure 10a illustrates the CPP on area 1 generated by EAOA in [46] , and Fig. 10b shows the CPP obtained by PSAACO algorithm.
As can be seen from Table 10, the path length and turning angle of the PSAACO algorithm are greatly improved,  Area 2 Figure 11a shows the CPP on area 2 generated by E-F method in [39], Fig. 11b shows the CPP generated by EAOA in [46], and the CPP obtained in our work is illustrated in Fig. 11c.
As can be seen from Table 11, the PSAACO algorithm produces a shorter path length and smaller turning angle. Compared with E-F and EAOA, the path length of PSAACO is reduced by 4.6% and 2.0%, and the turning angle is reduced by 33.3% and 13.9%, respectively. Benefiting from the smaller path length and turning angle, the energy consumption of PSAACO is decreased by 14.2% and 5.4%, and the completion time is reduced by 10.9% and 4.1%, respectively.

Scenario 3
In this scenario, our approach is compared with the algorithm proposed in Cabreira et al. [39]. Four areas, named area 1, area 2, area 3 and area 4, in [39] are selected for comparison. Authors in [39] propose two methods: O-F and E-F, which calculate the path with the lowest turning angle and the path with the least energy consumption respectively. For the convenience of comparison, we modified some parameters, such as the size of some areas, the speed of UAV, etc. But we maintain the same path planning scheme, keeping the number and order of points in the path unchanged.
Area 1 For area 1, the path planned by O-F method is illustrated in Fig. 12a, the path obtained by E-F method is shown in 12b, and the path generated by PSAACO algorithm is presented in 12c.
It can be seen from the Table 12 that the PSAACO algorithm greatly reduces the path length and turning angle. Compared with O-F and E-F methods, the path length of PSAACO is reduced by 10.3% and  8.6%, and the turning angle is reduced by 36.6% and 39.5%, respectively. Correspondingly, the energy consumption and completion time of PSAACO have also been greatly improved. The energy consumption of PSAACO is decreased by 20.4% and 21.0%, and the completion time is reduced by 25.6% and 27.1%, respectively.
Area 2 For area 2, the path planned by O-F method is illustrated in Fig. 13a, the path obtained by E-F method is shown in 13b, and the path generated by PSAACO algorithm is presented in 13c.
It can be seen from the Table 13 that the PSAACO algorithm greatly reduces the path length and turning angle. Compared with O-F and E-F methods, the path length of PSAACO is reduced by 11.2% and 6.3%, and the turning angle is reduced by 28.2% and 25.2%, respectively. Correspondingly, the energy consumption and completion time of PSAACO have also been greatly improved. The energy consumption of PSAACO is decreased by 17.0% and 12.8%, and the completion time is reduced by 20.3% and 16.5%, respectively. Area 3 For area 3, the path planned by O-F method is illustrated in Fig. 14a, the path obtained by E-F method is shown in 14b, and the path generated by PSAACO algorithm is presented in 14c.
As can be seen from Table 14, the path length of PSAACO is 4.3% shorter than the path length in [39] using O-F, but 4.2% longer than the path length using E-F. The PSAACO algorithm greatly reduces the turning angle. Compared with O-F and E-F methods, the turning angle of PSAACO is reduced by 40.0% and 41.2%, respectively. Correspondingly, the energy consumption and completion time of PSAACO have also been greatly improved. The energy consumption of PSAACO is decreased by 17.7% and 14.0%, and the completion time is reduced by 24.8% and 23.0%, respectively. Area 4 For area 4, the path planned by O-F method is illustrated in Fig. 15a, the path obtained by E-F method is shown in 15b, and the path generated by PSAACO algorithm is presented in 15c.
As can be seen from Table 15, the PSAACO algorithm slightly reduces the path length, and the path length of PSAACO is reduced by 3.4% on O-F method and 0.6% on E-F method. The PSAACO algorithm greatly decreases the turning angle, the turning angle of PSAACO is reduced by 37.8% on O-F method and by 37.8% on E-F method. Correspondingly, the energy consumption and completion time of PSAACO have also been greatly improved. The energy consumption of PSAACO is decreased by 15.1% on O-F method and 13.5% on E-F method, and the completion time is reduced by 21.8% on O-F method and 20.8% on E-F method, respectively.

Performance Verification using Gazebo Simulation
In order to verify the feasibility of the proposed algorithm in the real scenarios, some simulation experiments are carried out using a small quadrotor UAV in gazebo. The UAV is equipped with a Pixhawk flight controller running PX4. The ground control station adopts QGroundControl which provides full flight control and mission planning. The communication between the UAV and the ground control station adopts MAVLink protocol.
The simulation experiments use a real scenario with a rectangular area of 300 m × 180 m. There are two tall buildings in this scenario, which are set as NFZs. The scenario is named CPP model4, as shown in Fig. 16a. The area is decomposed into grids,   11:29 and the A-type points, N-type points and NFZ are labeled. The decomposed and labeled area is shown in Fig. 16b. Figure 17a-d illustrate the paths planned by BF,SP,WF and PSAACO on CPP model4, respectively. Figure 18a-d show the flight trajectories simulated with gazebo, corresponding to the paths planned by these four algorithms. Table 16 presents the simulation experiment results of these four algorithms. It can be seen from the figures and table: • The flight trajectories of the UAV and the planned paths almost coincide, indicating that the path planned by the proposed algorithm is feasible for real flight. • Compared with the other three algorithms, the PSAACO algorithm uses a shorter completion time, which proves that the PSAACO has better performance. • The difference between the planned completion time and the simulated completion time is very small, ranging from 24 and 28.36 seconds, and the percentage of the difference is between 5.4% and 6.9%. It shows that the values of the main performance metrics used in this paper are almost consistent with the real values, and have high applicability.

Conclusion
In this paper, we propose the PSAACO algorithm to plan paths for areas of interest. The algorithm is improved by applying grid-mapping of the area, inversion and insertion operators, self-adaptive parameters, and parallel computing. Two metrics, completion time and energy consumption, are used to compare and evaluate the performance of PSAACO algorithm. The performance improvement experiments show that selfadaptive parameter setting and parallel computing can improve the performance of PSAACO algorithm, and the improvement is greater when the areas are large or the no-fly zones are complex. In the performance comparison experiments with other algorithms and existing works, PSAACO has excellent comprehensive performance on CPP, and has a great gain in the four indicators of total path length, total turning angle, energy consumption and completion time. The DFA is also proposed to deal with the NFZs in the areas. The DFA can dynamically add vertices and only calculate the changes caused by these vertices. However, the approach proposed in this paper also has some limitations, such as the use of parallel computing requires high-performance computing equipment; the algorithm runs slowly when the areas of interest are large. In the future works, we aim to speed up the algorithm, and evaluate the work when the areas are larger or the nofly zones are more complex.