## 3 VirtFogSim: A View of the Simulated Formal Models
### Simulated Adaptive Resource Allocation Framework  
In this subsection, we briefly present the general analytical framework implemented by the _RAP_p_ and _FogTracker_ functions of Sections 4.2 and 4.4, in order to perform the adaptive updating of the computing frequencies: \(f_{M}\), \(f_{F}\), \(f_{C}\), the wireless network bandwidths: \(R_{U}\), \(R_{D}\), \(B_{U}\), \(B_{D}\), and the Lagrange multiplier \(\lambda\) associated with the throughput constraint in Equation (4b). The final goal is to allow the user to acquire insights about the role played by the input step-size \(a_{MAX}\) and related input step-size vector \(\vec{a}_{MAX-FT}\) on the adaptive capability of the resource allocation engine implemented by _VirtFogSim_. For this purpose, after indicating by \(\mathcal{L}\) the Lagrangian function of the _JOP_ of Equation (4), let: \(y\in\{f_{M},f_{F},f_{C},R_{U},R_{D},B_{U},\lambda\}\) indicate a (scalar and non-negative) variable to be optimized, and let \(y_{MAX}\) be its allowed maximum value. Furthermore, after denoting by \(t\) an integer-valued iteration index, let \(\
abla_{y}\mathcal{L}\left(t\right)\) be the derivative of the Lagrangian function \(\mathcal{L}\) with respect to the considered optimization variable \(y\) at iteration \(t\). Hence, according to the so-called primal-dual iteration-based approach recently customized in [28] for broadband networked application scenarios, the adaptive updating of \(y\left(t+1\right)\) reads as follows:  
\[y\left(t+1\right)=\max\{0,\,\min\{y_{MAX},\,y\left(t\right)-g_{y}\left(t \right)\
abla_{y}\mathcal{L}\left(t\right)\}\}, \tag{19}\]  
where the outer \(\max\{.\}\) (resp., the inner \(\min\{.\}\)) accounts for the non-negative (resp., maximum) value of \(y\). The peculiar feature of the updating relationship in (19) is that it resorts to a \(y\)-depending and time-varying gain function: \(g_{y}\left(t\right)\), in order to guarantee _quick adaptation_ of the optimization variable \(y\) in response to abrupt changes of the wireless environment of Figure 1. On the basis of the general results of [28] about the convergence to the steady-state of the iterations in (19), we planned to implement in the current version of _VirtFogSim_ the following time-varying gain formula:  
\[g_{y}\left(t+1\right)=\max\{a_{MAX},\,\min\{a_{MAX}\times y_{MAX},\,\frac{1}{2} \left(y\left(t\right)\right)^{2}\}\}. \tag{20}\]  
An examination of the above formula unveils the role played by the (positive) step-size \(a_{MAX}\), as well as its potential impact on the adaptive capability of the overall simulator. Specifically, on the basis of (20), we expect that large (resp., small) values of \(a_{MAX}\) lead to quick (resp., slow) response to abrupt environmental changes, together with large (resp., small) possible oscillations in the steady-state. In this regard, we anticipate that the final goal of the _FogTracker_ function of Section 4.4 is to guide the user towards the right trade-off among these two \(a_{MAX}\)-depending contrasting behaviors. **4. VirtFogSim: Supported Task Allocation Strategies and Their Parallel Execution**  
The engine of the _VirtFogSim_ simulator is built of a main core of eight software routines that implement a number of strategies (e.g., optimization policies), in order to check the feasibility and, then, solve numerically the constrained optimization problem in (4). MATLAB is the native environment under which the optimization routines are developed and run. In this regard, it must be remarked that the _VirtFogSim_ package is capable of _automatically_ turning ON and exploiting the multi-core capability retained by the supporting hardware platform, in order to run parallel programming and, then, speed up the execution of the implemented task allocation policies. This is done in a fully-_transparent_ way, e.g., without any direct user involvement. For this purpose, some instructions for parallel programming on multi-core hardware platforms specifically supported by the _Parallel Toolbox_ of MATLAB are utilized by the _VirtFogSim_ package.