## 3 VirtFogSim: A View of the Simulated Formal Models
### Implemented Auxiliary Functions  
In this subsection, we provide the description of some auxiliary functions called from the previous allocation routines. These auxiliary functions are listed in Table 3.  
In the _Crossover_ function, \(\mathit{Parent}_{v}^{1}\) and \(\mathit{Parent}_{v}^{2}\) are two \(V\)-tuple parent vectors to crossover, while \(\mathit{Child}_{v}^{1}\) and \(\mathit{Child}_{v}^{2}\) are the resulting \(V\)-tuple vectors produced by the performed crossover operation. The crossover operation generates an integer index \(I\) over the set \(\{2,3,\ldots,(V-1)\}\). It is the pointer to the crossover point. Afterward, \(\mathit{Child}_{v}^{1}\) and \(\mathit{Child}_{v}^{2}\) are obtained by swapping the first \(I\) components of \(\mathit{Parent}_{v}^{1}\) and \(\mathit{Parent}_{v}^{2}\) with the last \((V-I)\) components of \(\mathit{Parent}_{v}^{2}\) and \(\mathit{Parent}_{v}^{1}\), respectively.  
In the _Mutation_ function, the global input parameter \(MN\) fixes the number of the components of the input vector \(\vec{x}_{v}\) to be mutated. \(\vec{x}_{v}\) is the \(V\)-tuple \((0,1,2)\)-ternary input vector to be mutated. \(\overrightarrow{out}_{v}\) is the \(V\)-tuple \((0,1,2)\)-ternary mutated output vector. It is guaranteed that the first and last components of \(\overrightarrow{out}_{v}\) are unit valued. The function _Mutation_ generates \(MN\) random positions (with \(1\leq MN\leq(V-2)\)) and \(MN\) random \((0,1,2)\)-ternary mutation numbers. Then, it mutates \(\vec{x}_{v}\) at the generated \(MN\) positions by replacing the generated \(MN\) mutation numbers for the corresponding components of \(\vec{x}_{v}\).  
In the _evaluatestaticenergy_p_ function for parallel execution, \(\vec{x}_{v}\) is the \((1\times V)\)-long input \((0,1,2)\)-ternary task allocation vector to be checked. Since the function _evaluatestaticenergy_p_ is called in the body of the parfor-cycle by the _O_TAS_par_ function, all the needed global variables: \(\vec{s}\), \(A\), \(Da\), and \(S_{RAP}\) must be passed to _evaluatestaticenergy_p_ as input parameters. This guarantees the synchronization of the used global variables under parallel execution. If \(\vec{x}_{v}\) is a feasible task allocation pattern, \(\mathcal{E}_{aux}\) and \(\mathcal{E}_{NET}\) are the total and network energies consumed by \(\vec{x}_{v}\) under the static maximal resource allocation vector defined as: \(\overrightarrow{RS}^{MAX}=[f_{M}^{MAX},f_{F}^{MAX},f_{C}^{MAX},R_{U}^{MAX},R_{ D}^{MAX},B_{U}^{MAX}]\) (bit/s). If \(\vec{x}_{v}\) is an infeasible task allocation pattern, then \(\mathcal{E}_{aux}=\mathcal{E}_{NET}=\infty\) is returned. The asymptotic complexity of the _evaluatestaticenergy_p_ function is: \(\mathcal{O}(7)\), where seven is the number of the computed resource variables.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Function** & **Description** \\ \hline \([\mathit{Child}_{v}^{1},\mathit{Child}_{v}^{2}]=\mathrm{Crossover}\left( \mathit{Parent}_{v}^{1},\mathit{Parent}_{v}^{2}\right)\) & It implements the Crossover operation. \\ \(\overrightarrow{out}_{v}=\mathrm{Mutation}\left(\vec{x}_{v}\right)\) & It implements the Mutation operation. \\ \hline \([\mathcal{E}_{aux},\mathcal{E}_{NET}]=\mathrm{evaluatestaticenergy\_p}\left( \vec{x}_{v},\vec{s},\mathit{A},\mathit{Da},\mathit{S}_{RAP}\right)\) & It evaluates the static energy evaluation in _O_TAS_. \\ \(TA=\mathrm{find\_allocations}\left(N,\mathit{K}\right)\) & It returns all the \(K^{N}\) patterns of \(N\) numbers that can assume the first \(K\) integer values: \(0,1,2,\ldots,K-1\). \\ \hline \hline \end{tabular}
\end{table}
Table 3: Auxiliary functions implemented by _VirtFogSim_.  
Finally, the _find_allocations_ function returns in the matrix \(TA\) all the possible: \(K^{N}\) patterns of \(N\) numbers that can assume the first \(K\) integer values: \(0,1,2,\ldots,K-1\). This function is used by the _ES_S_par_ strategy function to obtain all the possible allocations to be tested in the exhaustive search.