# Resource Allocation in Wireless Powered IoT System: A Mean Field Stackelberg Game-Based Approach
## 4 Game Analysis and Implementation Algorithm
### Mean Field Control Algorithm  
In this subsection, we will discuss the implementation algorithm for the proposed model. As shown in Figure 4, the whole algorithm cycling can be divided into two parts. One is the \"mean field control of sensor nodes\" part, which is used to calculate the equilibrium for the sensor nodes. The other is the \"mean field control of HAP\" part, to make a decision on the power level for energy transfer. As all the objective functions given in the mean field control process are linear quadratic functions, and the solutions should be solved based on the Stackelberg game framework, the complexity of the algorithm will be \(O\big{(}n^{2}\big{)}\). The progress can be described as follows. ```
1 Set up the parameter for the HAP and sensor nodes. 2 The HAP announce the power strategy for energy transfer to the sensor nodes. 3 Start the mean field game of the HAP and sensor nodes. 4 Calculate the mean field control solutions for the sensor nodes first. 5 Setup the objective function and state function for the sensor nodes. 6 Calculate the solutions for the sensor nodes based on Equations (12)-(18). 7 Get the mean field estimation of the sensor nodes for the HAP. 8 Calculate the mean field control solutions for the HAP. 9 Setup the objective function and state function for the HAP. 10 Calculate the solutions for the HAP based on Equations (31)-(37). 11 End. ## 5 Performance Evaluation

In this section, we provide simulation results to illustrate the convergence property and effectiveness of the proposed model. Assuming all the sensor nodes are uniform sensor node, that have the same parameter settings. Each sensor wants to control the power level for information transmission to minimize the cost given in Equation (5). The mean field control solutions introduced in Sections 3 and 4 are simulated. Figure 5 shows the optimal variations of the energy state for the sensor node, with the power level for energy transfer are set to be 50 W, 100 W, 150 W, and 200 W, respectively. In Figure 4(a), the power level for energy transfer is set to be 50 W, the energy state of the sensor node can be increased from the initial energy state to a higher energy state with energy transfer. When we increase the power level of the HAP for energy transfer in Figure 4(b)-d, the final energy state will be increased. The higher of the transfer energy, the higher of the achieved energy state. The sensor node can have much more energy stored in its battery with higher energy from the HAP. Related to the energy state, the power level for information transmission for each sensor node is given in Figure 6. With the increasing of the transferred energy, there will be more power for the sensor node to transmit information. When the power level of HAP for energy transfer is 50 W, shown in Figure 5(a), the sensor node will increase the power level for information transmission at the first 6 s. It will decrease the power level to have more energy available at the next 4 s. The power level for the information transmission can achieve convergence when the power level for energy transfer is large than 50 W.

The variation of the mean filed term, the mass behavior of the sensor nodes is given in Figure 7. Figure 8 shows the variation of the energy state of the HAP. As the HAP is the energy source for the sensor nodes, its energy will decrease with the time duration. Figure 4: Implementation algorithm. Figure 5: Variations of energy state with different transfer power. (**a**) Power transfer = 50 W; (**b**) power transfer = 100 W; (**c**) power transfer = 150 W; and (**d**) power transfer = 200 W.

Figure 6: The power level for information transmission.