Keywords

1 Introduction

In mobile cloud computing (MCC), by offloading the computational tasks to the distant cloud for execution, the system performance, e.g., energy consumption and latency, is able to be improved [1]. Among all different types of MCC technologies, fog/edge computing system, emerges as a proximity solution to provide pervasive and distributed computation services for the MDs, and especially for the Internet-of-Things (IoT) applications with stringent requirement of latency and reliability [2]. In the edge computing system, as the computing capability of the edge node (EN) is not comparable to the traditional cloud center and one EN only serves a relative small area where the radio resource is also limited, the offloading decisions of the MDs may have a significant impact on the quality of services (QoS). Accordingly, the usage of the radio resources, such as transmit power and frequency spectrum, and the harvested energy should be carefully coordinated and optimized in line with the offloading decisions. In addition, as the radio environment and the demand for computational resources vary in a fast speed, dynamic scheduling and optimization are more preferred compared to static optimization schemes. However, due to the randomness of radio environment, harvested energy and computation demands, realizing the dynamic optimization is challenging. Therefore, in this paper, our aim is to overcome the obstacles and provide dynamic computation offloading and resource allocation schemes for edge computing system with EH devices.

Most of the researches on the offloading problem focus on designing different and effective static schemes for battery-powered MDs, through optimizing the MD’s execution decision, radio resource, and/or computational resource [2,3,4,5,6,7]. Considering a edge computing system, the authors of [2] apply queuing theory to investigate the delay, energy consumption, and payment cost (E&D&P) of offloading processes. Based on the theoretical analysis, a multi-objective optimization problem is then formulated to minimize the formulated cost functions by finding the offloading decisions and power allocation for each MD. In [3], the authors explore the tradeoff between delay and energy consumption in the edge-cloud hybrid computing system. The associated workload allocation problem is addressed accordingly. In [4], the authors propose an optimization framework of offloading to optimize the task allocation decision and the computational resource allocation.

In this work, to address the offloading problem in edge computing, we consider different queue models at different edge computing devices to provide thorough analysis on the delay and energy consumption performance. At the MD, a M/M/1 queue is considered and at the EN, a M/G/1 queue is assumed. With the derived analytical results, we are able to formulate the system cost, which consists of service latency and energy consumption. With the objective to minimize the formulated system cost, the offloading strategy, the transmit power, and the subcarrier assignment are jointly optimized in the proposed resource allocation and offloading scheme. Due to the stochastic nature of the radio channel, the request arrival and the amount of harvesting energy, we propose to leverage the advantages of Lyapunov optimization to design an online dynamic algorithm. By minimizing the upper bound of the Lyapunov drift-plus-penalty function from the perspective of different decision variables, the initial problem is divided into several simple sub-problems with low-complexity and can be addressed accordingly.

2 System Model

We consider the system consisting of N single-core MDs, one AP, and one EN. The set of MDs is denoted as \(\mathcal {N}=\left\{ 1,2,\cdots ,N \right\} \). Each MD generates a series of homogeneous service requests in order to execute an application. At the MD, a first-in-first-out (FIFO) queue is considered for storing arriving requests, and the radio interface is used for wireless connection. As a single processor is assumed, the process queue at the MD is assumed as a M/M/1 queue. The EH capability enables the MD to obtain energy supply from the environment. The harvested energy used for local task execution and data transmission. The AP is responsible for receiving requests from the MD and delivering data to the EN for further processing. The process queue of EN is modelled as a M/G/1 queue. The MD offloads (part of) the computation requests to the EN to enjoy a higher level of quality of computation experience. We assume that the time is slotted and the length of each time slot is \(\tau \). We denote the time slot set \(\mathcal {T}=\left\{ 0,1\cdots ,t\cdots ,T-1 \right\} \).

2.1 Local Execution Model

The computation requests generated by MD i, \(i\in \mathcal {N}\) is assumed to follow Poisson process with an average arrival rate \({A}_{i}\left( t \right) \) and within \(\left[ {A}_{i,\min },{A}_{i,\max } \right] \). Each request is of data size \({\theta }_{i}\). Note that “at time slot t” means the requests are generated at time slot “t” but executed at time slot “\(t+1\)”.

