# Blockchain-Based UAV-Assisted Mobile Edge Computing for Dual Game Resource Allocation
## 3 Model of a Drone-Assisted Mobile Edge Computing System
### Utility Function Definition  
Taking into account the changing payment capabilities and needs of users and drones, the server controls the allocation of resources for each task by setting prices to find the optimal balance between revenue and cost and maximize server utility. The utility function of the server consists of two parts: total revenue and total resource maintenance cost. Specifically, the utility function of the server is shown in Equation (1). \[U_{server}\ =\sum_{i=1}^{N}\ p_{i}\cdot D_{i}-\sum_{i=1}^{N}C(D_{i}) \tag{1}\]  
Among them, \(\text{p}_{i}\) is the price set by the server for the ith task. \(\text{D}_{i}\) is the demand for the ith task. \(C(D_{i})\) is the resource maintenance cost of the ith task, \(C(D_{i})=\gamma\cdot D_{i}^{2}\) and \(\gamma\) is the possibility that the resources traded between the drone and the ECS can be written into a valid block. Taking into account the user's ability to pay and changes in demand, the UAV controls resource allocation and revenue for each task by setting the price of the service. The linear functional form of the energy cost rationally reflects the direct relationship between the energy required to provide the service and the demand. The utility function of the UAV consists of four parts: the total revenue that the UAV earns by providing the service, the total cost that it must pay to purchase computing resources from the server, the cost of the energy consumed, and the system reward obtained by completing a resource allocation. Among them, the total cost to be paid for purchasing computing resources from the server can directly affect its revenue, and the system reward can motivate the UAV to perform a large number of resource exchanges to improve resource utilization. In particular, the utility function of the UAV can be expressed by Equation (2). \[U_{UAV}=\sum_{i=1}^{N}s_{i}\cdot D_{i}-\sum_{i=1}^{N}p_{i}\cdot D_{i}-\sum_{i= 1}^{N}E(D_{i})+\sum_{i=1}^{N}R(D_{i}) \tag{2}\]  
where \(s_{i}\) is the service price set by the UAV for the ith task, and \(E(D_{i})\) is the energy cost of the ith task. \(E(D_{i})=\beta\cdot D_{i}^{2}\), \(\beta\) are the elasticity coefficients. \(R(D_{i})=\alpha\cdot D_{i}^{2}\), \(\alpha\) are the impact factors. The user's utility function describes the benefits and expenditures that the user receives in the process of using the services provided by the UAV, and consists of two parts: the user's valuation of each task in the process of using the UAV's services, and the fee paid to the UAV for each task. In this case, the user valuation can be determined based on the quality of the service, the urgency of the need, and other factors, and the fee paid to the drone reflects the user's utility or satisfaction with the service. Users will consider the cost of the service when choosing the service to ensure that the cost paid does not exceed the utility gained, and find the best balance between the valuation and the cost paid by optimizing the demand to maximize their total utility. Specifically, the user's utility function can be expressed in Equation (3). \[U_{User}\ =\sum_{i=1}^{N}\left(v_{i}\cdot D_{i}-s_{i}\cdot D_{i}\right) \tag{3}\]  
In the resource allocation problem, we model the relationship between the server (ECS) and the UAV as a leader-follower structure. The server acts as a leader; the server has more computational resources and decision-making power, and is able to set the price of resources and control the resource allocation strategy. The UAVs act as followers, and the UAVs need to decide their resource requirements and service prices based on the prices and strategies set by the server. The server's goal is to maximize its utility function, which can be expressed in Equation (4). \[\underset{p_{i}}{max}\ U_{Server}\ =\underset{p_{i}}{max}\ \sum_{i=1}^{N}\ (p_{i}\cdot D_{i}-C_{i}) \tag{4}\]  
The goal of the UAV is to maximize its utility function, which can be expressed in Equation (5).