Energy-Efficient UAV-Enabled MEC System: Bits Allocation Optimization and Trajectory Design

The unmanned aerial vehicle (UAV) enabled mobile edge computing (MEC) system is attracting a lot of attentions for the potential of low latency and low transmission energy consumption, due to the advantages of high mobility and easy deployment. It has been widely applied to provide communication and computing services, especially in Internet of Things (IoT). However, there are still some challenges in the UAV-enabled MEC system. Firstly, the endurance of the UAV is limited and further impacts the performance of the system. Secondly, mobile devices are battery-powered and the batteries of some devices are hard to change. Therefore, in this paper, a UAV-enabled MEC system in which the UAV is empowered to have computing capability and provides tasks offloading service is studied. The total energy consumption of the UAV-enabled system, which includes the energy consumption of the UAV and the energy consumption of the ground users, is minimized under the constraints of the UAV’s energy budget, the number of each task’s bits, the causality of the data and the velocity of the UAV. The bits allocation of uploading data, computing data, downloading data and the trajectory of the UAV are jointly optimized with the goal of minimizing the total energy consumption. Moreover, a two-stage alternating algorithm is proposed to solve the non-convex formulated problem. Finally, the simulation results show the superiority of the proposed scheme compared with other benchmark schemes. Finally, the performance of the proposed scheme is demonstrated under different settings.


Introduction
With the technological evolution of user devices, the computation-intensive and latency-critical applications, such as virtual reality, face recognition and Industrial Internet of Things (IIoT), have become more and more popular. However, the requirements of high quality communications have simultaneously posed big pressure on the user devices [1,2]. Although the user devices are equipped with powerful central processing unit (CPU), they are not able to deal with the ever-increasing amount of data. Mobile cloud computing (MCC) gives the chance to overcome the computing difficulties of

