# An Optimized Load Balancing Using Firefly Algorithm in Flying Ad-Hoc Network
## 3 Proposed Network Model
### Solution of the Problem  
It should be noticed that the function defined in Equation (4) is more complex. As a result, the following equations may be used to breakdown the relationship in Equation (4)  
\[\sum_{s}^{S}r\leq\mathrm{Cn}-\mathrm{P} \tag{4}\]  
where \(\mathrm{P}=\mathrm{K}/\overline{\mathrm{Di}}\), \(\mathrm{K}\) is the constant value, and \(\overline{\mathrm{Di}}\) is the network's single-hop delay limit. The value of \(\mathrm{p}\) should be greater than zero, i.e., \(\mathrm{p}>0\). From Equations (2) and (4), we can formulate  
\[F_{2}=max\sum_{s}^{E}fn(r) \tag{5}\] \begin{table}
\begin{tabular}{p{142.3 pt} p{142.3 pt}} \hline \hline \multicolumn{1}{c}{**Symbol/Notation**} & **Description** \\ \hline \(\Sigma_{\mathrm{F}}\) & The notation depicts a limited set that contains all of the UAVs that are free to fly in the specified area. \\ \hline \(\mathrm{L_{i}}\) & Indicates a link linking a pair of UAVs. \\ \hline \(\mathrm{L}\) & Denotes the set [\(\forall\mathrm{I}\in\mathrm{L}\)]. \\ \hline \(\mathrm{U_{j}}\) and \(\mathrm{U_{i}}\) & If the distance between \(\mathrm{U_{j}}\) and \(\mathrm{U_{i}}\) is below the communication radius, \(\mathrm{j}\in\mathrm{Ne_{i}}\), where \(\mathrm{Ne_{i}}\) is a set of \(\mathrm{U_{i}}\)’s neighbors. \\ \hline S & A session initiated by a source UAV. \\ \hline E & A collection of all consecutive sessions. \\ \hline L(s) & A collection of links followed by session Us. \\ \hline S(I) = \(\mathrm{Us}\in\sum\mathrm{S}\mid\mathrm{L_{i}}\in\mathrm{L(s)}\)] & A collection of all sources that use link \(\mathrm{L_{i}}\). \\ \hline \(\mathrm{\sum D_{i}}<\theta\) & The entire delay along the path \(\mathrm{L(s)}<\mathrm{threshold}\) (\(\theta\)). \\ \hline Cn & Capacity of the node-link \\ \hline \(\mathrm{D_{n}}=\mathrm{P}/(\mathrm{Cn}-\sum\mathrm{S}*\mathrm{r})\) & This is expressed as a single-hop delay where \(\mathrm{P}\) is the length of the packet and \(\mathrm{r}\) is the rate of the source node. \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Mathematical Notations. Here, Equation (6) is subject to  
\[\sum_{s}^{S}r\leq Cn-P \tag{6}\]  
\[\sum_{Li}^{Ls}\overline{Di}\leq\theta \tag{7}\]  
It is rather challenging to tackle the traffic congestion problem of flying nodes in the network with various settings in a centralized manner. To ease the optimization process, Equation (5) can be denoted as \(\chi\). As a result, the new form of \(F_{2}\) can be expressed as  
\[S=max\left(\sum_{s}^{S}r+\sum_{Li}^{Ls}\chi-\left(Cn-\left(P+\sum_{s}^{S}r \right)\right)\right) \tag{8}\]  
After reordering Equation (9), a new form can be obtained as  
\[S=max\left(\sum_{s}^{S}\left(r-r\sum_{Li}^{Ls}\chi\right)-\sum_{Li}^{Ls}(x*P)\right) \tag{9}\]  
Furthermore, we have two different equations from Equation (10), as follows  
\[S1=max\ \sum_{s}^{S}\left(r-r\sum_{Li}^{Ls}\chi\right)\]  
and  
\[S2=min\ \sum_{Li}^{Ls}(x*P) \tag{10}\]  
The Proposed Firefly Algorithm is defined as follows:  
Algorithm 1: (Proposed Firefly Algorithm) With the help of two properties, this approach is used to determine the direct path (shortest) in a network. The first is the firefly's brightness, which is proportionate to its mate selection and prey attractiveness. The other is that the difference between the couples (two) of fireflies is inversely proportional to the difference between them [20]. ```
Step 1: Begin by initializing the objective function. Step 2: Create a small population of fireflies (nodes). Step 3: Calculate the light intensity and the state absorption coefficient. Step 4: Repeat Steps 5-8 until the maximum generation value is reached (maximum iteration). Step 5: Repeat for I = 1 to N, where N represents all of the 'N' fireflies. Step 6: Repeat for J = 1 to I. Step 7: If J's light intensity is larger than I's light intensity, then set: change mate selection and prey attractiveness with their distance. Step 8: Reposition the firefly based on I's attraction to J and test different solutions.