## 4 DeepFogSim: The Considered System Model
### The Underlying Resource Allocation Problem  
From a formal point of view, the proposed _DeepFogSim_ toolkit numerically computes the solution and evaluates the resulting performance of an optimization problem that is concerned with the _joint_ allocation of the available computing-plus-networking resources to the FNs of the virtualized execution platform of Figure 3 under per-exit constraints on the tolerated inference delays. In order to introduce this problem, let \(Q=\sum_{m=1}^{M}m_{m}\) be the number of FNs of the platform of Figure 3. Let: \(\vec{f}\triangleq\left[f_{11},\ldots,f_{M1}\right]^{T}\in\mathbb{R}_{+}^{Q}\), \(\vec{\widetilde{f}}\triangleq\left[\widetilde{f}_{11},\ldots,\widetilde{f}_{ M1}\right]^{T}\in\mathbb{R}_{+}^{Q}\) and \(\vec{R}\triangleq\left[R_{1},\ldots,R_{M-1}\right]^{T}\in\mathbb{R}_{+}^{M-1}\) be the vectors of the convolutional and classifier processing frequencies and the vector of the inter-tier network throughputs, respectively. Finally, let \(\vec{x}\triangleq\left[\vec{f},\vec{\widetilde{f}},\vec{\widetilde{R}}\right] ^{T}\in\mathbb{R}_{+}^{2Q+M-1}\) be the resulting compound vector. Hence, the tackled constrained resource allocation problem is formally defined as follows:  
\[\min_{\vec{x}}\mathcal{E}_{TOT}\,,\] (23a) s.t. : \[0 \leq T_{EXT}^{(1,m)}\leq T_{EXT}^{(m)}\,, m=1,\ldots,M\,, \tag{23b}\] \[0 \leq f_{jm}\leq f_{jm}^{(MAX)}\,, j=1,\ldots,m_{m}\,, m=1,\ldots,M\,,\] (23c) \[0 \leq\widetilde{f}_{jm}\leq\widetilde{f}_{jm}^{(MAX)}\,, j=1,\ldots,m_{m}\,, m=1,\ldots,M\,,\] (23d) \[0 \leq R_{m}\leq R_{m}^{(MAX)}\,, m=1,\ldots,M\,, \tag{23e}\]  
where: \(\left\{T_{EXT}^{(m)},\ m=1,\ldots,M\right\}\) (s), \(\left\{f_{jm}^{(MAX)},\ j=1,\ldots,m_{m},\ m=1,\ldots,M\right\}\) (bit/s), \(\left\{\widetilde{f}_{jm}^{(MAX)},\ j=1,\ldots,m_{m},\ m=1,\ldots,M\right\}\) (bit/s) and \(\left\{R_{m},\ m=1,\ldots,M-1\right\}\) (bit/s) are the set of the \(M+2Q+M-1=2(M+Q)-1\) assigned constraints on the maximum allowed resources and tolerated per-exit inference delays. The box constraints in (23c)-(23e) upper bound the computing frequencies at the FN and the inter-tier network throughput, respectively. The \(M\) constraints in (23b) guarantee that each local exit is generated within a maximum inference delay. In the case in which no delay constraint is enforced to the \(m\)-th local exit, we set \(T_{EXT}^{(m)}=+\infty\). The problem in (23) is a continuous-valued optimization problem that embraces \((2Q+M-1)\) non-negative continuous optimization variables and \(2(M+Q)-1\) constraints. The \((2Q+M-1)\) constraints in (23c)-(23e) are of box-type, while the \(M\) delay constraints in (23b) are nonlinear constraints involving the optimization vector \(\vec{x}\). After indicating by \(\mathcal{L}\) the Lagrangian function of the problem in Equation (23), and by \(\left\{\lambda_{m},\ m=1,\ldots,M\right\}\) the Lagrange multipliers associated to the delay constraints in (23b), let: \(\left\{\vec{x}^{*},\ \widetilde{\lambda}^{*}\right\}\) be a solution of the optimization problem. In order to compute it, we implement the iteration-based primal-dual approach recently customized in Reference [45] for broadband networked application scenarios. The primal-dual algorithm is an iterative procedure that updates on per-step basis both the primal \(\vec{x}\) and the dual \(\widetilde{\lambda}\) variables, in order to throttle the corresponding Lagrangian function \(\mathcal{L}\) towards its saddle point.