Related Work
The first concept of edge computing is proposed in 2009, which is named cloudlet [2,12]. There has been a lot of research about MEC in recent years, concerning the energy consumption, latency and so on. In [4], the authors designed an energy-efficient MEC offloading mechanism for mobile devices in 5G heterogeneous networks. The mechanism aimed at minimizing the system's energy consumption and ensuring the latency constraints of the computation task. Authors in [1] proposed an algorithm aiming at solving the minimum energy consumption problem in deadline-aware MEC system. The mobility of the mobile devices was also considered in the deadline-aware MEC system. In addition to the energy-efficient mechanisms, the latency is also investigated. In [10], an effective dynamic computation offloading scheme for energy harvesting mobile devices was proposed, aiming at minimizing the execution cost which consists of execution delay and task failure.
Although MEC reduces the energy consumption and latency compared with MCC, it is difficult to satisfy the communication requirements of mobile users in some specific areas, such as hotspot areas or the areas where the communication facilities are distributed sparsely. UAV is recognized to be one of promising wireless communication platforms due to the advantages of high mobility and easy deployment [13]. UAVs, acting as flying base stations or relays, have attracted people's attention in recent years. The placement of the UAV to maximize the coverage has been studied in a lot of research. In [14], the optimal altitude of the UAV-based base station was analyzed for the maximal communication coverage. In [15], an efficient UAV 3D placement with the purpose of maximizing the covered users based on the optimal altitude was proposed. In [16], the authors studied a novel 3D UAV placement with the objective of maximizing the number of covered users according to different requirements of quality of service (QoS). Besides, the energy consumption of both the UAV and mobile users have also been taken into consideration. In [17], the propulsion energy consumption model of the fixed-wing UAV was derived and an efficient trajectory maximizing the UAV's energy efficiency was designed. In [11], given the locations of active devices, the optimal locations of the UAVs and the associations with devices were determined with the objective of minimizing the transmission power of devices. Moreover, the resource management of the UAV-aided communications has also been investigated. In [18], an energy efficient solution in UAV-supported multi-level architecture is employed by grouping uer equipments in clusters based on reinforcement learning. In [19], based on the above cluster solution, the authors proposed a framework that combined UAV-support with wireless powered communication (WPC) techniques to further improve energy efficiency in a distributed non-orthogonal multiple access (NOMA) public safety networks (PSN). The optimal position of the UAV in the Euclidean 3D space was determined by maximizing the coalition head's total energy availability. In [20], a game theoretic framework for load balancing between LTE-Unlicensed unmanned aerial base stations (UABSs) and WiFi access points (APs) based on the loads at the UABSs and the ground APs was proposed. In [21], a framework for the coverage and rate analysis was derived, considering the coexistence between the UAV as a flying base station, and an underlaid device-to-device (D2D) communication network. The framework considered two scenarios: a static UAV and a mobile UAV. The overall outage probabiliy of the D2D users was derived considering multiple retransmissions for the UAV and D2D users.
UAVs endowed with computing capabilities have become more and more popular in recent years, owing to the on-demand communication services provision and flexible deployment. The study of latency has been one of the research directions. The objective of [22] was to minimize the sum of the maximum delay among all the users in each slot. The trajectory of the UAV, the ratio of offloading task and the user scheduling variables were jointly optimized. In addition, energy efficient schemes have attracted wide attention due to the battery technology limitation of the mobile devices and the UAVs. In [23], the energy consumption of the mobile users was minimized considering two types of access schemes, namely, orthogonal and non-orthogonal access. The bits allocation and the trajectory of the UAV were jointly optimized. However, the energy efficient algorithms of the UAVs, which significantly influence the performance of the UAV-enabled MEC system, were not considered. The authors in [24] studied the minimization problem of the weighted sum energy consumption of the UAV and users. The computation resources scheduling, the bandwidth allocation and the trajectory of the UAV were optimized in the minimization problem. In [25], a UAV-enabled wireless powered MEC server was studied to minimize the energy consumption consumed at the UAV. In [26], the weighted sum computation bits were maximized under both the partial and binary offloading mode in UAV-enabled wireless powered MEC system. However, the energy consumption constraint of the UAV was not taken into consideration in [24][25][26]. The energy consumption of the UAV impacts the duration of flight and then impacts the performance of the UAV-enabled MEC system. Hence, it is necessary to design an energy-efficient UAV-enabled MEC systems considering both the energy consumption of the UAV and mobile devices.

Contribution and Organization
Different from the aforementioned study, this paper proposes an energy-efficient UAV-enabled MEC system with the objective of minimizing the total energy consumption of the system. Moreover, the constraints of the UAV energy budget, the number of each task's bits, the causality of the data, and the velocity of the UAV are taken into consideration. The bits allocation and the trajectory of the UAV are jointly optimized under the constraints. Besides, an alternating algorithm is designed to solve the non-convex optimization problem. The main contributions are described as follows: • An energy-efficient scheme subjecting to the constraints of UAV's energy budget, the number of each task's bits, the causality of the data, and the velocity limitation of the UAV is proposed. The aim of the problem is to minimize the total energy-consumption of the UAV-enabled MEC system, which includes the energy consumption of the ground users and the UAV. The bits allocation and the trajectory of the UAV are cooperatively optimized. • A two-stage alternating algorithm is presented to solve the optimization problem. The formulated optimization problem is non-convex due to the non-convex objective function and non-convex constraints. The dual variables also enhance the difficulty of the problem. To solve the optimization problem, an alternating algorithm is proposed. The subproblems are solved by Lagrange duality method and CVX solver respectively. • The simulation results are shown to indicate the superiority of the proposed scheme compared with other benchmark schemes. In contrast to the fixed trajectory of the UAV, the energy consumption of the proposed scheme is greatly decreased. Besides, the performance of the proposed scheme is also demonstrated under different settings.
The remainder of this paper is organized as follows. Section 2 sets up the system model and formulates the optimization problem. An alternating algorithm to solve the optimization problem is designed in Section 3. Then, the simulation results are shown in Section 4. Finally, the paper is concluded in Section 5.

