## 3 VirtFogSim: A View of the Simulated Formal Models
### General Architecture of the Developed Simulation Platform  
The main functionalities of _VirtFogSim_ are implemented by the functions listed in Table 2. In the sequel of the paper, these functions are briefly described. A deep explanation about the usage of such functions can be found in the _VirtFogSim_ User Guide, which can be downloaded along with the software package (see Section 8). The main functions in Table 2 use some auxiliary functionalities implemented in the set of routines listed in Table 3.  
Regarding the description of the general software architecture of the simulator, _VirtFogSim_ acts as the main program that:  
1. allows the user to setup 67 input parameters that characterize the scenario to be simulated by the user (see Figure 1);
2. calls the _GeneticTA_par_ function for parallel execution and returns the corresponding: 1. \(\vec{x}_{best}\in\{0,1,2\}^{V}\), i.e., ternary \(V\)-tuple best allocation vector; \begin{table}
\begin{tabular}{l l} \hline \hline
**Function** & **Description** \\ \hline \(\left[\vec{\bar{y}},\,\vec{\xi}_{TOT},\,\vec{\xi}_{NET}\right]=\text{RAP\_p}\, (\vec{x},\,\vec{z},\,\vec{s},\,Da,\,S_{RAP})\) & It implements the Resource Allocation Problem described in Equation (4). \\ \(\left[\mathcal{E}_{aux},\,\mathcal{E}_{max}^{NET},\,\lambda_{aux}\right]= \text{FogTracker}\,(x_{1},\,x_{2},\,x_{3})\) & It tests the convergence rate to the steady-state and the steady-state stability of the primal-dual iterations performed by the _RAP_p_ function when abrupt changes happen. \\ \hline \(\left[\vec{x}_{best},\,\overrightarrow{R}_{best}^{S},\,\mathcal{E}_{best}, \,\mathcal{E}_{best}^{NET},\,RB_{best}\right]=\text{GeneticTA\_par}\) & It runs the parallel Genetic Task Allocation strategy. \\ \(\left[\overrightarrow{R}_{OM},\,\mathcal{E}_{OM},\,\mathcal{E}_{OM}^{NET} \right]=\text{OM\_S}\) & It runs the Only Mobile strategy. \\ \(\left[\overrightarrow{R}_{OF},\,\mathcal{E}_{OF},\,\mathcal{E}_{OF}^{NET} \right]=\text{OF\_S}\) & It runs the Only Fog strategy. \\ \(\left[\overrightarrow{R}_{OC}^{S},\,\mathcal{E}_{OC},\,\mathcal{E}_{OC}^{NET} \right]=\text{OC\_S}\) & It runs the Only Cloud strategy. \\ \(\left[\vec{x}_{OTAS},\,\mathcal{E}_{OTAS},\,\mathcal{E}_{OTAS}^{NET}\right]= \text{O\_TAS\_par}\) & It runs the Only Task Allocation strategy. \\ \(\left[\vec{x}_{ESS},\,\overrightarrow{R}_{ESS}^{S},\,\mathcal{E}_{ESS},\, \mathcal{E}_{ESS}^{NET},\,RB_{ESS}\right]=\text{ES\_S}\) & It runs the Exhaustive Search strategy. \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Main functions implemented by _VirtFogSim_. * \(\overrightarrow{R}_{best}^{\text{def}}\)\([f_{M}^{s},f_{F}^{s},f_{C}^{s},R_{U}^{s},R_{D}^{s},B_{U}^{s},B_{D}^{s}]\) (bit/s), i.e. the seven-tuple vector of the optimal resource allocation of the Mobile computing frequency, Fog computing frequency, Cloud computing frequency, Mobile-to-Fog transport throughput, Fog-to-Mobile transport throughput, Mobile-to-Cloud transport throughput, and Cloud-to-Mobile transport throughput (see Figure 1);
* \(\mathcal{E}_{best}\) (Joule), i.e., the total computing-plus-network energy consumed by the infrastructure of Figure 1 under the returned \(\vec{x}_{best}\) task allocation vector. For this purpose, the _GeneticTA_ function calls, in turn, the auxiliary functions \(RAP\), _Crossover_, and _Mutation_ ;
* optionally, calls the \(OM\_S\) function and returns:
* \(\overrightarrow{R}_{OM}^{\text{def}}\)\([f_{M},f_{F},f_{C},R_{U},R_{D},B_{U},B_{D}]\) (bit/s), i.e., the seven-tuple vector of the optimal resource allocation under the \((1\times V)\)_All-Mobile_ task allocation vector: \(\vec{x}_{OM}\overset{\text{def}}{=}[1,1,\ldots,1,1]\);
* \(\mathcal{E}_{OM}\) (Joule), i.e., the total computing-plus-network energy consumed by the infrastructure of Figure 1 under \(\vec{x}_{OM}\). If the returned \(\mathcal{E}_{OM}\) is infinite, then the _All-Mobile_ task allocation \(\vec{x}_{OM}\) is infeasible.