# Dynamic UAV Inspection Boosted by Vehicle Collaboration Under Harsh Conditions in the IoT Realm
## 4 Algorithm
### Dynamic Task Processing Algorithm Based on the Speed Variation of UAVs and Vehicles
#### 4.2.2 KGTSA Algorithm  
In the dynamic scenario where the speeds of multiple UAVs and vehicles constantly fluctuate, the complete dynamic task handling algorithm primarily includes: constructing a global initial solution based on K-means clustering, HGA static optimization, and local dynamic optimization based on Tabu Search (TS). Therefore, the dynamic processing optimization algorithm based on UAV and vehicle speed variations is referred to as the KGTSA.  
The KGTSA integrates K-means clustering, HGA, and Tabu Search to achieve efficient task scheduling and path planning. First, K-means clustering is used for the initial task clustering and partitioning, efficiently assigning tasks to different vehicles and UAVs by grouping data points based on similarity. Next, HGA is applied for the static optimization of vehicle routes and UAV flight paths, ensuring the optimal and efficient solution through a combination of evolutionary processes and selection strategies. Finally, Tabu Search is employed for local dynamic optimization, iteratively exploring the solution space to avoid local optima, further improving overall performance.  
To address the joint optimization problem of vehicles and UAVs in a structured manner, it is divided into three steps: problem preprocessing, intra-cluster solution construction, and global solution construction. The construction of the global initial solution, HGA static optimization, and local dynamic optimization are all based on optimization adjustments from the first two steps.  
In the dynamic scenario where the speeds of multiple UAVs and vehicles constantly fluctuate, the complete dynamic task handling algorithm primarily includes constructing a global initial solution based on K-means clustering, HGA static optimization, and local dynamic optimization based on Tabu Search (TS). Therefore, the dynamic processing optimization algorithm based on UAV and vehicle speed variations is referred to as the KGTSA. A schematic diagram of the KGTSA is shown in Figure 4.  
The overall dynamic simulation process of the KGTSA is as follows: After the central console receives the initial static task, it uses Algorithms 1-5 to generate a static optimization solution, allowing multiple UAVs and vehicles to receive tasks and set off from the starting point. After departure, the speeds of the multiple UAVs and vehicles are in a constant state of random fluctuation, with certain range limits. After each short time interval \(\tau\), if the vehicle is on its way to the next anchor point, the driving distance of the vehicle for the time \(\tau\) is updated. Otherwise, this indicates that the vehicle is parked at the anchor point and that the UAVs are out performing tasks. In this case, the flight distance of each UAV for the time \(\tau\) is updated, and Algorithm 6 is used to generate the local dynamic optimization solution within the current anchor point, allowing all UAVs to continue performing tasks according to the new flight route. This process is repeated until all task points are visited, at which point, the algorithm is ended.