System Model and Problem Formulation
The offloading modes of MEC include binary offloading and partial offloading [27]. In the first mode, the computation task cannot be partitioned, which can only be computed locally or offloaded wholely. In the last mode, a part of the computation task can be computed locally and the other part offloaded. In this paper, we only consider the binary offloading mode to relieve the computation load of the users. Considering the superiority of rotary-wing UAV's agility in turning, the rotary-wing UAV is assumed to provide offloading services in this paper. The UAV-enabled MEC system is depicted in Figure 1, consisting of one UAV-enabled MEC server and K users denoted as K {1, 2, 3, . . . , K}. Moreover, taking the energy constraints of the UAV and the short task deadline of ground users into consideration, the area where the UAV-enabled MEC system can provide offloading services is not large. Thus, it is assumed that the ground users are not distributed over a large area and the ground users are always in the communication range of the UAV. The scenario that the ground users are distributed over a large scale will be further investigated in our future work.

System Model
The notation of user k's task is denoted as A k (I k , τ k , C k , O k ). I k means the task input-data size of user k in bits. τ k means the task deadline of user k. C k represents the computation/intensity of user k, i.e., the number of CPU cycles needed to compute one input bit for user k. O k is the ratio of the number of output information bits to the number of input information bits for user k. The minimal task deadline of all the K users is considered as the time duration T of the UAV-enabled MEC system to finish the offloading tasks. The K users offload their computation tasks using a time division multiple access (TDMA) mode. The time duration T is divided into N slots, whose duration is ∆ = T N . Each slot ∆ is divided into K sub-slots, whose duration is δ = ∆ K = T NK . The slot and sub-slot are depicted as Figure 2. To reduce the additional noise from other users when user k is transmitting the data to the UAV and receiving the data from the UAV, user k only uploads its input information and the UAV only downloads the output results for user k in the kth sub-slot in each slot. The symbols used in the system model are listed in Table 1.
In this paper, a three-dimensional Euclidean coordinate is adopted without the loss of generality, which is measured in meters. The mobile users are located on the ground, whose coordinate is expressed as q k = (x k , y k , 0) for k ∈ K. A UAV mounted with MEC server provides the computation services for the mobile users in the altitude h. The position of the UAV at the end of nth slot is expressed as q u [n] = (x u [n], y u [n], h), which is considered as the position of the UAV in nth slot. We assume that the communication link between the UAV and the ground user is dominated by the line of sight (LoS) channel. The UAV-ground channel is more likely to have the LoS link compared to the terrestrial ground-ground channels. Besides, the Doppler effect due to the UAV mobility is assumed to be compensated [17,28]. Hence, the channel gain from the ground user k to the UAV in the nth slot follows the free-space loss model, which is given by [29,30] where g 0 is the channel power gain at reference distance 1 m. From (1), it can be observed that optimizing the 2D position of the UAV (x k , y k ) has the same effect of optimizing the altitude of the UAV. Therefore, for ease of explanation, we assume that the UAV fly at a fixed altitude H and ingore the slight altitude changes. The energy consumption of the UAV-enabled MEC system is consisted of two parts: the energy consumption of the UAV and the energy consumption of the ground users. Hence, the total energy consumption of the system E is the sum of the energy consumption of the UAV and the energy consumption of the ground users, which is given as: (2) Table 1. List of symbols.

K, k
The set of ground users, k ∈ K K Number of ground users A k The notation of user k's task I k Task input-data size of user k τ k Task  Noise power at the receiver g 0 Channel power gain at reference distance 1m Channel gain from the ground user k to the UAV in nth slot Number of uploading bits of user k in nth slot Number of computing bits of the UAV for user k in nth slot Number of downloading bits from the UAV to user k in nth slot Frequency of the UAV's CPU in the nth slot for computing the tasks of user k f u [n] Frequency of the UAV's CPU in the nth slot Computation energy consumption of the UAV for ground user k in the nth slot Dual variables at the jth iteration in the subgradient method n,j , g

