## 3 Materials and Methods
### Working Mechanism of the Method  
One of the most commonly applied methods of 3D path planning is to provide a robot with a defined number of static stations and to allow an algorithm to discover the most appropriate path. These types of algorithms are easier to apply mathematically, but generally, their time and space complexity is relatively higher. Here, a pool of stations is assumed so that these stations can be created randomly. Since the station selection in our methods is based on metaheuristic algorithms, it works appropriately with fewer parameters, and therefore, it can work efficiently by consuming resources in an acceptable time. Mathematically, this pool has been described in the structure of the 3 xn matrix. The elements of search space represent distances between stations. Each station in the pool is a possible position that a mobile robot can choose as the next station. This pool is used to control the mobile robot's movement in the area. In addition, by using the information of this pool, it may be possible to help to avoid obstacles. The station selection process used in our methods is presented in Algorithm 1. In this study, the number and positions of stations (mobile robot stopovers) and obstacles are predefined similar to other studies in the literature [5; 6; 15; 20; 53]. On the other hand, obstacle avoidance is one of the many challenges that exist in the path planning problem. In this study, a method was used to avoid the collision of the UAVs with obstacles (objects or other robots), which benefits from geometric and calculus-based formulae. It was inspired by [47]. ```
1. State is array of candidate stations
2. w = distance obtained from metaheuristics //Equations (10) and (13)
3. d = The list of distances
4. For each station (i) in pool
5. di = distance between current and next stations + distance between next and destination stations
6. End For
7. MinDist = Min(d) //Min function indicates minimum distance in the list
8. if (MinDist < w)
9. Select station with minimum distance as next station
10. Else
11. Select station by metaheuristics as next station
12. End if
```  
**Algorithm 1**Pseudocode of station selection  
Primarily, the proposed methods initialize the random position matrix. Each row of the position matrix defines the path, and the columns represent the number of steps in the path to the destination. These number of stations are denoted as \(p\). The \((x_{n}^{m},y_{n}^{m},z_{n}^{m})\) presents a coordinate of each station, where m is the aforementioned index of stations and n is the number of search agents in each method (Figure 5a). The search agents are the configuration parameter of the metaheuristic algorithms. Then, for each metaheuristic algorithm, a search space, based on the position matrix, is initialized. The search space is shown in Figure 5b, which represents the distance between tuples. In this table, each row represents a path length. Each element of the row shows the distance between two points as \(d_{(i,j)}^{n}\), where i is the current state and j is the previous state. Furthermore, n is in the number of search agents. In addition, in the proposed methods, the path cost based on a fitness function that was presented in Equation (3) is calculated. In the next step, the proposed methods calculate the distance between each tuple for each station in the pool. In this case, we have a distance cost (_d_) between the current station and candidate next stations. The d includes two values: first is the distance between the current and next states, and the second is the distance between next and destination states. However, the metaheuristic algorithms find the best solution for the next station of each current station. If the distance of the possible next stations is smaller than the obtained value from metaheuristic algorithms (_w_), the relevant station with the minimum value is selected as the elected next station. Otherwise, the UAV chooses the achieved solution of the metaheuristic algorithms as the next station (Algorithm 1).