# Lyapunov-Guided Energy Scheduling and Computation Offloading for Solar-Powered WSN
## 3 Problem Formulation
### Problem Reformulation Based on Lyapunov Optimization Theory  
Considering the energy queue stability constraint of the solar-powered HAP, the energy and data queue stability constraint of each node, we define \(\mathbf{G}^{t}=\left[\mathbf{E}^{t},B^{\text{max}}-E_{S}^{t},\mathbf{Q}^{t}\right]\) to be the cascade vector, where \(\mathbf{E}^{t}=\left[E_{1}^{t},\ldots,E_{K}^{t}\right]\) and \(\mathbf{Q}^{t}=\left[Q_{1}^{t},\ldots,Q_{K}^{t}\right]\). It is known from Equations (1), (5) and (6) that the queue backlog length can be stabilized by optimizing the queue input and output quantities to satisfy constraints C7-C9 in problem P1. We use a quadratic Lyapunov function \(L[\mathbf{G}^{t}]\) to characterize the scalar of the queue backlog and define it as Equation (14). \[L[\mathbf{G}^{t}]=\frac{1}{2}\underset{k=1}{\overset{K}{\sum}}\left(E_{k}^{t} \right)^{2}+\frac{1}{2}\left(B^{\text{max}}-E_{S}^{t}\right)^{2}+\frac{1}{2} \underset{k=1}{\overset{K}{\sum}}\left(Q_{k}^{t}\right)^{2} \tag{14}\]  
Next, Lyapunov drift is used to characterize the variation of the queue backlog for different time slots, which can be expressed by Equation (15). \[ \begin{array}{l}\Delta L[\mathbf{G}^{t}]=L[\mathbf{G}^{t}]-L[\mathbf{G}^{t- 1}]\leq C^{t}+\underset{k=1}{\overset{|\mathcal{K}|}{\sum}}E_{k}^{t-1}\left( E_{k,har}^{t}-E_{k,con}^{t}\right)\\ +\underset{k=1}{\overset{|\mathcal{K}|}{\sum}}Q_{k}^{t-1}\left(D_{k}^{t}- \Phi_{k}^{t}\right)^{2}+\left(E_{S}^{t-1}-2B^{\text{max}}\right)\left(E_{S,har} ^{t}-E_{MEC}^{t}-P_{S}^{t}\tau_{0}\right)\end{array}  \tag{15}\]  
where \(C^{t}\) can be expressed by Equation (16). \[C^{t}=\frac{1}{2}\underset{k=1}{\overset{|\mathcal{K}|}{\sum}}\left(E_{k,con} ^{t}\right)^{2}+\frac{1}{2}\underset{k=1}{\overset{|\mathcal{K}|}{\sum}}\left( E_{k,har}^{t}\right)^{2}+\frac{1}{2}\underset{k=1}{\overset{|\mathcal{K}|}{ \sum}}\left(D_{k}^{t}\right)^{2}+\frac{1}{2}\underset{k=1}{\overset{| \mathcal{K}|}{\sum}}\left(\Phi_{k}^{t}\right)^{2}+\frac{1}{2}\left(P_{S}^{t} \tau_{0}\right)^{2}+\frac{1}{2}\left(E_{S,har}^{t}-E_{MEC}^{t}\right)^{2} \tag{16}\]  
Since the out and in of energy and data volumes in each queue are bounded, there exists a finite constant \(C\) so that the following property holds for all time and for all queues:  
\[\mathbb{E}\{\left.L[\mathbf{G}^{t}]-L[\mathbf{G}^{t-1}]\right|\mathbf{G}^{t}\}\leq C \tag{17}\]Then, the conditional expectation of Lyapunov drift satisfies Equation (18). \[ \begin{array}{l}\Delta L[\mathbf{G}^{t}]=\mathbb{E}\{\left.L[\mathbf{G}^{t}]-L[ \mathbf{G}^{t-1}]\right|\mathbf{G}^{t}\right\}\leq C+\sum\limits_{k=1}^{| \mathcal{K}|}E_{k}^{t-1}\mathbb{E}\{\left.E_{k,har}^{t}-E_{k,con}^{t}\right| \mathbf{G}^{t}\}\\ \\ +\sum\limits_{k=1}^{|\mathcal{K}|}Q_{k}^{t-1}\mathbb{E}\{\left.D_{k}^{t}- \Phi_{k}^{t}\right|\mathbf{G}^{t}\}+\left(E_{S}^{t-1}-2B^{\text{max}}\right) \mathbb{E}\{\left.E_{S,har}^{t}-E_{MEC}^{t}-P_{S}^{t}\tau_{0}\right|\mathbf{G} ^{t}\}\end{array}  \tag{18}\]  
To achieve system long-term average energy efficiency while stabilizing the network queue, we introduce adjustable weights V to balance queue stability and network energy efficiency, and construct the drift-minus-utility (DMU) function as shown in Equation (19)  
\[\Delta_{V}L[\mathbf{G}^{t}]=\Delta L[\mathbf{G}^{t}]-V\ \mathbb{E}\{\sum\limits_{k=1}^{K} \overline{\Phi}_{k}^{t}-\eta_{EE}^{t}\overline{E}_{total}^{t}\Bigg{|}\mathbf{ G}^{t}\} \tag{19}\]  
The upper bound \(\Delta_{V}L[\mathbf{G}^{t}]\) is derived from Theorem 1 when considering the relevance of power control, computational capacity management, and time scheduling. **Theorem 1**. : _The upper bound on the drift minus utility DMU function \(\Delta_{V}L[\mathbf{G}^{t}]\) is bounded by the following equation._  
\[