# A Low Complexity Persistent Reconnaissance Algorithm for FANET
## 3 Algorithm Description
### Ta&CRFO  
We now go into depth about our TA&CRFO algorithm in this subsection. Algorithm 2 presents the pseudo-code. In the preparatory phase (lines 1-2), which usually is the beginning of reconnaissance missions, the high-altitude UAV, known as ACP, constructs the initial FANET by Alg. 1 based on available information. Then, each low-altitude UAV flies to the position specified by the high-altitude UAV. When they arrive, we abstract the FANET into a graph and define it as a reference graph \(\theta_{ref}\) for a particular time.  
During the iterative stage (lines 3-16), the high-altitude UAV collects the position information of the scouted targets and evaluates the fluctuation of threat density distribution in the scenarios. Meanwhile, in time \(t\), the ACP calculates the TED \(\theta\left(\theta_{ref},\vartheta(t-1),P\right)\) between reference graph \(\theta_{ref}\) and the FANET graph at time step \(t-1\) in the current scenario. The \(\theta\left(\theta_{ref},\vartheta(t-1),P\right)\) value represents how much the FANET and threat PDF in the scenario have changed from the reference time. We assert that the cumulative changes are insignificant if the TED between them is below the threshold \(\lambda\). Therefore, by Equations (19) and (20), we have each low-altitude drone adaptively alter its position (lines 7-11).  
The right side of Equation (19) is the gradient of the total performance function concerning the position of node \(x_{i}\) at time \(t\). With neighbor UAVs' position information and the threat PDF of related areas, each node's gradient value can be easily obtained.  
On the other hand, if the TED is greater than \(\lambda\), we believe that the distributed position adjustment has lost its meaning since the routing path or scenario's threat PDF may have altered too much. Therefore, we use Algorithm 1 again to reconstruct the FANET network in a centralized way and set the newly configured network as the reference graph \(\theta_{ref}\).  
\[v_{i}(t)=\
abla_{x_{i}}f(t)=\
abla_{x_{i}}f\big{(}X_{V}(t),\{e_{m}\}_{m\in M}, \varphi(x(t)),r_{thr},\rho\big{)} \tag{19}\]  
\[x_{i}(t+1)=x_{i}(t)+v_{i}(t) \tag{20}\]  
In other words, at each time, the high-altitude UAV will decide whether to issue instructions to all low-altitude drones for overall control according to \(\theta\Big{(}\theta_{ref},\vartheta(t-1),P\Big{)}\). If low-altitude drones receive those instructions, they will obey them. Otherwise, they continue their adaptive location optimization method using local information.  
```
1 Construct the first FANET using Algorithm 1
2 Initialize the reference FANET as \(\vartheta_{ref}\)
3 For each time \(\boldsymbol{t}\)do
4 Obtain the \(X_{A}\), \(X_{M}\) at the current moment
5 Obtain the threat PDF \(\varphi\big{(}x\big{)}\) of the current simulation space
6 If \(\theta\big{(}\vartheta_{ref},\vartheta\big{(}t-1\big{)},\mathrm{P}\big{)}<\lambda\)then
7 For each particle \(\big{(}x_{i},v_{i}\big{)}\in\mathbb{N}\)do
8 Update \(\
u_{i}\) depending on (19)
9 Update \(x_{i}\) depending on (20)
10 \(\big{\{}\rho_{m}\big{\}}_{i}\leftarrow\rho\big{(}X_{A},X_{M},x_{i}\big{)}\)
11 End for
12 else
13 Update each particle \(\big{(}x_{i},v_{i}\big{)}\in\mathbb{N}\) by Algorithm 1
14 Reconfigure the reference FANET, \(\vartheta_{ref}=\vartheta\big{(}t\big{)}\)
15 End if
16 End for
```  
**Algorithm 2** Dynamic Threat Avoidance and Continuous Reconnaissance FANET Operation