For MD i, some of the computation requests may be locally executed and the rest will be offloaded to the EN. It may also happen that when neither of these computation modes is feasible, e.g., when MD has insufficient energy, and some of the computation requests have to be dropped. The decision of MD i at time slot t is modeled as a vector \(\mathbf{p _{i}}\left( t \right) =\left[ p_{i}^{M}\left( t \right) ,p_{i}^{F}\left( t \right) ,p_{i}^{D}\left( t \right) \right] \), where \( p_{i}^{M}\left( t \right) + p_{i}^{F}\left( t \right) +p_{i}^{D}\left( t \right) =1\). \(p_{i}^{M}\left( t \right) \) represents the portion that the requests are executed locally at time slot t, \(p_{i}^{F}\left( t \right) \) denotes the portion that the requests are offloaded to the EN, and \(p_{i}^{D}\left( t \right) \) expresses the portion that the requests are dropped.

We denote \(u_{i}^{M}\) as the computing capability of MD i, which depends on CPU Cycle the MD. Additionally we assume that \(l_{i}^{M}\left( t \right) \) denotes the normalized workload on the MD i at time slot t, which shows the occupation of CPU. For example, \(l_{i}^{M}\left( t \right) =0\) indicates at time slot t, the CPU is totally idle. When considering a M/M/1 queue with request arrival rate \(\lambda \) and service rate u, the response time is \(R=\frac{1/u}{1-\rho }\), where \(\rho =\frac{\lambda }{u}\) [8]. Then, the average response time \(D_{i}^{M}\left( t \right) \) for local execution of MD i at time slot t is expressed as follows:

$$\begin{aligned} D_{i}^{M}\left( t \right) =\frac{1}{u_{i}^{M}\left( 1-l_{i}^{M}\left( t \right) \right) -p_{i}^{M}\left( t \right) {{A}_{i}}\left( t \right) }. \end{aligned}$$
(1)

Assume that the computing capability of MD i is \(u_{i}^{M}\left( 1-l_{i}^{M}\left( t \right) \right) \) and the corresponding CPU-cycle frequency is denoted as \({f}_{i}\left( t \right) \) at time slot t. As shown in [5], under the assumption of a low CPU voltage, the power consumption of CPU is \(k{f}^{3}\), where k is a constant depending on the switched capacitance of MD, and f is the CPU-cycle frequency. Thus, the energy consumption \(E_{i}^{M}\left( t \right) \) of MD i for local execution can be denoted as follows:

$$\begin{aligned} \begin{aligned} E_{i}^{M}\left( t \right) =&\ {{k}_{i}}{{f}^{3}}_{i}\left( t \right) D_{i}^{M}\left( t \right) = \frac{{{k}_{i}}{{f}^{3}}_{i}\left( t \right) }{u_{i}^{M}\left( 1-l_{i}^{M}\left( t \right) \right) -p_{i}^{M}\left( t \right) {{A}_{i}}\left( t \right) }. \end{aligned} \end{aligned}$$
(2)

Nevertheless, if some of the requests cannot be executed due to lack of energy, they have to be dropped. We define a cost coefficient \({\mu }_{i}\) for the task drop, and accordingly the punishment cost for MD i at time slot t can be expressed as follows:

$$\begin{aligned} C_{i}^{D}\left( t \right) ={{\mu }_{i}}p_{i}^{D}\left( t \right) {{A}_{i}}\left( t \right) \tau . \end{aligned}$$
(3)

2.2 Uplink Transmission

The wireless network is assumed to be Orthogonal Frequency Division Multiplexing (OFDM)-based. The set of the subcarrier is denoted as \(\mathcal {K} =\left\{ 1,2\cdots ,k,\cdots ,K \right\} \), where \(\left| \mathcal {K} \right| =K\). The channels are assumed to be independent and identically distributed (i.i.d) block fading during time slots, i.e. the channels remain static within each time slot, but vary among different time slots. Let B denotes the channel bandwidth, \({N}_{0}\) denotes the noise power spectral density at the AP, \({h}_{i,k}( t )\) denotes the channel gain and \({p}_{i,k}(t)\) denotes the transmit power of MD i on subcarrier k at time slot t which cannot exceed its maximum value of \({{p}_{i,\max }}\). Define \({\rho }_{i,k}( t )\in \{ 0,1 \}\) as the subcarrier assignment indicator, where \({\rho }_{i,k}( t)=1\) indicates that the subcarrier k is assigned to MD i at time slot t. Otherwise, \({\rho }_{i,k}( t )=0\). Correspondingly, the uplink data rate \({r}_{i,k}( t )\) of MD i on subcarrier k at time slot t is expressed as follows:

$$\begin{aligned} {{r}_{i,k}}\left( t \right) ={{\rho }_{i,k}\left( t \right) }B{{\log }_{2}}\left( 1+\frac{{{p}_{i,k}}\left( t \right) {{h}_{i,k}}\left( t \right) }{{{N}_{0}}B} \right) . \end{aligned}$$
(4)

In this work, we consider one subcarrier can only be assigned to one MD to avoid transmission interference, while one MD can be assigned several subcarriers. The total uplink data rate for MD i at time slot t is denoted as follows:

$$\begin{aligned} {{R}_{i}}\left( t \right) =\sum \limits _{k\in \mathcal {K}}{{{\rho }_{i,k}}\left( t \right) B{{\log }_{2}}\left( 1+\frac{{{p}_{i,k}}\left( t \right) {{h}_{i,k}}\left( t \right) }{{{N}_{0}}B} \right) }. \end{aligned}$$
(5)

Correspondingly, we can obtain the uplink transmission time \(D_{i}^{up} ( t )\), as follows:

$$\begin{aligned} \begin{aligned} D_{i}^{up}\left( t \right) = \frac{p_{i}^{F}\left( t \right) {{A}_{i}}\left( t \right) {{\theta }_{i}}\tau }{\sum \limits _{k\in \mathcal {K} }{{{\rho }_{i,k}}\left( t \right) B{{\log }_{2}}\left( 1+\frac{{{p}_{i,k}}\left( t \right) {{h}_{i,k}}\left( t \right) }{{{N}_{0}}B} \right) }}. \end{aligned} \end{aligned}$$
(6)

Then the energy consumption \(E_{i}^{up} ( t )\) of the uplink transmission can be given as follows:

$$\begin{aligned} \begin{aligned} E_{i}^{up}\left( t \right) = \sum \limits _{k\in \mathcal {K}}{\frac{{{\rho }_{i,k}}\left( t \right) {{p}_{i,k}}\left( t \right) p_{i}^{F}\left( t \right) {{A}_{i}}\left( t \right) {{\theta }_{i}}\tau }{\sum \limits _{k\in \mathcal {K} }{{{\rho }_{i,k}}\left( t \right) B{{\log }_{2}}\left( 1+\frac{{{p}_{i,k}}\left( t \right) {{h}_{i,k}}\left( t \right) }{{{N}_{0}}B} \right) }}}. \end{aligned} \end{aligned}$$
(7)

2.3 Fog Execution Model

The EN connecting to the AP can process the offloaded requests and execute the computation task. We consider the connection between the EN and AP is fiber-based with large enough bandwidth and the transmission time from the AP to EN is ignored. We denote the service rate of the EN as \({u}^{F}\). The pending requests of the MDs are pooled together with a total rate \({A}_{total}( t )\) which also follows the Poisson process. Therefore, \({A}_{total}( t)\) is given as follows:

$$\begin{aligned} {{A}_{total}}\left( t \right) =\sum \limits _{i\in \mathcal {N}}{p_{i}^{F}\left( t \right) {{A}_{i}}\left( t \right) }. \end{aligned}$$
(8)

We denote the workload of the EN as \({l}^{F}(t)\), which presents the occupied percentage of each server and \( {l}^{F}( t) < 1\). As a M/G/1 queue is considered at the EN, the average response time \({D}^{F}( t )\) is given as follows [9]:

$$\begin{aligned} {{D}^{F}}\left( t \right) =\frac{2{{u}^{F}}\left( 1-{{l}^{F}}\left( t \right) \right) -\left( \sum \limits _{i\in \mathcal {N}}{{{A}_{i}}\left( t \right) \ p_{i}^{F}\left( t \right) } \right) }{2{{u}^{F}}\left( 1-{{l}^{F}}\left( t \right) \right) \left[ {{u}^{F}}\left( 1-{{l}^{F}}\left( t \right) \right) -\left( \sum \limits _{i\in \mathcal {N}}{{{A}_{i}}\left( t \right) \ p_{i}^{F}\left( t \right) } \right) \right] }. \end{aligned}$$
(9)

2.4 Energy Harvesting Model

To model the energy harvesting, a successive energy packet arrival model is considered. The arrival of energy packet follows a Poisson process with an average arrival rate \({e}_{i}( t)\), and \(0<{e}_{i}( t )\le e_{i}^{\max }( t )\) where \(e_{i}^{\max }( t )\) is the maximum energy arrival rate in each time slot. The harvested energy is stored in the battery and will be available for further actions. We denote the battery energy level of MD i at the beginning of time slot t as \({B}_{i}(t)\). In this work, energy consumed for purposes other than local computation and transmission is ignored for simplicity. The energy consumption \({E}_{i,total}( t )\) of MD i consists of two parts:

