# Resource Allocation in Wireless Powered IoT System: A Mean Field Stackelberg Game-Based Approach
## 4 Game Analysis and Implementation Algorithm  
### Mean Field Control of Sensor Nodes  
In this section, we will try to get the mean field control solutions for the SNs, based on an energy transfer power strategy of the HAP. First, the local optimal control of each sensor node can be considered as a dynamic game and the open-loop and state feedback solutions will be given based on the [PERSON]'s dynamic programming principle. Then we will extend the size of the IoT system, and use the strong law of large numbers (SLLN) to get the mean field control solution for all the SNs, then each sensor node can obtain the distributed equilibrium solution based on the mean field control solution. For each SN, it always constitutes an \(\varepsilon\)-Nash equilibrium for any control strategy of the HAP, which gives out the optimality of the optimal control problem for each SN, and is given as follows. **Definition 1** (\(\varepsilon\)-Nash equilibrium): _Given an energy transfer power strategy of the HAP, which is denoted by \(p_{0}\), for each sensor node \(\{i,1\leq i\leq N\}\), it constitutes an \(\varepsilon\)-Nash equilibrium, if there exists \(\varepsilon\geq 0\) such that \(\int_{i}^{N}\big{(}\overline{p}_{i},\overline{p}_{-i},p_{0}\big{)}\leq\inf_{p _{i}\in\mathcal{U}_{i}(p_{0})}\int_{i}^{N}\big{(}p_{i},\overline{p}_{-i},p_{0 }\big{)}+\varepsilon\), for all \(i,1\leq i\leq N\)._  
**Proposition 1**: _For the sensor node \(\{i,1\leq i\leq N\}\), a set of controls \(\big{(}x_{i}^{*},p_{i}^{*}\big{)}\)constitutes an open loop equilibrium to the power control problem in Equations (2) and (6), and the optimal control solution can be given by:_  
\[p_{i}^{*}(t)=-v_{i}^{-1}\beta_{i}\lambda_{i}(t)-v_{i}^{-1}\eta_{i}p_{0}(t) \tag{7}\]  
_subject to:_  
\[ \begin{array}{l}dx_{i}^{*}(t)=\Big{[}\alpha_{i}x_{i}^{*}(t)+\beta_{i}\Big{(} -v_{i}^{-1}\beta_{i}\lambda_{i}(t)-v_{i}^{-1}\eta_{i}p_{0}(t)\Big{)}+\rho_{i} h_{i}p_{0}(t)\Big{]}dt\\ =\Big{[}\alpha_{i}x_{i}^{*}(t)-v_{i}^{-1}\beta_{i}^{2}\lambda_{i}(t)-v_{i}^{-1 }\beta_{i}\eta_{i}p_{0}(t)+\rho_{i}h_{i}p_{0}(t)\Big{]}dt\end{array}  \tag{8}\]  
_where \(x_{i}^{*}(0)=x_{i}(0)\). \(\lambda_{i}(t)\) is a costate function with \(\lambda_{i}(T)=0\)and can be given by the following differential equation:_  
\[d\lambda_{i}(t)=[-\mu_{i}(x_{i}^{*}(t)-H_{i}z(t))-\alpha_{i}\lambda_{i}(t)]dt \tag{9}\]  
_and:_  
\[z(t)=x^{N}(t)=(1/N)\sum_{i=1}^{N}x_{i}(t)\]  
**Theorem 1**: _The optimal control problem has a unique solution._  
**Proof. ** The corresponding optimal solution for the SN \(\{i,1\leq i\leq N\}\) in Equation (7) is given by the Hamilton Jocabi Bellman (HJB) equation, based on the following equation:  
\[L_{i}(p_{i},x_{i})=\mu_{i}\Big{(}x_{i}(t)-H_{i}x^{N}(t)\Big{)}^{2}+v_{i}(p_{i} (t))^{2}+\eta_{i}p_{0}(t)p_{i}(t)+\lambda_{i}(t)[\alpha_{i}x_{i}(t)+\beta_{i}p _{i}(t)+\rho_{i}h_{i}p_{0}(t)] \tag{10}\]Then the optimal control problem has a unique solution, which is given by:  
\[p_{i}^{*}(t)=\partial L_{i}(p_{i},x_{i})/\partial p_{i}(t) \tag{11}\]  
In Equations (7)-(9), we can find that under the mean field game analysis framework, the corresponding optimal solution for each sensor node can be affected by the mass behaviors of all the sensors. The corresponding optimal solutions can be considered as the mean field game Nash equilibrium control strategies. \(\square\)  
**Proposition 2**. : _For each sensor node, the state feedback control equilibrium is given by:_  
\[p_{i}^{*}(t)=\
u_{i}^{-1}\beta_{i}V(t)x_{i}^{*}(t)-\
u_{i}^{-1}\beta_{i}\phi_{ i}(t)-\
u_{i}^{-1}\eta_{i}p_{0}(t) \tag{12}\]  
_where \(V(t)\)is the value function which will be given later. We call Equation (7) or (12) is the optimal localized power strategy of the sensor node if information transmission, because the optimal power strategy is a function of the local information and the strategy of the HAP.