# A Cost-Aware Framework for QoS-Based and Energy-Efficient Scheduling in Cloud-Fog Computing
## 6 Service Management Framework
### Problem Formulation: Minimum Cost of QoS and Energy Penalty
#### 6.3.2 Penalty Cost \(\epsilon\) of Energy across the Cloud-Fog Environment  
Scheduling the stream \(\ell\) of fog jobs \(\mathbf{J}\) across the cloud-fog computing environment incurs an energy cost \(\epsilon\) that formulates the energy performance of bandwidth allocation \(\Gamma\), waiting \(t\omega_{i}^{\beta}\) in a resource queue \(Q_{m}\) in the cloud tier, service time \(\mathcal{E}_{i}\) in a cloud resource \(R_{m}\), and SLA violation \(\alpha_{i}^{\beta}\) with the cloud service provider.  
As such, a fog job \(J_{i}\) is delivered by a fog device for execution in cloud resources \(R\). Allocating a bandwidth \(\mathds{F}\) for a fog job \(J_{i}\) in the fog tier incurs an energy cost \(e_{\gamma,\mathds{F}}\) per time unit of bandwidth allocation, that is, a function of an energy consumption per bit \(u\) modeled by an exponential distribution with a rate \(\lambda_{\Gamma}\) and a communication bit-rate \(q\) modeled by a uniform distribution as follows:  
\[e_{\gamma,\mathds{F}}=u\times q \tag{24}\]  
\[u=\exp(\lambda_{\Gamma}) \tag{25}\]  
\[q=\text{uniform}() \tag{26}\]  
which, as a result, incurs a total bandwidth energy cost \(E_{i,\Gamma}\) modeled by:  
\[E_{i,\Gamma}=\sum_{\gamma=1}^{F}\left(\mathds{F}\times e_{\gamma,\mathds{F}} \times z_{i,\gamma}\right) \tag{27}\]  
Once a fog job \(J_{i}\) arrives to the cloud computing environment, the cloud dispatcher \(cd\) allocates a resource \(R_{m}\) that fulfills the job's QoS waiting requirements with the least energy cost. There exists an energy cost \(e_{m,\omega_{i}}\) per time unit of waiting \(t\omega_{i}^{\beta}\) in a resource queue \(Q_{m}\) in the cloud tier modeled by an exponential distribution with a rate \(\lambda_{\omega}\), which accordingly incurs a total waiting energy cost \(E_{i,\omega}\) modeled by:  
\[E_{i,\omega}=\sum_{m=1}^{n}\left(t\omega_{i}^{\beta}\times e_{m,\omega_{i}} \times z_{i,m}\right) \tag{28}\]  
\[e_{m,\omega_{i}}=\exp(\lambda_{\omega}) \tag{29}\]  
When a fog job \(J_{i}\) is delivered from a resource queue \(Q_{m}\) to start the service in a cloud resource \(R_{m}\), an energy cost \(e_{m,\mathcal{E}_{i}}\) is incurred for each time unit of service \(\mathcal{E}_{i}\) in the cloud resource \(R_{m}\) modeled by an exponential distribution \(\lambda_{\mathcal{E}}\), which thus incurs a total service energy cost \(E_{i,\mathcal{E}}\) modeled by:  
\[E_{i,\mathcal{E}}=\sum_{m=1}^{n}\left(\mathcal{E}_{i}\times e_{m,\mathcal{E}_ {i}}\times z_{i,m}\right) \tag{30}\]  
\[e_{m,\mathcal{E}_{i}}=\exp(\lambda_{\mathcal{E}}) \tag{31}\]  
If, however, an SLA violation occurs, an energy cost \(e_{m,\mathcal{E}_{i}}\) is developed per each time unit of SLA violation \(\alpha_{i}^{\beta}\) with the cloud service provider modeled by \(\lambda_{\alpha}\), which therefore incurs a total SLA violation energy cost \(E_{i,\alpha}\) modeled by:  
\[E_{i,\alpha}=\sum_{m=1}^{n}\left(\alpha_{i}^{\beta}\times e_{m,\mathcal{E}_{ i}}\times z_{i,m}\right) \tag{32}\]  
\[e_{m,\mathcal{E}_{i}}=\exp(\lambda_{\alpha}) \tag{33}\]  
As such, the entire cost of energy \(\epsilon\) for a stream \(\ell\) of fog jobs \(J\) across the cloud-fog computing environment is modeled by:  
\[\epsilon=\sum_{i=1}^{L}\left(E_{i,\Gamma}+E_{i,\omega}+E_{i,\mathcal{E}}+E_{ i,\alpha}\right) \tag{34}\]The objective is to formulate a schedule for a stream \(\ell\) of fog jobs \(\mathbf{J}\) in the cloud tier with a scheduling order \(\beta\) such that the entire cost of energy \(\epsilon\) is minimized at the level of the cloud-fog computing environment, as follows:  
\[\begin{split}\underset{\beta}{\text{minimize }}(\epsilon)&=\sum_{i=1}^{l} \bigg{(}\sum_{\gamma=1}^{F}(\mathbb{F}\times e_{\gamma,\mathbb{F}}\times z_{i,\gamma})+\\ &\sum_{m=1}^{n}\big{(}(t\omega_{i}^{\beta}\times e_{m,\omega_{i}} +\mathcal{E}_{i}\times e_{m,\mathcal{E}_{i}}+\alpha_{i}^{\beta}\times e_{m, \alpha_{i}})\times z_{i,m}\big{)}\bigg{)}\end{split} \tag{35}\]