$$\begin{aligned} {{E}_{i,total}}\left( t \right) =E_{i}^{M}\left( t \right) +E_{i}^{up}\left( t \right) . \end{aligned}$$
(10)

where \(E_{i}^{M}\left( t \right) \) is the energy consumption for local processing and \(E_{i}^{up}\left( t \right) \) is energy consumption for delivering the requests. Note that \({E}_{i,total}( t )\) should be smaller than the battery level, i.e., \( {E}_{i,total}\left( t \right) \le {{B}_{i}}\left( t \right) \). Thus, the battery level of MD i evolves as follows,

$$\begin{aligned} {{B}_{i}}\left( t+1 \right) ={{B}_{i}}\left( t \right) -{{E}_{i,total}}\left( t \right) +{{e}_{i}}\left( t \right) . \end{aligned}$$
(11)

3 Problem Formulation

The execution cost consists of the execution delay and the task dropping punishment cost. The execution delay \({D}_{i}( t )\) at time slot t is derived as follows:

$$\begin{aligned} {D}_{i}( t )=p_{i}^{M}\left( t \right) D_{i}^{M}\left( t \right) +p_{i}^{F}\left( t \right) \left( D_{i}^{up}\left( t \right) +{{D}^{F}}\left( t \right) \right) . \end{aligned}$$
(12)

Consequently, the execution cost for MD i can be formulated as follows:

$$\begin{aligned} {{EC}_{i}}\left( t \right) ={{D}_{i}}\left( t \right) +{{\alpha }_{i}} C_{i}^{D}\left( t \right) , \end{aligned}$$
(13)

where \({\alpha }_{i}\) is the weight of task dropping cost. The total weighted execution cost of the system at time slot t is denoted as \({\varGamma }_{total}( t )\), which is given as

$$\begin{aligned} \begin{aligned}&{{\varGamma }_{total}}\left( t \right) \ =\sum \limits _{i\in \mathcal {N}}{{{\omega }_{i}}}\left[ p_{i}^{M}\left( t \right) D_{i}^{M}\left( t \right) +p_{i}^{F}\left( t \right) \left( D_{i}^{up}\left( t \right) +{{D}^{F}}\left( t \right) \right) +{{\alpha }_{i}} C_{i}^{D}\left( t \right) \right] ,\\ \end{aligned} \end{aligned}$$
(14)

where \({\omega }_{i}\) is the weight factor, which reflects the relative importance of MD i. Then we derive the average execution cost \(\varPhi \left( t \right) \) of the edge computing system during T time slots, which is given in (15).

$$\begin{aligned} \begin{aligned}&\varPhi \left( t \right) = \underset{T\rightarrow +\infty }{\mathop {\lim }}\,\frac{1}{T}\sum \limits _{t\in \mathcal {T}}{WE{{C}_{total}}\left( t \right) }\\&= \underset{T\rightarrow +\infty }{\mathop {\lim }}\,\frac{1}{T}\sum \limits _{t\in \mathcal {T}}{\sum \limits _{i\in \mathcal {N}}{{{\omega }_{i}}}\left[ p_{i}^{M}\left( t \right) D_{i}^{M}\left( t \right) +p_{i}^{F}\left( t \right) \left( D_{i}^{up}\left( t \right) +{{D}^{F}}\left( t \right) \right) +{{\alpha }_{i}} C_{i}^{D}\left( t \right) \right] }. \end{aligned} \end{aligned}$$
(15)

We denote the system decision at time slot t as \(\mathbf{V} ( t )=\left[ \mathbf{p }( t ),\varvec{\rho } ( t),\varvec{{p}}_{up}( t ) \right] \), \(\forall t\in \mathcal {T}\), where \(\mathbf{p} (t)=\left[ \mathbf{p _{1}}( t),\cdots ,\mathbf{p _{i}}( t ),\cdots \mathbf{p _{N}}( t ) \right] \) are execution strategies for all the MDs at time slot t and \(\mathbf{p _{i}}( t )=\left[ p_{i}^{M}( t ),p_{i}^{F}( t ), p_{i}^{D} ( t )\right] \) is the execution strategy for MD i at time slot t. \(\varvec{\rho }( t )=\left[ {{\varvec{\rho }}_{1}}( t),\cdots ,{{\varvec{\rho } }_{i}}( t ),\cdots ,{{\varvec{\rho } }_{N}}( t) \right] \) is the subcarrier assignment matrix for all MDs at time slot t and \({{\varvec{\rho } }_{i}}( t)=\left[ {{\rho }_{i,1}}( t ),\cdots ,{{\rho }_{i,k}}( t ),\cdots ,{{\rho }_{i,K}}( t )\right] \) is the subcarrier assignment vector for MD i at time slot t. \({\varvec{{p}}_{up}}( t )=\left[ {\varvec{{p}}_{1}}( t ),\cdots ,{\varvec{{p}}_{N}}( t ) \right] \) is the uplink transmit power matrix for all the MDs at time slot t and \({\varvec{{p}}_{i}}( t )=\left[ {{p}_{i,1}}( t ),\cdots ,{{p}_{i,K}}( t )\right] \) is the set of transmit power for MD i. Thus, the problem can be formulated as shown in P1, which is

