# An Adaptive Data Rate Algorithm for Power-Constrained End Devices in Long Range Networks
## 5 Adaptive Data Rate Algorithm Design
### Adaptive Data Rate Control Algorithm Based on Network Performance Optimization
#### 5.2.1 Zebra Optimization Algorithm  
The Zebra Optimization Algorithm (ZOA) is a metaheuristic algorithm that solves optimization problems by simulating the foraging and defensive behaviors of zebras, searching for the global optimal solution from an initial solution [38,39]. Zebras rely on keen perception and swift running while foraging and evading predators. The algorithm includes foraging behavior and defensive behavior, and the basic steps are as follows:  
Step 1: Initialization phase. An initial population of zebras (candidate solutions) is generated within the search space, where each zebra represents a potential solution. Step 2: Foraging phase. The positions of the population are updated through foraging behavior. In this phase, the best member of the population (the lead zebra) guides the other members toward its position. The position update is represented by Equations (42) and (43). \[x_{i,j}^{\text{new},P1}=x_{i,j}+r\cdot\left(PZ_{j}-I\cdot x_{i,j}\right) \tag{42}\]  
\[X_{i}= \begin{cases}X_{i}^{\text{new},P1}&\text{if}\quad F_{i}^{\text{new}}<F_{ i}\\ X_{i}&\text{else}\end{cases}  \tag{43}\]  
Equation (42), \(x_{i,j}^{\text{new},P1}\) represents the new position of the \(i\)-th zebra in the \(j\)-th dimension, and \(x_{i,j}\) represents the current position of the \(i\)-th zebra in the \(j\)-th dimension. \(r\) is a random number within the range \([0,1]\), introducing randomness. \(PZ_{j}\) represents the position of the lead zebra (current optimal solution) in the \(j\)-th dimension, while \(I\) is a binary number that indicates the update strength, typically 0 or 1. Equation (43), \(X_{i}\) represents the current position of the \(i\)-th zebra, and \(X_{i}^{\text{new},P1}\) is the updated position of the \(i\)-th zebra in foraging mode. If the fitness value \(F_{i}^{\text{new},P1}\) of the updated position is better than the current fitness value \(F_{i}\), the position is updated to \(X_{i}^{\text{new},P1}\); otherwise, the position remains unchanged. Step 3: Defense phase. This phase simulates the defensive actions of zebras to update the position of each member. When a zebra is attacked by its natural predator, the lion, its position is updated using \(S_{1}\) in Equation (44). When it is attacked by other predators \begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Description** \\ \hline \(node_{num}\) & Unique identifier of the ED. \\ \(SF_{new},BW_{now},TP_{new}\) & The SF, BW, and transmission power currently used by the ED. \\ \(SNR_{avg},RSS_{avg}\) & The average SNR and RSSI of packets received during the statistical window. \\ TP & The transmission power of the ED after adjustment. \\ \(list(SF),list(BW)\) & The list of selectable SFs and BWs available to the ED. \\ \(SNR_{margin},LM\) & The SNR margin and link budget for the ED. \\ \(M_{1},M_{2}\) & The extra margin calculated from the link state score. \\ \(N_{step}\) & The number of iterations in the algorithm. \\ \(SF_{min},SF_{max}\) & The minimum and maximum SF values, from 7 to 12. \\ \(BW_{min},BW_{max}\) & The minimum and maximum BW values, from 62.5 kHz to 500 kHz. \\ \(TP_{inv},TP_{max}\) & The minimum and maximum transmission power, from 2 dBm to 20 dBm. \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Description of parameters in Algorithm 1. (non-natural enemies), its position is updated using \(S_{2}\) in Equation (44). The final update of the position is achieved using Equation (45). \[x_{i,j}^{\text{new},P2}= \begin{cases}S_{1}:x_{i,j}+R\cdot(2r-1)\cdot\left(1-\frac {t}{T}\right)\cdot x_{i,j},&\text{if}\quad P_{s}\leq 0.5\\ S_{2}:x_{i,j}+r\cdot\left(AZ_{j}-I\cdot x_{i,j}\right),&\text{else}\end{cases}  \tag{44}\]  
\[X_{i}= \begin{cases}X_{i}^{\text{new},P2},&\text{if}\quad F_{i}^{\text{new},P2 }<F\\ X_{i},&\text{else}\end{cases}  \tag{45}\]  
Equation (44), \(x_{i,j}^{\text{new},P2}\) represents the updated value of the \(i\)-th zebra in the \(j\)-th dimension in defense mode.