## 3 VirtFogSim: A View of the Simulated Formal Models
### The Considered Throughput-Constrained Joint Task and Dynamic Resource Allocation Problem  
In this section, we give a glimpse of the constrained optimization problem whose solution is numerically evaluated by _VirtFogSim_. For this purpose, let \(\mathcal{E}_{M}\), \(\mathcal{E}_{F}\), and \(\mathcal{E}_{C}\) (Joule) be the computing energies consumed by the Mobile device, Fog clone, and Cloud clone of Figure 1 in order to process the assigned tasks of the considered application DAG. Furthermore, let \(\mathcal{E}_{WiFi}\), \(\mathcal{E}_{CELL}\), and \(\mathcal{E}_{WD}\) (Joule) be the energies consumed by the Mobile-Fog, Mobile-Cloud, and Cloud-Fog two-way TCP/IP connections, in order to transport the inter-task data among the Mobile, Cloud, and Fog computing nodes. Finally, let:  
\[\mathcal{E}_{\text{TOT}}\overset{\text{def}}{=}\vartheta_{M}\times\mathcal{E} _{M}+\vartheta_{F}\times\mathcal{E}_{F}+\vartheta_{C}\times\mathcal{E}_{C}+ \mathcal{E}_{WiFi}+\mathcal{E}_{CELL}+\mathcal{E}_{WD}\quad\left(\text{Joule }\right), \tag{3}\]  
be the resulting computing-plus-communication total consumed energy, with \(\vartheta_{M}\), \(\vartheta_{F}\), and \(\vartheta_{C}\) being binary \(\left\{0,1\right\}\)-valued constants. Hence, the considered Joint Optimization Problem _(JOP)_ is defined as follows:  
\[\min_{\overrightarrow{RS},\overrightarrow{x}}\mathcal{E}_{\text{TOT}}\,,\] (4a) s.t. : \[\left(1/T_{DAG}\right)\geq TH_{0}^{MIN}\,, \tag{4b}\] \[0\leq f_{M}\leq f_{M}^{MAX}\,,\] (4c) \[0\leq f_{F}\leq f_{F}^{MAX}\,,\] (4d) \[0\leq f_{C}\leq f_{C}^{MAX}\,,\] (4e) \[0\leq R_{U}\leq R_{U}^{MAX}\,,\] (4f) \[0\leq R_{D}\leq R_{D}^{MAX}\,,\] (4g) \[0\leq B_{U}\leq B_{U}^{MAX}\,, \tag{4h}\]\[0\leq B_{D}\leq B_{D}^{MAX}\,, \tag{4i}\] \[\min_{\overrightarrow{RS},\overrightarrow{x}}\mathcal{E}_{\text{TOT}}\,,\]0 (4j) \[\min_{\overrightarrow{RS},\overrightarrow{x}}\mathcal{E}_{\text{TOT}}\,,\]1  
In the above equations, we have that:  
1. \(\overrightarrow{RS}\) is the resource allocation vector defined in Equation (2);
2. \(\vec{x}\) is the task allocation vector defined in Equation (1);
3. \(T_{DAG}\) (s) is the overall time needed to execute the assigned application DAG, in short, the DAG execution time. It generally depends on the optimization variables \(\overrightarrow{RS}\) and \(\vec{x}\);
4. \(TH_{0}^{MIN}\) (app/s) is the required minimum application throughput, i.e., the minimum number of application DAGs to be performed in the time interval of one second. It is a non-negative real number;
5. Equations (4c)-(4g) account for the maximum available resources;
6. Equations (4i)-(4k) account for the ternary nature of the considered task allocation vectors. The considered JOP is solved in _VirtFogSim_ by the _RAP_p_ function described in Section 4.2. Before proceeding, four main remarks about the formulated _JOP_ are in order. First, it aims to _jointly_ optimize the allocation of the tasks over the Mobile, Fog, and Cloud computing nodes of Figure 1_and_ the corresponding computing-plus-communication resources. Formally speaking, it is a mixed-integer non-convex optimization problem, that resists closed-form solution. In the sequel, we will denote as: \(\overrightarrow{RS}^{*}\) and \(\vec{x}^{*}\) the solution of the constrained _JOP_ in Equations (4a)-(4k). Second, for positive \(TH_{0}^{MIN}\), the constraint in Equation (4b) enforces a _hard_ (e.g., deterministic) _QoS_ constraint on the minimum desired application throughput. As a consequence, too many larger values of \(TH_{0}^{MIN}\) may give rise to infeasible _JOP_. Third, the actual values of the binary constants: \(\theta_{M}\), \(\theta_{F}\), and \(\theta_{C}\) depend on the application service model adopted by the Service Provider. Specifically, \(\theta_{M}\) and/or \(\theta_{F}\) and/or \(\theta_{C}\) are unit valued (resp., vanish) when the energies consumed by the Mobile, Fog, and Cloud computing nodes are for free (resp., are taxed).