$$\begin{aligned} \mathbf{P}1 : \underset{\varvec{V}\left( t \right) }{\mathop {\min }}\,\ \varPhi \left( t \right) , \end{aligned}$$
(16)

s.t.

$$\begin{aligned} p_{i}^{M}\left( t \right) \text {+}p_{i}^{F}\left( t \right) \text {+}p_{i}^{D}\left( t \right) =1, 0\le p_{i}^{M}\left( t \right) ,p_{i}^{F}\left( t \right) ,p_{i}^{D}\left( t \right) \le 1; \end{aligned}$$
(17a)
$$\begin{aligned} p_{i}^{M}\left( t \right) {{A}_{i}}\left( t \right) -u_{i}^{M}\left( 1-l_{i}^{M}\left( t \right) \right) <0; \end{aligned}$$
(17b)
$$\begin{aligned} \sum \limits _{i\in \mathcal {N}}{p_{i}^{F}\left( t \right) }{{A}_{i}}\left( t \right) -{{u}^{F}}\left( 1-{{l}^{F}}\left( t \right) \right) <0; \end{aligned}$$
(17c)
$$\begin{aligned} 0<{{p}_{i,k}}\left( t \right) <{{p}_{i,\max }}; \end{aligned}$$
(17d)
$$\begin{aligned} \sum \limits _{i\in \mathcal {N}}{{{\rho }_{i,k}}}\left( t \right) \le 1,\ \ {{\rho }_{i,k}}\in \left\{ 0,1 \right\} ; \end{aligned}$$
(17e)
$$\begin{aligned} {{E}_{i,total}}\left( t \right) \le {{B}_{i}}\left( t \right) ; \end{aligned}$$
(17f)
$$\begin{aligned} i\in \mathcal {N},t\in \mathcal {T}, k\in \mathcal {K}. \end{aligned}$$
(17g)

As we can see, the MDs’ decisions are coupled among different time slots due to the constraints (17f), which makes the problem difficult to be tackled. As presented in [5], by introducing a reasonable upper bound \(E_{i}^{\max }(t)\) and a non-negative lower bound \(E_{i}^{\min } (t)\) of the battery, the coupling effect is eliminated. Correspondingly, the system operation can be optimized by ignoring (17f). Thus, the problem can be modified as follows:

$$\begin{aligned} \mathbf{P}1 : \underset{\varvec{V}\left( t \right) }{\mathop {\min }}\,\ \varPhi \left( t \right) \end{aligned}$$
$$\begin{aligned} (17a)-(17e),(17g) \end{aligned}$$
(18)
$$\begin{aligned} {{E}_{i,total}}\left( t \right) \in \left[ E_{i}^{\min }\left( t \right) ,E_{i}^{\max }\left( t \right) \right] \end{aligned}$$
(19)

For simplify, we consider \(E_{i}^{\min } ( t ) = 0\). For \(\mathbf{P}1 \), a stochastic optimization problem is formulated with decision variables of the execution strategy, the uplink transmit power and the subcarrier assignment. By addressing the deterministic per-time slot problem, we can obtain the total optimal decisions in a stochastic manner.

4 Proposed Solution

Lyapunov optimization is an efficient framework for designing online control algorithm without requiring any prior knowledge [5]. In order to present the proposed solution, we firstly define the Lyapunov function as follows:

$$\begin{aligned} L\left( \varvec{B}\left( t \right) \right) =\frac{1}{2}\sum \limits _{i\in \mathcal {N}}{{{B}_{i}}^{2}\left( t \right) }, \end{aligned}$$
(20)