Energy Consumption Model of Ground Users
In the binary mode of the UAV-enabled MEC system, all the K users upload their computation tasks to the UAV and the ground users have no local computing tasks. Consequently, the energy consumption of the ground users E G only depends on the communication energy consumption for uploading data of the ground users E U G as given [30,31]: where B and σ 2 denote the communication bandwidth and the noise power at the receiver respectively; I u k [n] represents the number of uploading input bits of the user k in the nth slot.

Energy Consumption Model of the UAV
The energy consumption of the UAV consists of three parts: the energy consumption of computation E C U , the energy consumption of flying E F U and the energy consumption of downloading the output results to the ground users E D U , which is shown as After the ground users uploading the input data to the UAV, the UAV will execute the computation immediately. The frequency of the UAV's CPU in the nth slot for computing the tasks of user k depends on the number of computing bits for user k in the nth slot, which is expressed as where the I c k [n] is the number of the computing bits at the UAV in the nth slot for ground user k. The computing energy consumption of the UAV depends on the frequency of the CPU. Thus, the computation energy consumption of the UAV for ground user k in the nth slot is shown as where γ u is the effective switched capacitance of the UAV's CPU [23,25,26,32,33]. The total energy consumption of computation in all slots of the UAV is calculated as The flying energy consumption of the UAV in slot n depends on the velocity v[n] and the weight of the UAV M. The total energy consumption for propulsion of the UAV in all slots is given as where κ = 0.5M∆ and M is the weight of the UAV [34][35][36][37]. The velocity of the UAV in nth slot can be calculated as the distance difference in nth slot divided by the time duration of one slot ∆. And the distance difference of the UAV in nth slot is related to the position of the UAV in nth slot q u [n] and in (n − 1)th slot q u [n − 1]. Thus, the velocity of the UAV in nth slot v[n] is expressed as And the value of the UAV's velocity in nth slot should be lower than the maximal velocity of the UAV as expressed as where V max denotes the maximal velocity of the UAV. The energy consumption of downloading the output results from the UAV to the ground users is related to the number of downloading bits and the channel gain, which is given as where I d k [n] denotes the number of the downloading bits from the UAV to the ground user k in the nth slot.

Problem Formulation
The objective of the formulated problem is to minimize the total energy consumption of the system, by joint optimizing the trajectory of the UAV q u [n] and the bits allocation I u k [n], I c k [n], I d k [n]. In this paper, the initial position of the UAV is preset as the position of q 1 , and the final point of the UAV is the position of q K , which are expressed as All users offload their computation tasks to the UAV and the computing results should be distributed to ground users in the duration of N slots. There are three steps for user k to offload the task to the UAV: the ground user k uploads the task to the UAV, the UAV processes data for user k, and the UAV downloads the computation results to the ground user k, as shown in Figure 3. These three steps are conducted in time sequence. Consequently, the ground users do not upload the input information in the last two slots. The UAV does not execute the computation tasks in 1st slot and Nth slot. Moreover, the UAV does not download the computation results to the ground users in 1st slot and 2nd slot. Thus, considering the causality of the data and the chronological order, the bit allocations follow the constraints:  Moreover, the total number of the uploading bits of the ground user k, computing bits and downloading bits of the UAV for the user k are expressed as follows: The objective of the energy-efficient problem is to minimize the total energy consumption of the UAV-enable MEC system. The bit allocations I u k [n], I c k [n], I d k [n] and the trajectory of the UAV q u [n] are jointly optimized, under the constraints of data causality, the velocity and the position of the UAV. The corresponding energy consumption minimization problem P1 is formulated as P1 : min

