# Resource Allocation on Blockchain Enabled Mobile Edge Computing System
## 3 Resource Allocation Problem
### Edge Computing System Model  
Assuming that one service node (SN) has \(m\) servers, they are in charge of \(n\) mobile devices (MD). In the model, two sets are used to present service node and mobile devices, respectively: \(\textbf{SN}=\{E_{1},E_{2},\ldots,E_{m}\}\), \(\textbf{MD}=\{I_{1},I_{2},\ldots,I_{n}\}\).  
Each mobile device will send different tasks to the service node, as for the latency of a specific task, two parameters are taken into consideration:  
\[t_{process}=t_{q}+t_{p} \tag{1}\]  
where \(t_{process}\) denotes the latency of data processing, \(t_{q}\) denotes the queuing latency, and \(t_{p}\) denotes the time for a server to process the data.  
Assume that the CPU cycles required by the edge computing servers to process 1 bit of data is \(M\), the CPU dominant frequency is \(f\) GHz, and \(d\) represents the data size of the task so Equation (1) can be changed as:  
\[t_{process}=t_{q}+d\frac{M}{f} \tag{2}\]  
The service model is actually a queuing model [36], based on the queuing theory [37], here \(\mathcal{M}\)/\(G\)/s model is chosen to simplify the service model. \(\mathcal{M}\) shows that the arrival rate of tasks is subject to Poisson distribution. \(G\) shows that the processing time is subject to general distribution with certain mean and variance, \(s\) denotes that there are \(s\) servers.  
Figure 2: System procedure.  
When the system is in steady state, according to the time approximation formula raised by [PERSON] [38]:  
\[\mathbb{E}[W_{q}(\mathcal{M}/G/s)]\simeq\frac{1+\sigma^{2}}{\frac{2I_{G}(s)}{ \mathbb{E}[W_{q}(\mathcal{M}/\mathcal{M}/s)]}+\frac{1-I_{G}(s)}{\mathbb{E}[W_{ q}(\mathcal{M}/D/s)]}} \tag{3}\]  
\[I_{G}(s)=\begin{cases}1,&s=1\\ \frac{s+1}{s-1}\Big{\{}\frac{1+\sigma^{2}}{(s+1)\mu I_{G}(s)}\Big{\}},&s\geq 2 \end{cases} \tag{4}\]  
\[I_{G}(s)=\int_{0}^{+\infty}\{1-G_{e}(t)\}^{s}\mathrm{d}t,\;\;t\geq 0 \tag{5}\]  
\[G_{e}(s)=\mu\int_{0}^{t}\{1-G(u)\}\mathrm{d}u,\;\;s\geq 1 \tag{6}\]  
where \(G_{e}\) is the stationary-excess cdf associated with the service-time cdf \(G\).  
Because the reward would be determined using the latency of task in the resource allocation algorithm later, the average latency of the queuing model in its steady state is not chosen when calculating the waiting time of one single task. Specifically, the service time of all the tasks in the target's queue is mentioned, regarding it as the latency of the target task. Relying on that, Equation (2) can be improved as:  
\[t_{process}=\frac{\sum_{i}d_{i}\cdot M_{i}}{f}+d\frac{M}{f}=\frac{b}{f}+d\frac{ M}{f} \tag{7}\]  
where \(\sum_{i}d_{i}\cdot M_{i}\) denotes the total amount of tasks in the buffer. \(b\) is used to represent how much task has left in the buffer in the rest part of the paper.  
Assuming the data size \(d\) obeys general distribution with certain mean and variance: \(d\sim\mathcal{N}(\mu,\sigma^{2})\), and the arrival rate follows the Poisson distribution with parameter \(\lambda\) in order to fit \(\mathcal{M}\)/G/s model.  
In real-world scenarios, the latency should also include the delay in wireless transportation. However, considering that all the servers are deployed in a service node in one certain place, which means that the delay in each server would be the same. Thus, it is left out in the model.  
Based on the kW-h concept in the electricity field, we propose a fresh new unit: GHz.h. The cost of data processing is calculated in GHz.h that the server consumes. So the cost can be presented as:  
\[cost=h\cdot u,\;\;h=f\cdot d\frac{M}{f}=d\cdot M \tag{8}\]  
where \(cost\) denotes the fee that the client needs to pay; \(u\) denotes the cost in GHz.h.