where \(\varvec{B} ( t )=\left[ {{B}_{1}} ( t ),\cdots ,{{B}_{i}} ( t ),\cdots {{B}_{N}} ( t ) \right] \). Thus, the conditional Lyapunov drift can be expressed as

$$\begin{aligned} \varDelta \left( \varvec{B}\left( t \right) \right) =E \left[ L\left( \varvec{B}\left( t+1 \right) \right) -L\left( \varvec{B}\left( t \right) \right) \left| \varvec{B}\left( t \right) \right. \right] . \end{aligned}$$
(21)

The Lyapunov drift-plus-penalty function can be given as follows:

$$\begin{aligned} {{\varDelta }_{V}}\left( \varvec{B}\left( t \right) \right) =\varDelta \left( \varvec{B}\left( t \right) \right) +V \mathcal {E} \left[ \varGamma _{total}\left( t \right) \left| \varvec{B}\left( t \right) \right. \right] , \end{aligned}$$
(22)

where \(V\in \left( 0, +\infty \right) \) is a control parameter. Then we will find an upper bound of \(\varDelta \left( \varvec{B}\left( t \right) \right) \) under any feasible set of \(\varvec{V}\left( t \right) \), which can be found in the following lemma.

Lemma 1. For any feasible set of \(\varvec{V}\left( t \right) \), which satisfies (18) and (19), the Lyapunov drift-plus-penalty function \({{\varDelta }_{V}}\left( \varvec{B}\left( t \right) \right) \) is upper bounded, i.e.,

$$\begin{aligned} \begin{aligned} \ \ \ {{\varDelta }_{V}}\left( \varvec{B}\left( t \right) \right)&\le \kappa +\sum \limits _{i\in \mathcal {N}}{\left\{ {{B}_{i}}\left( t \right) \left[ {{e}_{i}}\left( t \right) -{{E}_{i,total}}\left( t \right) \right] \right\} } \\ {}&+VE \left[ \varGamma _{total}\left( t \right) \left| \varvec{B}\left( t \right) \right. \right] , \\ \end{aligned} \end{aligned}$$
(23)

where \(\kappa \) is a constant, which is denoted as

$$\begin{aligned} \kappa =\sum \limits _{i\in N}{\left[ \frac{{{\left( e_{i}^{\max }\left( t \right) \right) }^{2}}+{{\left( E_{i}^{\max }\left( t \right) \right) }^{2}}}{2} \right] }. \end{aligned}$$
(24)

Due to the space limitation, we omit the proof here. The key idea of the proposed algorithm is to minimize the upper bound of \({{\varDelta }_{V}}\left( \varvec{B}\left( t \right) \right) \) in the right-hand side of (23). The proposed algorithm is displayed in Algorithm 1.

figure a

Due to the high complexity of the considered problem, in the next section, we will divide it into several sub-problems to obtain the optimal system decision.

4.1 Optimal Execution Strategy

Firstly, we seek the optimal execution strategy at each time slot t, while taking the other pending variables as constants, then the problem is translated into the following sub-problem \(\mathbf{SP}1 \), which is denoted as follows:

$$\begin{aligned} \underset{\varvec{p}\left( t \right) }{\mathop {\min }}\,\ \sum \limits _{i\in \mathcal {N}}{-{{B}_{i}}}\left( t \right) {{E}_{i,total}}\left( t \right) +V\sum \limits _{i\in \mathcal {N}}{{{\omega }_{i}}}\left[ {{D}_{i}}\left( t \right) +{{\alpha }_{i}} C_{i}^{D}\left( t \right) \right] \end{aligned}$$
(25)

s.t.

$$\begin{aligned} (17a) - (17g),(17g),(19) \end{aligned}$$

It can be found that (17c) is a coupled constraint, which includes various decision variables of different MDs. Similarly to the ones in [6], we can formulate the proposed problem as a Generalized Nash Equilibrium Problem (GNEP). The exponential penalty function method is applied to transform the original GNEP into a classical NEP and address it by semi-smooth Newton method with Armijo line search.

4.2 Optimal Power Allocation and Subcarrier Assignment

Similarly, the optimal transmit power \(\mathbf{{p} _{up}}\left( t \right) \) and subcarrier assignment matrix \(\varvec{\rho } ( t)\) can be obtained by solving the following sub-problem \(\mathbf{SP}2 \) through removing some irrelevant parameters from P2, which is denoted as follows:

