| Algorithm 1. Localization and clustering |
| Input: S, Vij(t), Xij(t), W, C1, 2, R1, 2, N, K. |
| Output:Pij(t), Gj(t), Vij(t + 1), Xij(t + 1). |
| /* Initialization*/ //Generate the initial S, Vij(t), and Xij(t) of dimensions where each particle’s position and velocity are randomly generated in the searching space. 1: Initialize S, W, Vij(t) 2: for ∀ UAVs ∈ S (1≤ i ≤ N) do 3: Initial Xij(t) 4: end for |
| /* Leader-UAV*/ //Generate the target position and velocity in the searching space. 5: If the thermal signature (is true) then 6: UAV position send to update in blockchain 7: end if |
| /* Main loop*/ 8: while (Stopping criteria (false)) do 9: for each k do |
| /* Computation*/ //Calculate the suitable position for follower-UAV Xij(t + 1) by using current Xij(t) and Vij(t + 1) = {Pij(t), Gj(t)} based on Equations (1) and (5). 10:Calculate Vij(t + 1) using Equation (1) 11:if Vij(t + 1) > Vmax then 12:Set Vij(t + 1) = Vmax 13:end if 14:if Vij(t + 1) ≤ Vmax then 15:Set Vij(t + 1) = Vmin 16:end if |
| /* Blockchain*/ //Update the velocity and position of the current generation. 17:for ∀ UAVs ∈ S (1≤ i ≤ N) do 18:Update ∀ 10 sec the position Xij(t + 1) and Pij(t) 19:Conform receive all hash UAVs updated position 20:end for |
| /* Output*/ //Private best position Pij(t) for UAV, Global best position Gj(t) for swarm, next velocity Vij(t + 1), next position Xij(t + 1). 21:Calculate Pij(t), Gj(t), Vij(t + 1), Xij(t + 1). 22:the end for 23:end while |