Algorithm Design
The problem of P1 is a non-convex problem due to the non-convex objective function (21a), non-convex constraint (21b) and the coupling characteristics of the optimization variables. Thus, in this paper, we bring forward a two-stage alternating algorithm to solve the non-convex problem. The details of the two-stage alternating algorithm are shown in the following part.

Bits Allocation under Given Trajectory
It can be seen that with if the trajectory of the UAV is fixed, the problem of P1 is convex with regard to the variables I u Because P2 is convex, Lagrange duality method can be applied [38]. The optimal solution of P2 is given in the following theorem. I u * k [n], I c * k [n] and I d * k [n] represent the optimal number of uploading bits of user k in nth slot, the optimal number of computing bits of the UAV in nth slot for user k and the optimal number of downloading bits from the UAV to the user k in nth slot respectively under the given trajectory of the UAV.

Lemma 1.
At the (j + 1)th iteration in the subgradient method, λ j+1 , µ k,j+1 , ν k,j+1 , ρ k,j+1 , β k,n,j+1 , η k,n,j+1 are obtained from and α (η) j denote the jth step size respectively. The corresponding subgradients n,j and g (η) n,j are given as where I u * k,j , I c * k,j and I d * k,j denote the optimal bits allocation at the jth iteration which are obtained from (23a)-(23c).  It can be seen that the objective function and the constraints of P3 are convex, and the duality of the variables is weak. Then, P3 can be solved by the CVX solver [38,40].

Trajectory Design under Given Bits Allocation
A two-stage alternating algorithm is proposed based on the solution of P2 and P3. The details of the alternating algorithm are shown in Algorithm 1, where E i j and E i denote the total energy consumption of the UAV-enabled MEC system in each iteration as calculated in (2). Initialize: iterative number j = 1 and λ 1 , µ k,1 , ν k,1 , ρ k,1 , β k,n,1 , η k,n,1 ; Update the iterative number j = j + 1; 13: 14: Update λ j , µ k,j , ν k,j , ρ k,j , β k,n,j , η k,n,j through Lemma 1; 15: 16: until

Complexity Analysis
The Complexity of Algorithm 1 comes from three parts. The first part is from the computation of I u * k [n], I c * k [n] and I d * k [n] in Theorem 1. The second part comes from the subgradient method for computing the dual variables. The third part is from the application of CVX to solve the trajectory of the UAV. Let L denote the number of interations of outer loop. According to the work in [38,41]

