# Blockchain-Based UAV-Assisted Mobile Edge Computing for Dual Game Resource Allocation
## 3 Model of a Drone-Assisted Mobile Edge Computing System
### DSO Algorithm Two-Stage Equalisation Analysis  
In a Stackelberg game, there is a leader (server) and followers (drones). Each has a different utility function: the leader's utility function depends on its own strategy and the followers' response strategies, while the followers' utility function depends on the leader's strategy and their own strategy. First, determine the follower's optimal response strategy after observing the leader's strategy. This is achieved by maximizing the follower's utility function. Differentiating and setting the derivative to zero solves for the follower's optimal response function,which indicates how the follower chooses the optimal strategy given the leader's strategy. After obtaining the follower's optimal response, the leader chooses the optimal strategy by maximizing its utility function. The leader's utility function depends on its own strategy and the follower's optimal response. The leader's optimal strategy is solved by differentiating the leader's utility function and setting the derivative to zero. Finally, the leader's optimal strategy is substituted into the follower's response function to obtain the follower's optimal strategy. At this point, the strategies of the leader and the follower form an equilibrium, which is the Stackelberg equilibrium solution. In this equilibrium, neither party can unilaterally change its strategy to increase its utility. So next, we will first analyze the utility function of the drone. The drone utility function can be expressed by Equation (10). \[U_{F_{i}}(s_{i},p,d_{i})=s_{i}\cdot d_{i}-p\cdot d_{i}-E(d_{i})+R(d_{i}) \tag{10}\]  
The robot will choose the demand \(\mathrm{d_{i}}\) that maximizes its utility. The optimization of \(\mathrm{d_{i}}\) can be expressed by Equation (11). \[\frac{\partial U_{F_{i}}}{\partial d_{i}}=s_{i}-p-E^{\prime}(d_{i})+R^{\prime} (d_{i})=0 \tag{11}\]  
Substituting the reward function \(R(D_{i})=\alpha\cdot D_{i}^{2}\) and the energy cost function \(E(D_{i})=\beta\cdot D_{i}^{2}\) gives Equation (12). \[\frac{\partial U_{F_{i}}}{\partial d_{i}}=s_{i}-p-2\beta d_{i}+2\alpha d_{i}=0 \tag{12}\]  
It can be found that the utility function of the drone is a convex function because of C. Substituting A into the utility function of the server gives Equation (13). \[U_{L}(p,d)=\sum_{i=1}^{N}p\cdot\frac{s_{i}-p}{2\beta-2\alpha}-\gamma\left( \sum_{i=1}^{N}\frac{s_{i}-p}{2\beta-2\alpha}\right)^{2} \tag{13}\]  
Simplification yields Equation (14). \[U_{L}(p,d)=\frac{p\cdot\sum_{i=1}^{N}\left(s_{i}-p\right)}{2\beta-2\alpha}- \gamma\left(\frac{\sum_{i=1}^{N}\left(s_{i}-p\right)}{2\beta-2\alpha}\right)^ {2} \tag{14}\]  
We optimize for p. Let \(\frac{\partial U_{i}}{\partial p}=0\), and let \(A=\sum_{i=1}^{N}s_{i}\). Then, we can get Equation (15). \[U_{L}(p,d)=\frac{p\cdot(A-Np)}{2\beta-2\alpha}-\gamma\left(\frac{A-Np}{2\beta -2\alpha}\right)^{2} \tag{15}\]  
Let \(f(p)=p\cdot(A-Np)-0.5\big{(}A-Np)^{2}\), \(\gamma=0.5\), we derive the Equation (16) for \(f(p)\). \[f^{\prime}(p)=\frac{\partial}{\partial p}\left(p\cdot(A-Np)-0.5\big{(}A-Np)^{ 2}\right) \tag{16}\]  
Let \(f^{\prime}(p)=0\), solve for \(p^{*}=\frac{A}{N-1}=\frac{\sum_{i=1}^{N}s_{i}}{N-1}\). Substituting \(p^{*}\) into the response function of the UAV gives \(d_{i}^{*}=\frac{s_{i}-\sum_{i=1}^{N}s_{i}}{2\beta-2\alpha}\). In summary, we can obtain the Stackelberg equilibrium solution between the server and the drone. The server first chooses its optimal price and then the drone chooses the optimal demand based on the server's price. This approach ensures an equilibrium resource allocation between the server and the drone, where the server maximizes its utility by setting the optimal price and the drone maximizes its utility by choosing the optimal demand in response to the server's price. To solve the Vickrey auction equilibrium solution, first set the valuation of the bidders and assume that each bidder i has a true valuation of the item. Each bidder chooses its bid price [39; 40; 41; 42; 43].