# Jointly Optimize the Residual Energy of Multiple Mobile Devices in the MEC-WPT System
## 5 Problem Solving
### Through the Lagrange Method and KKT Conditions to Find the Optimal Solution Properties  
Constructing a Lagrangian function usually adds all constraints to the objective function, thereby transforming the constraint problem into an unconstrained problem. However, in this construction process, we only consider most constraints but not all constraints. Let \(u_{i}=[u_{1},u_{2},\ldots,u_{N}]\succ 0\), \(\lambda_{i}=[\lambda_{1},\lambda_{2},\ldots,\lambda_{N}]\succ 0\), \(v_{i,j}=[[v_{1,1},v_{1,2},\ldots,v_{1,M}],[v_{2,1},v_{2,2},\ldots,v_{2,M}], \ldots,[v_{N,1},v_{N,2},\ldots,v_{N,M}]]\succ 0\) and \(w_{i,j}=[[w_{1,1},w_{1,2},\ldots,w_{1,M}],[w_{2,1},w_{2,2},\ldots,w_{2,M}], \ldots,[w_{N,1},w_{N,2},\ldots,w_{N,M}]]\succ 0\) represents the corresponding Lagrange multiplier. The partial Lagrange function of question P4 is defined as:  
\[\begin{split}& L(R,t,u,v,w,\lambda)=\sum_{i=1}^{N}\sum_{j=1}^{M}f( i,j)\sum_{i=1}^{M}t_{i,j}^{off}+\frac{\kappa_{j}((R_{i,j}-R_{i,j}^{off})C_{j})^{3}}{T^{2} }+\frac{t_{i,j}^{off}}{t_{i,j}^{off}}f(\frac{R_{i,j}^{off}}{t_{i,j}^{off}})+P_ {m,j}t_{im,j}^{off}\\ &+\sum_{i=1}^{N}u_{i}(\sum_{j=1}^{M}R_{i,j}C_{j}-F)+\sum_{i=1}^{N }\sum_{j=1}^{M}v_{i,j}(R_{i,j}-R_{i,j}^{off})+\sum_{i=1}^{N}\sum_{j=1}^{M}w_{i, j}(\frac{\kappa_{j}((R_{i,j}-R_{i,j}^{off})C_{j})^{3}}{T^{2}}\\ &+\frac{t_{i,j}^{off}}{h_{i,j}^{m}}f(\frac{R_{i,j}^{off}}{t_{i,j }^{off}})+P_{m,j}t_{im,j}^{off}-(f(i,j)T-f(i,j)\sum_{j=1}^{M}t_{i,j}^{off}))+ \sum_{i=1}^{N}\lambda_{i}(\sum_{j=1}^{M}t_{i,j}^{off}-T)\end{split} \tag{14}\]  
We supposed \((R^{*},t^{*})\) to represent the optimal solution of the \(P4\) problem, and \((u^{*},v^{*},w^{*},\lambda^{*})\) represents the optimal Lagrange multipliers. By applying the Karush-Kuhn-Tucker (KKT) condition, we get a relation about the optimal solution:  
\[\frac{L(R,t,u,v,w,\lambda)}{\partial t}=(1+w_{i,j}^{*})(f(i,j)+\frac{1}{h_{i,j }^{m}}f(\frac{R_{i,j}^{*}}{t_{i,j}^{*}})-\frac{1}{h_{i,j}^{m}}f(\frac{R_{i,j}^ {*}}{t_{i,j}^{*}})\frac{R_{i,j}^{*}}{t_{i,j}^{*}}+p_{m,j})+\lambda_{i}^{*}=where \(w_{i,j}^{*}\geq 0\) and \(\lambda_{i}^{*}=0\) we can get an equation:  
\[f(i,j)+\frac{1}{h_{ij}^{m}}f(\frac{R_{ij,j}^{*}}{t_{i,j}^{*}})-\frac{1}{h_{ij}^{m }}f^{\prime}(\frac{R_{ij,j}^{*}}{t_{i,j}^{*}}\frac{R_{ij}^{*}}{t_{i,j}^{*}}+p_{ m,j}=0 \tag{16}\]  
Let \(h(x)=\frac{1}{a}f(x)-\frac{1}{a}f^{\prime}(x)x\), where \(f^{\prime}(x)\) is the first-order derivative of \(f(x)\). \(h(x)\) is a monotonic decreasing function of \(x\geq 0\) with \(h(0)=0\). Given \(G<0\), there exists a unique positive solution for equation \(h(x)=G\), given by \(x^{*}=\frac{R}{\ln 2}[W_{0}(-\frac{aG}{N_{0}d_{i,j}}-\frac{1}{e})+1]\). \(W_{0}(x)\) is the main branch of the Lambert \(W\) function, which defines \(W_{0}(x)e^{W_{0}(x)}=x\), and \(e\) is the base of the natural logarithm [32]. Bring \(a=h_{i,j}^{m}\) and \(x^{*}=\frac{R_{ij,j}^{*}}{t_{i,j}^{*}}\), we get \(\frac{R_{ij,j}^{*}}{t_{i,j}^{*}}=\frac{B}{\ln 2}[W_{0}(-\frac{aG}{N_{0}d_{i,j}e}- \frac{1}{e})+1]\). Therefore, we have:  
\[t_{i,j}^{*}=\frac{R_{ij,j}^{*}\ln 2}{B[W_{0}(\frac{h_{i,j}^{m}(f(i,j)+p_{ m,j})}{N_{0}d_{i,j}e}-\frac{1}{e})+1]} \tag{17}\]