Simulation Results
In this section, we evaluate the performance of the proposed algorithm by simulation. The parameters of the simulation are shown in Table 2 [22][23][24][25][26]. We consider five trajectories of the UAV to compare the energy consumption of the UAV-enabled MEC system. The size of input tasks of each user are assumed to be I 1 = 4 × 10 7 bits, I 2 = 5 × 10 7 bits, I 3 = 6 × 10 7 bits, I 4 = 7 × 10 7 bits and I 5 = 8 × 10 7 bits respectively. All tasks should be processed within T = 5 s. The duration of each slot and sub-slot are set as 5 × The simulation compares five trajectories: the trajectory using the proposed algorithm, the square trajectory whose length is 16m, the semicircle whose radius is 8m, the line trajectory from (0, 0, H) to (0, 16, H) and the fixed point in (8, 8, H), as shown in Figure 4.  The total energy consumption of four pre-defined trajectories and the proposed algorithm are compared under the same parameter settings. In four pre-defined trajectories, the bits allocation is optimized under given trajectory. The total energy consumption of the UAV-enabled system under five trajectories are 1.8468 × 10 4 J, 1.9812 × 10 4 J, 1.8735 × 10 4 J, 1.9343 × 10 4 J and 1.8665 × 10 4 J respectively, as given in Figure 5. The trajectory of the proposed scheme tends to user 2, user 3 and user 4 to receive the input data and transmit output results. Compared with the pre-defined trajectories, the trajectory of the proposed scheme is optimized to minimize the total energy consumption. In comparison with four pre-defined trajectories, the proposed scheme performs the lowest system energy consumption as shown in Figure 5. It is not necessary for the UAV to go through every ground user to provide MEC services. Consequently, the energy consumption of the square trajectory exceeds the proposed scheme. In the semicircle trajectory, the UAV flies beyond the proposed scheme, causing the augment of the energy consumption of mobility. Although the length of the line trajectory and fixed point decrease compared with the length of the proposed scheme, the energy consumption of communication leads to the increase of the total energy consumption of the system.  Figure 6 shows the optimized bits allocation of each user in each slot for the trajectory using the proposed algorithm of Figure 4. It can be seen from Figure 6 that the tendency of the number of uploading bits, computing bits and downloading bits are similar. The number of uploading bits is relatively high in the beginning slots and decreases over time. Therefore, the UAV can receive all the tasks and provide the input data for the MEC server timely. Then, the UAV deals with the input data and the number of computing bits maintains a steady value. When the computing results output from the MEC server, the UAV needs to transmit the results to the ground users with time constraints. Therefore, the number of the downloading bits increases over time. The number of downloading bits is relatively low compared with the number of uploading bits because of the output/input ratio O k .
The trajectory of the UAV varies under different time duration constraints for the proposed scheme. Figure 7 shows the trajectories of the UAV under different time constraints 4 s, 4.5 s and 5 s, assuming that I 1 = 4 × 10 7 bits, I 2 = 5 × 10 7 bits, I 3 = 6 × 10 7 bits, I 4 = 7 × 10 7 bits and I 5 = 8 × 10 7 bits. When T = 5 s, the trajectory of the UAV tends to user 2, user 3 and user 4 to receive the input data and download the computing results. As the time constraint decreases, the trajectory of the UAV shrinks to user 1 and user 2, because the velocity of the UAV is limited and the UAV should complete the offloading tasks under the finite time duration constraint. Figure 8 shows the velocities of the UAV for the trajectories shown in Figure 7 under different time constraints. The UAV flies fast at the start to fly forward to the ground users to receive the uploading data. Then, the UAV reduces the speed over time to ensure that all ground users can upload the data and the UAV has time to process the data. Finally, the UAV speeds up in the end to finish the offloading tasks and to reach the destination timely. Moreover, as the time constraint decreases, the velocity of the UAV increases to complete the tasks under the limited task deadline. In the two-stage alternating algorithm, the subproblem at a certain iteration is solved given the optimized variables derived from last iteration or last stage. So the alternating algorithm proposed in this paper should perform convergence. Figure 9 shows the convergence of the total energy consumption of the UAV-enabled MEC system under different time constraints when I 1 = 4 × 10 7 bits, I 2 = 5 × 10 7 bits, I 3 = 6 × 10 7 bits, I 4 = 7 × 10 7 bits and I 5 = 8 × 10 7 bits. It can be seen from Figure 9 that the total energy consumption of the UAV-enabled MEC system converges to a certain value using the proposed algorithm. Only a few iteration numbers are needed to converge by applying the alternating algorithm. Besides, the total energy consumption rises as the time constraint decreases, because the increase of the UAV's velocity leads to the growth of the total energy consumption under the limited task deadline.  The number of iteration Energy consumption of the system (Joule) 10 4 T=4s T=4.5s T=5s Figure 9. The total energy consumption of the system (I 1 = 4 × 10 7 bits, I 2 = 5 × 10 7 bits, I 3 = 6 × 10 7 bits, I 4 = 7 × 10 7 bits and I 5 = 8 × 10 7 bits).
The superiority of the proposed algorithm is also demonstrated. In Figure 10, the proposed two-stage alternating scheme and the successive convex approximation (SCA) scheme are compared. The SCA algorithm is used to tackle the non-convex problems by applying the convex approximation of the non-convex objective and constraints [23,42,43]. For the generality, the users are assumed to be randomly distributed. Under the same distribution of the ground users, the optimizing trajectories of the UAV using the proposed scheme and the SCA scheme are compared. Figure 11 shows the total energy consumption of the UAV-enabled MEC system using the proposed two-stage alternating algorithm and the SCA algorithm, assuming that T = 5 s, I 1 = I 3 = I 5 = 2 × 10 7 bits and I 2 = I 4 = 8 × 10 7 bits. It can be seen from Figure 11 that the proposed scheme outperforms the SCA scheme in terms of the total energy consumption of the UAV-enabled MEC system. The UAV under the SCA algorithm flies further than the proposed algorithm as shown in Figure 10. The longer distance leads to the larger energy consumption of the UAV and the UAV-enabled MEC system. In Figure 11, the energy consumption of the system using the proposed algorithm, the energy consumption of the ground users using the proposed algorithm, the energy consumption of the system using the SCA algorithm and the energy consumption of the ground users by computing the tasks locally are shown respectively. The energy consumption is compared under different time constraints and the same user distribution as shown in Figure 10, assuming that T = 5 s, I 1 = I 3 = I 5 = 2 × 10 7 bits and I 2 = I 4 = 8 × 10 7 bits. Figure 11 demonstrates that the proposed algorithm performs lower energy consumption of the system than the SCA algorithm under different time constraints. Moreover, from Figure 11, we observe that offloading the computing tasks to the UAV-enabled MEC system alleviates the burden of the ground users greatly. We also note that as the time constraint becomes more stringent, the energy savings of the UAV-enabled system using the proposed scheme becomes more prominent compared with computing locally. It should be noted that if the time constraint is too short for the UAV to complete the offloading tasks under the velocity limit, the optimization problem becomes infeasible.
To show the comlexity of Algorithm 1, the run time of Algorithm 1 is given in Table 3. The run time is obtained by using a computer with 64-bit Intel(R) i5-4210 CPU, 8GB RAM. From Table 3, it can be seen that it is feasible to implement Algorithm 1. The complexity of Algorithm 1 is affected by the number of slots N and the number of ground users K. And the table shows that N has a larger influence on the complexity than K, as analyzed in Section 4. Besides, how to reduce the complexity of the algorithm, especially when N increases, will be further studied in our future work. Energy consumption (Joule) 10 4 The proposed algorithm (system) The proposed algorithm (ground users) The SCA algorithm (system) Local computing (ground users) Figure 11. The total energy consumption of the MEC system under different time constraints (I 1 = I 3 = I 5 = 2 × 10 7 bits, I 2 = I 4 = 8 × 10 7 bits).

