# Resource Allocation in Wireless Powered IoT System: A Mean Field Stackelberg Game-Based Approach
## 4 Game Analysis and Implementation Algorithm
### Mean Field Control of HAP  
In this section, we will analyze the mean field control problem for the HAP, and try to obtain the optimal control strategy. The open-loop solution will be given and the mean field control solution can be obtained.  
**Definition 2**.: _For the HAP, the control strategy\(p_{0}^{*}(t)\) are optimal if the following inequality holds for all feasible controls\(p_{0}(t)\
eq p_{0}^{*}(t)\):_  
\[J_{0}^{N}\big{(}p_{0}^{*},p^{N}\big{)}\leq J_{0}^{N}\big{(}p_{0},p^{N}\big{)} \tag{24}\]  
**Proposition 4**.: _The HAP's optimal control problem is to minimize the following equation:_  
\[J_{0}^{N}\Big{(}p_{0},p^{N}\Big{)}=\mathrm{E}\!\left(\int_{0}^{T}\!\Big{\{} \mu_{0}(x_{0}(t)-H_{0}z(t))^{2}+\
u_{0}(p_{0}(t))^{2}\Big{\}}dt\right) \tag{25}\]  
_subject to:_  
\[dx_{0}(t)=[\alpha_{0}x_{0}(t)+\beta_{0}p_{0}(t)]dt \tag{26}\]  
\[dz(t)=\Big{[}\alpha_{i}z(t)+\beta_{i}\Big{(}-v_{i}^{-1}\beta_{i}\lambda(t)-v_{ i}^{-1}\eta_{i}p_{0}(t)\Big{)}+\rho_{i}h_{i}p_{0}(t)\Big{]}dt \tag{27}\]  
\[d\lambda(t)=[-\mu_{i}(z(t)-H_{i}z(t))-\alpha_{i}\lambda(t)]dt \tag{28}\]  
As the HAP is the leader in the proposed game model, and we should apply the Stackelberg game analysis to the proposed model, there exists two more constraints in the control of the HAP compared to the control of the sensor nodes, given by Equations (27) and (28). Based on the mean field control solutions given in Section 3, the constraints given by Equations (27) and (28) can be replaced by:  
\[dz(t)==\Big{[}\Big{(}\alpha_{i}+v_{i}^{-1}\beta_{i}^{2}V(t)\Big{)}z(t)-\beta_ {i}^{2}v_{i}^{-1}\phi(t)-\beta_{i}v_{i}^{-1}\eta_{i}p_{0}(t)+\rho_{i}h_{i}p_{0 }(t)\Big{]}dt \tag{29}\]  
\[d\phi(t)==\Big{[}-\Big{(}\alpha_{i}+\beta_{i}^{2}v_{i}^{-1}V(t)\Big{)}\phi(t) +\mu_{i}H_{i}z(t)-V(t)\beta_{i}v_{i}^{-1}\eta_{i}p_{0}(t)-\rho_{i}h_{i}p_{0}( t)\Big{]}dt \tag{30}\]  
**Proposition 5**.: _For the HAP, there exists an optimal control solution given by the pair \((x_{0}^{*},p_{0}^{*})\) if and only if_  
\[p_{0}^{*}(t)=-v_{0}^{-1}\beta_{0}\lambda_{0}(t)+v_{0}^{-1}\Lambda_{1}(t)\sum_ {i=1}^{N}\eta_{i}v_{i}^{-1}\beta_{i}-v_{0}^{-1}\Lambda_{2}(t)\sum_{i=1}^{N}\rho _{i}h_{i} \tag{31}\]_where:_  
\[dx_{0}(t) = \Bigg{[}\alpha_{0}x_{0}(t)-\
u_{0}^{-1}\beta_{0}^{2}\lambda_{0}(t)+ \
u_{0}^{-1}\beta_{0}\Lambda_{1}(t)\sum_{i=1}^{N}\eta_{i}\
u_{i}^{-1}\beta_{i}- \
u_{0}^{-1}\beta_{0}\Lambda_{2}(t)\sum_{i=1}^{N}\rho_{i}h_{i}\Bigg{]}dt \tag{32}\] \[d\lambda_{0}=[-\mu_{0}(x_{0}^{*}(t)-H_{0}z(t))-\alpha_{0}\lambda_ {0}(t)]dt\] (33) \[d\Lambda_{1} = \Bigg{[}\eta_{i}H_{0}(x_{0}^{*}(t)-H_{0}z(t))-\Lambda_{1}\sum_{i= 1}^{N}\alpha_{i}-\Lambda_{2}\sum_{i=1}^{N}\eta_{i}(H_{i}-1)\Bigg{]}dt\] (34) \[d\Lambda_{2} = \Bigg{[}\Lambda_{1}\sum_{i=1}^{N}\beta_{i}^{2}\
u_{i}^{-1}+ \Lambda_{2}\sum_{i=1}^{N}\alpha_{i}\Bigg{]}dt\] (35) \[dz(t) = \Bigg{[}\alpha_{i}z(t)-\
u_{i}^{-1}\beta_{i}^{2}\lambda_{i}(t)- \
u_{i}^{-1}\beta_{i}\eta_{i}\Bigg{[}\begin{array}{c}-\
u_{0}^{-1}\beta_{0 }\lambda_{0}(t)+\
u_{0}^{-1}\Lambda_{1}(t)\sum_{i=1}^{N}\eta_{i}\
u_{i}^{-1} \beta_{i}\\ -\
u_{0}^{-1}\Lambda_{2}(t)\sum_{i=1}^{N}\rho_{i}h_{i}\end{array}\Bigg{]} \begin{array}{c}\\ \end{array}\Bigg{]}dt\] (36) \[d\lambda(t) = [-\mu_{i}(z(t)-H_{i}z(t))-\alpha_{i}\lambda(t)]dt \tag{37}\]