## 3 GA Hybrid-Fog Model
### GA Hybrid-Fog Formulation
Step 7: Update the local best for each individual in population \(i\). Update the global best for all individuals in population \(i\). ```
Inputs: Task size vector (\(D\)), radius (\(R\)), channel frequency (\(f_{c}\)), transmission bandwidth (\(B\)), altitude of the UAV (\(H\)), fog BS CPU cycles (\(\eta\)), fog BS CPU frequency (\(f_{i}\)), UAV transmission power (\(P_{t}\)), noise power (\(n_{0}\)) Output: Total task-offloading delay (\(Total\_Delay\)) Steps: Step 1: Calculate the transmission Rate (\(T\)): Step 1.1: Determine the range of the communication: lambda = physconst('LightSpeed')/\(f_{c}\) Range = round(hypot(H, Radius)); Step 1.2: Calculate the transmission packet loss (\(PL\)), signal-to-noise ratio (\(SNR\)), and transmission data rate (\(T\)): PL = fsp(Range, lambda) \(SNR\) = (\(P\_t\) / \(PL\))/\(n\_0\) \(T\) = \(B\) - log_\(2\)(\(1+SNR\)) Step 2: Calculate Total Delay (\(Total\_Delay\)): Step 2.1: Compute transmission delay (\(delay\)) and fog computing delay (\(C\)): delay = D/T, C = \(D\cdot\eta\) /\(f\_i\) Step 2.2: Compute total transmission delay (\(ToT_{trans}-Delay\)) and total fog computing delay (\(ToT_{comp}-Delay\)): \(ToT_{trans}-Delay\) = Delay(1); \(ToT_{comp}-Delay\) = C(1); for i = 1 : (Length(D) \(-\) 1) \(ToT_{trans}-Delay\) = \(ToT_{trans}-Delay\) + Delay(i + 1); \(ToT_{comp}-Delay\) = \(ToT_{comp}-Delay\) + C(i); if (\(ToT_{trans}-Delay\) > \(ToT_{comp}-Delay\)) \(ToT_{comp}-Delay\) = \(ToT_{trans}-Delay\); end for \(Total\_Delay=ToT_{comp}-Delay\) + C(length(D));
```

**Algorithm 2 Calculating the total delay of the offloading tasks to a single fog base station or fog UAV**

## 4 Numerical Results

This section presents the configuration of our simulation and a comparison of the results between our proposed GA Hybrid-Fog and different IoD technologies integrated with a GA (GA BS-Fog, GA UAV-Fog, and GA UAV-Edge). **Simulation and parameter settings:**

We conducted our simulation using the MATLAB R2016a toolbox in order to evaluate the performance of GA Hybrid-Fog for task offloading in IoD networks. Table 2 shows the simulation parameter settings, in which three types of devices were deployed: BS-Fog, UAV-Fog, and UAV-Edge. Our simulation consisted of two phases:

**Phase 1:** We evaluated the proposed GA Hybrid-Fog algorithm by comparing it with two existing task-offloading methods:

* **Particle Swarm Optimization (PSO)**: Designed for static fog task offloading, as proposed in [13]. * **Mixed-Integer Linear Programming (MILP)**: Introduced in [14] for mobile fog task offloading. **Phase 2:** We compared the GA Hybrid-Fog solution with the following integrated IoD technologies:

* **GA UAV-Edge:** Uses a GA for task distribution between UAVs in the edge layer. * **GA BS-Fog:** Uses a GA for task offloading to fog BSs. * **GA UAV-Fog:** Uses a GA for task offloading to fog UAVs. * **GA Hybrid-Fog:** The proposed solution, which uses a GA for task offloading to both fog BSs and fog UAVs. Figure 3 presents a performance comparison of task-offloading methods based on the number of nodes, with the number of offloaded tasks fixed at 200. The figure illustrates the variations in task-offloading delay (in seconds) for our proposed GA algorithm, as well as the PSO and MILP algorithms, as a function of the number of fog nodes. As shown, increasing the number of fog nodes reduced task-offloading delay across all methods. This decrease is attributed to the enhanced processing capacity provided by additional nodes. The results indicate that GA had a lower delay compared to PSO and MILP. Specifically, when the number of nodes was seven, the task-offloading delay using GA was 0.52 s, whereas PSO resulted in a delay of 0.97 s and MILP incurred a delay of 1.26 s. This corresponds to reductions in delay of 46.39% compared to PSO and 58.73% compared to MILP.