$$\begin{aligned} \underset{\left\{ \varvec{\rho } \left( t \right) ,\varvec{p}\left( t \right) \right\} }{\mathop {\min }}\,\ \sum \limits _{i\in \mathcal {N}}{-{{B}_{i}}\left( t \right) E_{i}^{up}\left( t \right) }+V\sum \limits _{i\in \mathcal {N}}{{{\omega }_{i}}}p_{i}^{F}\left( t \right) D_{i}^{up}\left( t \right) , \end{aligned}$$
(26)

s.t.

$$\begin{aligned} 0<{{p}_{i,k}}\left( t \right) <{{p}_{i,\max }}, \end{aligned}$$
(27a)
$$\begin{aligned} \sum \limits _{i\in \mathcal {N}}{{{\rho }_{i,k}}}\left( t \right) \le 1,\ \ {{\rho }_{i,k}}\in \left\{ 0,1 \right\} , \end{aligned}$$
(27b)
$$\begin{aligned} E_{i}^{up}\left( t \right) <E_{i}^{\max }\left( t \right) , \end{aligned}$$
(27c)
$$\begin{aligned} i\in \mathcal {N}, k\in \mathcal {K}. \end{aligned}$$
(27d)

By substituting the specific expressions of \(E_{i}^{up}\left( t \right) \) and \(D_{i}^{up}\left( t \right) \) into the above problem, we can get an equal form of \(\mathbf{SP}{2} \), as shown in . The constraints are the same as those in (27). We can find that the is a mixed-integer programming problem, which involves the joint optimization of both continuous variables \({{p}_{i,k}}\left( t \right) \) and integer variables \({{\rho }_{i,k}}\left( t \right) \). Next, we will propose an algorithm to solve the problem. Firstly, we introduce an average offloading priority function [7], and it is defined as follows:

(28)
(29)

where the constant \({{v}_{i}}\left( t \right) \) is defined as \({{v}_{i}}\left( t \right) =\frac{B{{h}_{i,k}}\left( t \right) \tau c_{0}}{{{N}_{0}}\ln 2}\) and \(c_{0}\) is a pre-defined constant. Specifically, with the defined average offloading priority function \({{\psi }_{i,k,t}}\left( {{\omega }_{i}},\tau ,{{h}_{i,k}}\left( t \right) \right) \) (for simplify, we assume that any two values of \({{\psi }_{i,k,t}}\left( {{\omega }_{i}},\tau ,{{h}_{i,k}}\left( t \right) \right) \) are not the same), we denote the offloading priority order as \(\varPsi \left( t \right) \) at time slot t, which is composed by \(\left\{ {{\psi }_{i,k,t}} \right\} ,i\in \mathcal {N},k\in \mathcal {K} \), and displayed in the descending manner. We denote the sets of assigned and unassigned subcarriers as \({\mathcal {K}_{1}}\left( t \right) \) and \({\mathcal {K}_{2}}\left( t \right) \) at the beginning of time slot t. The average channel gain \({{\tilde{h}}_{i}}\left( t \right) \) is defined as \({{\tilde{h}}_{i}}\left( t \right) =\frac{\sum \limits _{k\in { \mathcal {K}_{2}\left( t \right) }}{{{h}_{i,k}}\left( t \right) }}{ \left| {\mathcal {K}_{2}}\left( t \right) \right| }\), where \(\left| {\mathcal {K}_{2}}\left( t \right) \right| \) is the number of unassigned subcarriers during the time slot t. For each MD, such as MD i, the assigned subcarrier set is denoted as \({\mathcal {Z}_{i}}\left( t \right) \) during the time slot t, initialized as \({\mathcal {Z}_{i}}\left( t \right) =\varnothing \). Additionally, the subcarrier assignment indicators are set as \(\left\{ {{\rho }_{i,k}}\left( t \right) =0 \right\} \) at the beginning of time slot t. By these definitions, we proposed a subcarrier allocation algorithm, which is displayed in Algorithm .

figure b

In the proposed algorithm, we need to find the optimal power allocation, which involves addressing the following , which is

(30)

s.t.

$$\begin{aligned} \sum \limits _{i\in \mathcal {N}}{{{n}_{i}}\left( t \right) }\le \left| {\mathcal {K}_{2}}\left( t \right) \right| , \end{aligned}$$
(31a)
$$\begin{aligned} {{\tilde{p}}_{i}}\left( t \right) \le {{p}_{i,\max }}, \end{aligned}$$
(31b)
$$\begin{aligned} \frac{{{{\tilde{p}}}_{i}}\left( t \right) p_{i}^{F}\left( t \right) {{A}_{i}}\left( t \right) {{\theta }_{i}}\tau }{B{{\log }_{2}}\left( 1+\frac{{{{\tilde{p}}}_{i}}\left( t \right) {{{\tilde{h}}}_{i}}\left( t \right) }{{{N}_{0}}B} \right) }\le E_{i}^{\max }\left( t \right) , \end{aligned}$$
(31c)

