## 3 VirtFogSim: A View of the Simulated Formal Models
### Supported Task Allocation Strategies and Adaptive Resource Allocation
It returns the vector of the _optimal_ resource allocation attained by the performed primal-dual iterations. Its seven components are measured in bit/s;
4. \(\widetilde{\mathcal{E}}_{TOT}\) is the total communication-plus-computing energy consumed by the computed optimal resource allocation \(\widetilde{y}\) under the given task allocation \(x\). \(\widetilde{\mathcal{E}}_{TOT}\) is measured in Joule. 5. \(\widetilde{\mathcal{E}}_{NET}\) is the overall network energy consumed by the computed optimal resource allocation \(\widetilde{y}\) under the given task allocation \(x\). \(\widetilde{\mathcal{E}}_{NET}\) is measured in Joule;
6. \(s\), \(A\) and \(Da\) are respectively the global workload vector, adjacency matrix, and edge matrix of the underlying DAG;
7. \(S_{RAP}\) is the \((1\times 54)\)-dimensional vector of all other global variables used by \(RAP\_p\) for its execution. Since \(RAP\_p\) is executed by the calling functions in the body of parfor-cycles, the global variables: \(s\), \(A\), \(Da\), and \(S_{RAP}\) must be passed to the \(RAP\_p\) function as input parameters, in order to guarantee the synchronization of the parfor-cycles performed by multiple parallel workers. The \(RAP\_p\) function requires \((110+6\times V)\) scalar local variables and two \((1\times I_{MAX})\) vector local variables. The \(I_{MAX}\) parameter is stored by \(S_{RAP}\) and fixes the maximum number of allowed primal-dual iterations. The asymptotic implementation complexity of the \(RAP\_p\) function scales as: \(\mathcal{O}\left(8\times I_{MAX}\right)\). The parallel _Exhaustive Search-Strategy (ES_S_par)_ function returns:  
1. the \(V\)-tuple \((0,1,2)\)-ternary \(\vec{x}_{ESS}\). It is the globally best task allocation vector, which is generated by performing the exhaustive search over the full population of the \(3^{(V-2)}\) ternary task allocation vectors. The first and last components of each ternary task allocation vector are unit valued, i.e., the first and last tasks of the application DAG are executed, by design, at the Mobile device;
2. the seven-tuple resource allocation vector: \(\overrightarrow{RS}_{ESS}=\left[f_{M^{\prime}}^{*},f_{F^{\prime}}^{*},f_{C}^{* },R_{U}^{*},R_{D}^{*},B_{U}^{*},B_{D}^{*}\right]\) (bit/s), corresponding to the returned global task allocation vector \(\vec{x}_{ESS}\);
3. the total communication-plus-computing energy \(\mathcal{E}_{ESS}\) (Joule), network energy \(\mathcal{E}_{NET}^{ESS}\) (Joule), and bandwidth \(RB_{ESS}\) (bit/s) of the backhaul connection consumed under the returned searched global best task allocation vector \(\vec{x}_{ESS}\). Being obtained through an exhaustive search, \(\mathcal{E}_{ESS}\) is, by design, the global minimum total energy consumed under the considered application scenario of Figure 1.  
In order to guarantee that the full search space of the the task allocation vectors is actually explored, the _ES_S_par_ function calls the auxiliary function: _find_ allocations_, which returns the: \(\left(3^{(V-2)}\times V\right)\)-dimensional \(POP\) matrix of all possible \((0,1,2)\)-ary task allocation patterns. Afterward, _ES_S_par_ calls the \(RAP\_p\) function under each ternary task allocation vector returned by _find_allocations_, in order to evaluate the resulting best resource allocation vector, the corresponding total and network consumed energies, and the utilized backhaul bandwidth. After checking all the \(3^{(V-2)}\) task allocations, _ES_S_par_ sorts them for increasing values of their total consumed energies and, then, picks out the first element of the attained sorted list. This last comprises the globally best task allocation \(x_{ESS}\), its associated resource allocation vector \(\overrightarrow{RS}_{ESS}\), the corresponding consumed energies \(\mathcal{E}_{ESS}\) and \(\mathcal{E}_{NET}^{ESS}\), and the utilized backhaul bandwidth \(RB_{ESS}\). A pseudo-code of the _ES_E_par_ function is reported in Algorithm 2.