Conclusions
In this paper, a UAV-enabled MEC system is studied in which the UAV carries computing resources to provide computation offloading services for the ground users. The bits allocation of uploading data, computing data, downloading data and the trajectory of the UAV are jointly optimized with the goal of minimizing the total energy consumption of the UAV-enabled system, including the flying energy consumption and the transmission energy consumption. The energy consumption minimization problem is optimized under the constraints of the number of each task's bits, the causality of the data and the velocity of the UAV. On account of the fact that the optimization problem is non-convex, an alternating algorithm is proposed in this paper to solve the formulated problem. The simulation results illustrate that the proposed scheme is superior to the benchmark schemes. Moreover, the simulation results also show the performance of the proposed scheme with different parameters. In the future work, we will consider the more complicated models for flying and communications, such as the fading factors and the mobility of ground users. L (I,λ, µ, ν, ρ, β, η Based on (A1), the optimal solution of P2 can be derived by solving the Lagrangian dual function. Then, the Lagrangian dual function of P2 can be presented as min I L (I, λ, µ, ν, ρ, β, η ∂L (I, λ, µ, ν, ρ, β, Let the derivations be zero, and the optimal solution of bits allocation I u * k [n], I c * k [n] and I d * k [n] can be solved separately. Thus, (23a), (23b) and (23c) shows the optimal solution of P2.