where \({{n}_{i}}\left( t \right) \) is the total integer number of subcarriers that allocated to MD i at time slot t. We can also find that is a mixed integer programming including a coupled constraint (31a). Thus, we can address it with semi-smooth Newton method, which is similar with [6]. Then with the branch-and-bound procedure, we can obtain the integer solution \({n}_{i}^{*}\left( t \right) \).

We denote the set of MDs that still require subcarriers as \(\tilde{\mathcal {N}}\), where \(\tilde{\mathcal {N}}=\left\{ i\left| {n}_{i}^{*}\left( t \right) >0 \right. \right\} \). We allocate subcarriers for each MD with the highest offloading priority principle. After searching for the highest offloading priority \({{\psi }_{{i}',{k}',t}}\) over unassigned subcarriers \({\mathcal {K}_{2}}\left( t \right) \) for the remaining offloading-required users \(\tilde{\mathcal {N}}\) and then allocates subcarrier \({k}'\) to user \({i}'\). Such a sequential subcarrier assignment follows the descending offloading priority order. Then the remaining sets can be updated until all subcarriers are assigned. At last, the optimal transmit power for MD i at time slot t over the assigned subcarriers \({\mathcal {Z}_{i}}\left( t \right) \) is obtained by minimizing the problem SP2”’

(32)

s.t.

$$\begin{aligned} 0<{{p}_{i,{k}'}}\left( t \right) \le {{p}_{i,\max }}, {k}'\in {\mathcal {Z}_{i}\left( t \right) }, \end{aligned}$$
(33a)
$$\begin{aligned} \sum \limits _{{k}'\in {\mathcal {Z}_{i}}\left( t \right) }{\frac{{{p}_{i,{k}'}}\left( t \right) p_{i}^{F}\left( t \right) {{A}_{i}}\left( t \right) {{\theta }_{i}}\tau }{\sum \limits _{{k}'\in {\mathcal {Z}_{i}}\left( t \right) }{B{{\log }_{2}}\left( 1+\frac{{{p}_{i,{k}'}}\left( t \right) {{h}_{i,{k}'}}\left( t \right) }{{{N}_{0}}B} \right) }}}\le E_{i}^{\max }\left( t \right) , \end{aligned}$$
(33b)

We can see that the formulated problem is similar with the problem investigated in [2]. Then, we can solve it with Interior Point Method (IPM), the details of which can be found in [2].

5 Performance Evaluations

In this section, extensive simulations are conducted to illustrate the effectiveness of the proposed algorithm. The simulation parameters are similar to the one used in [2] and [6]. First, we illustrate the relationship of the average execution cost of the system versus the number of subcarriers with 6 MDs in Fig. 1. It can be observed that with the optimal subcarrier allocation strategy, the average execution cost of the system is the smallest among all three schemes. Moreover, as shown in this figure, with the increasing of the number of subcarriers, the average execution cost becomes smaller, as the MDs have sufficient choices to offload the requests to the EN to reduce the execution delay. In this way, the dropped requests would also be reduced.

Fig. 1.
figure 1

The effect of subcarrier allocation

Fig. 2.
figure 2

The effect of the number of MDs

Then we show the total execution cost of the system versus the number of MDs in the system when the number of subcarriers is fixed in Fig. 2. It can be observed that the average execution costs are increasing when the number of MDs increases, which means that the execution delay or the punishment cost become larger under the condition of fixed number of subcarriers. As more and more users compete for the radio and computational resources with each other, longer transmission time and fog execution delay can be induced. Thus, the MDs have to execute more requests locally or drop them, which leads to a larger execution cost.

6 Conclusion

In this paper, we propose a dynamic optimization scheme for an edge computing system with multiple users, where the radio and computational resources, and offloading decisions, can be dynamically allocated with the variation of computation demands, radio channels and the computation resources. Specifically, with the objective to minimize the energy consumption of the considered system, we propose a joint computation offloading, radio and computational resource allocation algorithm based on Lyapunov optimization. Through minimizing the derived upper bound of the Lyapunov drift-plus-penalty function, the main problem is divided into several sub-problems at each time slot and are addressed separately. The simulation results demonstrate the effectiveness of the proposed scheme.