1 Introduction

With the rapid development of the Internet-of-Things (IoT) and the fifth-generation (5G) communication technology, numerous emerging mobile applications, such as unmanned driving, virtual reality, and face recognition, have been incorporated into people’s daily life [1]. Commonly, such computation-intensive applications are sensitive to delay, and thus they put high demands on the computational capacity of mobile devices (MDs) during execution [2]. However, with the consideration of the existing hardware technology and device portability, the computational capacity of MDs is usually limited, which greatly reduces the performance of the above-mentioned applications when they are executed on MDs. In recent years, mobile edge computing (MEC) has been regarded as a forward-looking technology to solve this issue [3]. Through deploying edge servers at the network edge (e.g., cellular-network base stations and WiFi access points), MEC overcomes the problem of network congestion caused by the traditional cloud-based centralized processing [4]. Therefore, MEC can offer computing services with less time overhead, thereby improving the Quality-of-Service (QoS).

Traditional mobile communications rely on ground communication infrastructures [5]. However, in some isolated areas (e.g., mountains and oceans) or some emergencies (e.g., disaster relief and military exercises), the restricted ground communication infrastructures may have a huge impact on the efficiency of mobile communications [6]. Due to the high flexibility, strong mobility, and low deployment cost, unmanned aerial vehicles (UAVs) are gradually applied to the field of emergency communications [7]. UAVs can be regarded as mobile base stations to provide communication services for MDs on the ground, thereby building an integrated ground-air communication network [8]. There are two advantages when using UAVs as base stations (or edge servers). First, the effective Line-of-Sight (LOS) channel formed by UAVs and MDs can avoid the problems of signal attenuation and penetration loss caused by encountering obstacles. Second, UAVs can flexibly change their deployment positions in the network. When MD or network status changes, UAVs can be quickly adjusted at a lower cost.

However, there are many challenges in applying UAVs to MEC systems. On one hand, the deployment of edge servers in traditional MEC systems usually depends on ground infrastructures. When UAVs are used as edge servers, more flexible UAV deployment strategies are required, and thus the traditional deployment strategies for edge servers might not be applicable. The positions of UAVs directly affect the communication delay and energy consumption in MEC systems, and thus an effective UAV deployment strategy has become critical. On the other hand, the traditional computation offloading strategies usually offload all computing tasks from MDs to edge servers for execution. However, UAVs are not equipped with the equivalent computational resources as traditional edge servers. Therefore, UAVs may not be able to provide computing services for all MDs in their coverage area. The computation offloading strategies directly affect the computing efficiency of UAVs, and thus an effective computation offloading strategy is indispensable.

To address the above challenges, we conduct research work on the optimization problem of UAV deployment and computation offloading in a multi-UAV-enabled MEC system. The goal of this work is to minimize the average task response time by optimizing the positions of UAVs and the offloading strategy in a multi-UAV-enabled MEC system. The main contributions of this paper are summarized as follows.

  • A multi-UAV-enabled MEC system is designed. Based on the proposed model, the optimization problem of average task response time with service constraints is well defined.

  • Based on the defined optimization problem, a two-layer joint optimization method (PSO-GA-G) is proposed. First, the outer layer utilizes a Particle Swarm Optimization algorithm combined with Genetic Algorithm operators (PSO-GA) to optimize UAV deployment. Next, the inner layer adopts a greedy algorithm to optimize computation offloading. Finally, the optimization problem is well solved by the loop-iteration.

  • The extensive simulation experiments are conducted to demonstrate the feasibility and effectiveness of the proposed PSO-GA-G. The results show that the PSO-GA-G outperforms other three baseline methods in terms of average task response time.

The rest of this paper is organized as follows. Section 2 reviews the related work. Section 3 introduces the system model and the problem definition. Section 4 describes the proposed PSO-GA-G in detail. Section 5 presents the evaluation results. Section 6 concludes the work of this paper.

2 Related work

In recent years, MEC has received widespread attention in both industry and academia. MEC can effectively reduce the communication delay between MDs and remote servers by sinking the computational resources from the remote cloud to the network edge, thereby improving the user experience.

Computation offloading is one of the key technologies of MEC. Through reasonable offloading decisions and resource allocation, the computing tasks running on MDs can be offloaded to edge servers, and then these tasks are completed by using sufficient computational and storage resources. Traditional computation offloading technology allows an end device to use a coarse-granularity manner to offload an entire computing task to an edge server [9] or to partition the task via a fine-granularity way and partly offload it to the edge server [10]. For example, Chen et al. [11] supported mobile applications with a novel offloading capability at the granularity of objects for MEC. With the development of 5G networks, a cooperative offloading technology has also emerged by integrating MEC and D2D [12]. Related research shows that the computation offloading technology can effectively shorten the task response time [13], reduce the energy consumption of devices [14], and cut down the communication cost [15].

It is expected that the combination of UAVs and MEC can provide more reliable, lower-latency, and larger-coverage network services [16], which is regarded as a new trend in MEC. Current researches on UAV-enabled MEC systems mainly focus on the problem of computation offloading. Chen et al. [17] introduced a first-come-first-served (FCFS) queuing model, defined the optimization problem as an offloading game, and then designed a distributed offloading algorithm based on the optimal concurrent response. Zhang et al. [18] designed a UAV-enabled MEC system considering offloading decisions and resource competition constraints and proposed a game-theory-based solution to prove the existence of Nash equilibrium. Kim et al. [19] developed an offloading method based on machine learning to optimize system energy consumption and delay. By using reinforcement learning (RL), Wang et al. [20] proposed an optimization algorithm for task offloading and UAV resource allocation, which showed good optimization effects in large-scale scenarios. Seid et al. [21] designed a collaborative offloading and resource allocation scheme based on model-free deep RL, which checked the UAV status through the Jain fairness index (JFI).

The optimization of UAV deployment is a research hotspot in the UAV field. Yao et al. [22] analyzed the distribution characteristics of UAVs and proposed a random optimal response algorithm to solve the problem of UAV deployment, aiming to minimize the system energy consumption. Yang et al. [23] designed an IoT architecture based on multi-UAV-assisted MEC and proposed a UAV deployment strategy based on a differential evolutionary algorithm, which achieved the load balancing among multiple UAVs. Zhang et al. [24] developed a UAV deployment method based on a discrete PSO algorithm to maximize the UAV coverage. Huang et al. [25] adopted an evolutionary algorithm to handle the problem of UAV deployment, which reduced the system energy consumption by optimizing the number and positions of UAV stops. Fu et al. [26] optimized the UAV deployment and transmission power consumption by using a dual decomposition method. Wang et al. [27] designed an adaptive deployment strategy for UAV-aided communication networks, aiming to enhance the average throughput and the transmission success rate.

The existing researches on UAV-enabled MEC systems mainly focused on reducing the system energy consumption while rarely optimizing the system response time. For example, Sun et al. [28] designed a learning-based cooperative particle swarm optimization (LCPSO) method with a Markov random field (MRF)-based decomposition strategy, in order to reduce the response time of forest fire monitoring in UAV-enabled MEC systems. Peng and Shen [29] proposed a multi-agent deep deterministic policy gradient (MADDPG)-based method to enhance delay/QoS satisfaction ratios in MEC-UAV-Assisted vehicular networks. Zhang and Ansari [30] developed an approximation algorithm to improve the average user latency in UAV-aided MEC networks. Different from these researches, our work aims to minimize the average task response time in a multi-UAV-enabled MEC system by jointly optimizing UAV deployment and computation offloading.

3 System model and problem definition

As shown in Fig. 1, a multi-UAV-enabled MEC system is considered. In this system, a set of MDs are unevenly distributed on the ground, donated by \(M=\left\{MD_1,MD_2,...,MD_m\right\}\), and a set of UAVs are deployed in the air for offering computing services to MDs, donated by \(N=\left\{UAV_1, UAV_2, ..., UAV_n\right\}\), where m and n indicate the number of MDs and UAVs, respectively. Assume that \(MD_i\) (\(1 \le i \le m\)) has a computing task to be performed, denoted by \(Task_i = (D_i, Si)\), where \(D_i\) represents the size of the input data (bits) of \(Task_i\) and \(S_i\) represents the amount of computing resources (CPU cycles) required for processing one bit of data. Moreover, MDs and UAVs exchange data via wireless channels and MDs can offload all their computing tasks to UAVs for execution.

Fig. 1
figure 1

A multi-UAV-enabled MEC system

3.1 Communication model

The positions of MDs and UAVs are expressed in the form of three-dimensional Cartesian coordinates. For example, the positions of \(MD_i\) (\(1 \le i \le m\)) and \(UAV_j\) (\(1 \le j \le n\)) are respectively defined as \(p^{MD}_i = (x^{MD}_i, y^{MD}_i, 0)\) and \(p^{UAV}_i = (x^{UAV}_j, y^{UAV}_j, H)\), where H represents the flying height of UAVs. To simplify the model, it is assumed that all UAVs are deployed at the same height and their positions remain unchanged after deployment in a certain time slot [31].

Due to the high positions of UAVs, the LOS channel loss of the communication link between UAVs and MDs becomes significant. Therefore, the wireless channel between \(MD_i\) and \(UAV_j\) can be simulated by using the free-space-path-loss (FSPL) model [32], where the power gain of the wireless channel link is calculated by

$$\begin{aligned} h_{i, j} = g_0d^{-2}_{i, j} = \frac{g_0}{H^2 + ||p^{MD}_i - p^{UAV}_i||}, \end{aligned}$$
(1)

where \(g_0\) represents the channel power gain of spatial distance per unit and \(d_{i, j}\) represents the spatial distance between \(MD_i\) and \(UAV_j\).

To reduce the transmission delay, \(MD_i\) always uses its maximum transmission power \(P_i\) for data transmission, in order to improve the signal-to-noise ratio (SNR) of the communication link. Therefore, the data transmission rate between \(MD_i\) and \(UAV_j\) is

$$\begin{aligned} R_{i, j} = B\log _2(1 + \frac{P_ih_{i, j}}{\sigma ^2}), \end{aligned}$$
(2)

where B and \(\sigma ^2\) represent the channel bandwidth and the white Gaussian noise (WGN) power in the communication link, respectively.

3.2 Computing model

Considering that all UAVs and MDs can provide computing services, the computing tasks on MDs can be offloaded to UAVs and also executed locally. The offloading matrix between MDs and UAVs is defined as

$$\begin{aligned} A= \left[ \begin{array}{cccccc} \alpha _{1,1} &{} \cdots \ &{} \alpha _{1,j} &{} \cdots \ &{} \alpha _{1,n} &{} \alpha _{1,n+1}\\ \vdots &{} \ddots &{} \vdots &{} \ddots &{} \vdots &{} \vdots \\ \alpha _{i,1} &{} \cdots \ &{} \alpha _{i,j} &{} \cdots &{} \alpha _{i,n} &{} \alpha _{i,n+1}\\ \vdots &{} \ddots &{} \vdots &{} \ddots &{} \vdots &{} \vdots \\ \alpha _{m,1} &{} \cdots \ &{} \alpha _{m,j} &{} \cdots &{} \alpha _{m,n} &{} \alpha _{m,n+1}\\ \end{array} \right] , \end{aligned}$$
(3)

where \(\alpha _{i,j} \in \{0, 1\}\). When the computing tasks are offloaded from \(MD_i\) to \(UAV_j\) for execution, \(\alpha _{i,j} = 1\); otherwise, \(\alpha _{i,j} = 0\). Especially, when \(\alpha _{i,n+1} = 1\), the computing tasks are executed on \(MD_i\).

Therefore, there are two optional execution manners for the computing tasks on each MD as follows.

  • Local execution. When \(\alpha _{i,n+1} = 1\), the computing tasks are executed on \(MD_i\). According to the definition of \(Task_i\), the total number of CPU cycles required to execute the task is \(S_i \times D_i\). Thus, the time required to execute a task on \(MD_i\) is calculated by

    $$\begin{aligned} T^{loc}_i = \frac{S_i \times D_i}{f^{MD}_i}, \end{aligned}$$
    (4)

    where \(f^{MD}_i\) indicates the CPU frequency of \(MD_i\).

  • Offloading execution. When \(\alpha _{i,j} = 1\), the computing tasks are offloaded from \(MD_i\) to \(UAV_j\) for execution. Thus, the completion time of a task consists of three parts, including the data transmission time (denoted by \(T^{tran}_{i,j}\)), the task execution time (denoted by \(T^{UAV}_{i,j}\)), and the back time of results (denoted by \(T^{back}_{i,j}\)). Specifically, \(T^{tran}_{i,j}\) and \(T^{UAV}_{i,j}\) are calculated by

    $$\begin{aligned} T^{tran}_{i,j} = \frac{D_i}{R_{i, j}},\end{aligned}$$
    (5)
    $$\begin{aligned} T^{UAV}_{i,j} = \frac{S_i \times D_i}{f^{UAV}_j}, \end{aligned}$$
    (6)

    where \(f^{UAV}_j\) indicates the CPU frequency of \(UAV_j\). It is noticed that each UAV can execute multiple tasks in parallel, and thus the computational resources of a UAV would be equally allocated by the offloaded tasks. When tasks are completed, the execution results would be sent back to the corresponding MDs. Since the amount of the back data is usually small, \(T^{back}_{i,j}\) is negligible. Thus, when a task is offloaded from \(MD_i\) to \(UAV_j\) for execution, the task completion time is calculated by

    $$\begin{aligned} T^{off}_{i,j} = T^{tran}_{i,j} + T^{UAV}_{i,j}. \end{aligned}$$
    (7)

3.3 Problem definition

Based on the above analysis, to minimize the average task response time of a multi-UAV-enabled MEC system, the optimization problem P1 is defined as

$$\begin{aligned} \begin{aligned}&\mathrm{P1}: \min _{P^{UAV}, A}\frac{1}{m}\sum _{i=1}^{m}(\alpha _{i,n+1}T^{loc}_i + \sum _{j=1}^{n}\alpha _{i,j}T^{off}_{i,j}), \\&s.t.~C1: 0 \le x^{UAV}_j \le X_{\max }, \\&~~~~~C2: 0 \le y^{UAV}_j \le Y_{\max }, \\&~~~~~C3: \alpha _{i,j} \in \{0, 1\}, \\&~~~~~C4: \sum _{j=1}^{n} \alpha _{i,j} = 1,\\&~~~~~C5: 0 \le \sum _{i=1}^{m} \alpha _{i,j} \le N_{\max }, \\ \end{aligned} \end{aligned}$$
(8)

where \(\forall i \in \{1,2, ..., m\}\) and \(\forall j \in \{1,2, ..., n\}\). C1 and C2 indicate the deployment scope constraints of UAVs, C3 represents offloading decisions, C4 indicates that each MD can only offload tasks to one UAV or execute them locally, and C5 means that the number of tasks that each UAV can execute can not exceed the maximum number of concurrent tasks.

4 PSO-GA-G based optimization for UAV deployment and computation offloading

4.1 Problem analysis

The proposed optimization problem is a hybrid nonlinear programming problem, whose objective function and the constraint C3 are non-convex, which makes it hard to be directly solved. As a swarm intelligence search algorithm, the PSO algorithm does not use the gradient information of functions. Therefore, the PSO algorithm has no requirement for the continuity and derivability of functions and shows great potentials to handle the above optimization problem. However, there exist the following two issues when using the traditional PSO algorithm to deal with the proposed optimization problem.

  • The proposed optimization problem involves UAV deployment and computational offloading, but it is difficult for the traditional PSO algorithm to solve this multi-parameter coupling optimization problem.

  • The traditional PSO algorithm may easily fall into the local optimum, and thus it might not be able to get the optimal/near-optimal solution.

To address these issues, a two-layer joint optimization method (PSO-GA-G) is proposed by integrating the PSO-GA and the greedy algorithms. In each iteration, the outer layer of the PSO-GA-G utilizes the PSO-GA algorithm to optimize the deployment positions of UAVs, while the inner layer of the PSO-GA-G adopts the greedy algorithm to optimize offloading decisions.

4.2 PSO-GA based optimization for UAV deployment

The PSO-GA algorithm inherits the features of the traditional PSO algorithm, including easy implementation, high accuracy, and fast convergence. Furthermore, by using the update operators of the GA, the PSO-GA algorithm can well avoid the local optimum and obtain a more optimized solution.

4.2.1 Particle coding

The coding manners determine the execution efficiency of algorithms, but it is are difficult to use some traditional coding manners (e.g., binary coding and integer coding) to describe the feasible solutions of P1. In the proposed model, the deployment positions of UAVs are represented by their x-axis and y-axis coordinates, and thus the following mechanism of particle coding is adopted: each particle indicates a deployment plan of all UAVs, and each quantile of the particle is encoded by a two-dimensional vector, which describes the horizontal deployment position of a UAV. At the t-th iteration, the position of the particle k is defined as

$$\begin{aligned} X^t_k = (x^t_{k1}, x^t_{k2}, ..., x^t_{kj},... , x^t_{kn}), \end{aligned}$$
(9)

where \(x^t_{kj} = (X^t_{kj}, Y^t_{kj})\) represents the horizontal deployment position of \(UAV_j\). \(X^t_{kj}\) and \(Y^t_{kj}\) indicate the x-axis and y-axis coordinates, respectively.

Figure 2 illustrates an example of particle coding. The particle consists of five quantiles, which describe the deployment positions of five UAVs. Each quantile is composed of a two-dimensional vector, which represents the horizontal coordinates of a UAV. For example, the coding of the 1st quantile is (114, 517), which indicates that the deployment position of the 1st UAV is (114, 517, H).

Fig. 2
figure 2

Particle coding

4.2.2 Fitness function

The fitness function evaluates the quality of particles. When solving the proposed optimization problem, the objective function in Eq. (8) is regarded as the fitness function of the PSO-GA algorithm. Therefore, by inputting UAV deployment and offloading plans into the objective function, the corresponding values of the fitness function of particles can be obtained. Since our optimization goal is to minimize the average task response time, the particles with smaller values of the fitness function exhibit better performance.

4.2.3 Particle updating

In the traditional PSO algorithm, each particle moves in the problem search space with a certain direction and velocity. The particles iteratively adjust their positions and velocities in the problem search space according to the surrounding particles and their own experience. In this process, the velocity and position of a particle are updated as

$$\begin{aligned} V^{t+1}_k = w V^t_k + c_1 r_1 (pBest_k - X^t_k) + c_2 r_2 (gBest - X^t_k),\end{aligned}$$
(10)
$$\begin{aligned} X^{t+1}_k = V^{t+1}_k + X^t_k, \end{aligned}$$
(11)

where \(V^t_k\) and \(X^t_k\) represent the velocity and position of the k-th particle at the t-th iteration, respectively. \(pBest_k\) and gBest indicate the optimal position of the k-th particle in history and the entire population after t iterations, respectively. w is the inertia factor that determines the influence of the velocity of the last iteration on the current velocity. \(c_1\) and \(c_2\) are individual and social learning factors, which respectively reflect the learning abilities for the optimal value in the individual and population histories. \(r_1\) and \(r_2\) are two random values in the interval [0, 1] that are used to supplement the randomness into the iterative search process.

Based on the PSO algorithm, the PSO-GA algorithm introduces the mutation and crossover operators of the GA. Correspondingly, the update manner of a particle is given as

$$\begin{aligned} X^{t+1}_k = c_2 \oplus C_g (c_1 \oplus C_p (w \oplus M_u(X^t_k), pBest_k), gBest), \end{aligned}$$
(12)

where \(M_u()\) is the mutation operator. \(C_p()\) and \(C_g()\) are crossover operators.

Next, through combining with the mutation operator, the inertial part of a particle is updated by

$$\begin{aligned} A^t_k = w \oplus M_u (X^{t-1}_k)= {\left\{ \begin{array}{ll} M_u (X^{t-1}_k), &{} r_1 < w \\ X^{t-1}_k, &{} \mathrm{other~cases} \end{array}\right. }, \end{aligned}$$
(13)

where \(r_1\) is a random value in the interval [0, 1]. \(M_u (X^{t-1}_k)\) is to randomly select a quantile on the particle \(X^{t-1}_k\) and perform the mutation operation within the pre-defined threshold. Figure 3 illustrates an example of mutation operation. In this process, the mutation operator randomly selects a quantile \(mp_1\) and mutates the code on this quantile from (234, 885) to (292, 901).

Fig. 3
figure 3

Mutation operation

Moreover, through combining with the crossover operator, the parts of individual and social learning are respectively updated by

$$\begin{aligned} B^t_k= & {} w \oplus C_p (A^t_k, pBest_k)= {\left\{ \begin{array}{ll} C_p (A^t_k, pBest_k), &{} r_2 < c_1 \\ A^t_k, &{} \mathrm{other~cases} \end{array}\right. },\end{aligned}$$
(14)
$$\begin{aligned} C^t_k= & {} w \oplus C_g (B^t_k, gBest)= {\left\{ \begin{array}{ll} C_g (B^t_k, gBest), &{} r_3 < c_2 \\ B^t_k, &{} \mathrm{other~cases} \end{array}\right. }, \end{aligned}$$
(15)

where \(r_2\) and \(r_3\) are two random values in the interval [0, 1]. The crossover operator is to randomly select two quantiles on the particle and replace the codes between these two quantiles by using the codes between the corresponding quantiles on \(pBest_k\) or gBest. Figure 4 illustrates an example of crossover operation. In this process, the crossover operator randomly selects two quantiles (i.e., \(cp_1\) and \(cp_2\)) and replaces the codes between these two quantiles (i.e., (234, 885), (178, 667), and (482, 533)) by using the codes between the corresponding quantiles on \(pBest_k\) or gBest (i.e., (288, 624), (167, 582), and (451, 764)).

Fig. 4
figure 4

Crossover operation

4.2.4 Parameter adjustment

The inertia factor w determines the convergence speed and search capability of the PSO-GA algorithm. When the value of w is large, the particles will be mutated with a greater probability, and thus the algorithm owns a stronger global search capability. On the contrary, the particles will be mutated with a lower probability, which leads to a better local search capability.

In the early stage of execution, the PSO-GA algorithm pays more attention to the diversity of the problem search space. As the search deepens, the PSO-GA algorithm will focus on the ability of the local search. Therefore, the value of w should decrease with the increasing number of iterations, whose adjustment manner is defined as

$$\begin{aligned} w = w_{\max } - iters_{cur} * \frac{w_{\max } - w_{\min }}{iters_{\max }}, \end{aligned}$$
(16)

where \(w_{\max }\) and \(w_{\min }\) are the maximum and minimum values of w. \(iters_{\max }\) and \(iters_{cur}\) are the maximum and current numbers of iterations. Thus, the value of w will decrease as the number of iterations increases.

Moreover, similar adjustment manners are adopted for the individual and social learning factors (i.e., \(c_1\) and \(c_2\)) as follows.

$$\begin{aligned} c_1= & {} c_{1\_start} - iters_{cur} * \frac{c_{1\_start} - c_{1\_end}}{iters_{\max }},\end{aligned}$$
(17)
$$\begin{aligned} c_2= & {} c_{2\_start} - iters_{cur} * \frac{c_{2\_start} - c_{2\_end}}{iters_{\max }}, \end{aligned}$$
(18)

where \(c_{1\_start}\) and \(c_{2\_start}\) are the initial values of \(c_1\) and \(c_2\) before the iterations start. \(c_{1\_end}\) and \(c_{2\_end}\) are the final values of \(c_1\) and \(c_2\) when the iterations end.

4.2.5 Algorithm implementation

According to Algorithm 1, the main steps of the PSO-GA based optimization for UAV deployment are described as follows.

Step 1: (Lines 1\(\sim\)11) Initialize the original population (denoted by \(Pop^0\)), including the population size (denoted by size), pBest, and gBest.

Step 2: (Lines 12\(\sim\)25) Execute mutation and crossover operations on \(Pop^0\), calculate the values of the fitness function (denoted by Fitness), and iteratively update \(pBest_i\) and gBest according to Fitness.

Step 3: (Line 26) Complete iterations, and output the optimal solution (denoted by \(P^{UAV}\)) and average task response time (denoted by \(T_{avg}\)).

figure f

4.3 Greedy-based optimization for computation offloading

To obtain a complete solution to the optimization problem P1, reasonable offloading decisions should also be made for the computing tasks from MDs. To address this problem, a greedy algorithm is adopted to quickly realize the optimization of computation offloading.

Basically, the greedy algorithm always makes the current best choice. When the UAVs and MDs are closer, the power gain of the wireless channel link is greater, and thus the time required for offloading will become less. Therefore, the task response time can be effectively reduced by offloading the computing tasks from an MD to the nearest UAV.

However, due to the limited parallel computational capacity of a UAV, it can only offer offloading services for a certain number of MDs. Moreover, for some scattered MDs, even if the tasks are offloaded to the corresponding nearest UAV, the time overhead will be large. In response to these issues, a greedy-based optimization for computation offloading is proposed. According to Algorithm 2, the main steps are described as follows.

Step 1: (Line 1) Initialize each element (denoted by \(\alpha _{i,j}\)) in the offloading matrix (denoted by A).

Step 2: (Lines 2\(\sim\)11) Calculate the distance (denoted by \(d_{i, j}\)) between \(MD_i\) and \(UAV_j\), and record the UAV nearest to \(MD_i\) (denoted by \(UAV_{index}\)).

Step 3: (Lines 12\(\sim\)17) Calculate the time required to execute a task on \(MD_i\) (denoted by \(T^{loc}_i\)) and on the nearest UAV (denoted by \(T^{off}_{i, index}\)), and judge whether the task is executed on the MD or on the UAV.

Step 4: (Lines 18\(\sim\)22) If the UAV has not exceeded its service constraints (denoted by \(N_{\max }\)), it can still offer computing services for MDs. Otherwise, the MD with the farthest distance from \(UAV_{index}\) will execute the task locally.

figure g

5 Performance evaluation

In this section, we evaluate the performance of the proposed PSO-GA-G for optimizing UAV deployment and computation offloading and make comparisons with the other three baseline methods.

5.1 Experimental setup

The simulation environment is established in an area of 1000 × 1000 m2 , which contains 100 MDs. The input data size of computing tasks is randomly distributed in the interval [10, 20] Mbit, and the CPU frequency of an MD is 1 GHz. In this area, 10 UAVs are deployed, where each UAV can offer computing services for multiple MDs in parallel. The CPU frequency of UAVs is randomly distributed in the interval [2.5, 3.5] GHz. Other parameter settings are shown in Table 1.

Table 1 Parameter settings

Based on the parameter settings, the following four scenarios are considered, where MDs are distributed via different manners.

Scenario 1: This is a typical scenario, and there is a local area (e.g., supermarkets and hospitals) where a large number of MDs are assembled. Specifically, about 90% of MDs are assembled in this local area, and the rest are randomly distributed in other areas. The distribution of MDs in this scenario is shown in Fig. 5a.

Scenario 2: There is also a local area where MDs are assembled in this scenario, but only 50% of MDs are assembled in this area, and the rest are randomly distributed in other areas. Compared with Scenario 1, the assemble density of MDs in a local area is lower. The distribution of MDs in this scenario is shown in Fig. 5b.

Scenario 3: There are two local areas where MDs are assembled (e.g., two workshops in a factory) in this scenario. Specifically, 50% of MDs are assembled in one area, 35% of MDs are assembled in another one, and the rest are randomly distributed in other areas. The distribution of MDs in this scenario is shown in Fig. 5c.

Scenario 4: There is no local area where MDs are assembled in this scenario, and all MDs are randomly distributed (e.g., parks and streets). The distribution of MDs in this scenario is shown in Fig. 5d.

Fig. 5
figure 5

Different scenarios with various MD distributions

5.2 Baseline methods

To verify the feasibility and effectiveness of the proposed PSO-GA-G, we modify the following three baseline methods to make them fit the proposed problem and then conduct comparative experiments. In the experiments, when making the comparison among various methods, the simulation settings (e.g., the input data size of computing tasks and the CPU frequency of UAVs) are kept constant in each scenario. Based on the above settings, a fair environment is established for making the comparison among various methods.

Random-G. The random strategy and greedy algorithm are adopted to handle the optimization problem of UAV deployment and computation offloading, respectively. In the Random-G, UAV deployment and computation offloading are regarded as two completely independent processes, and the impact of MD positions and resource demands of computing tasks on optimization results is not considered when deploying UAVs.

K-means-G. The K-means [33] and greedy algorithms are adopted to handle the optimization problem of UAV deployment and computation offloading, respectively. In the K-means-G, UAV deployment and computation offloading are regarded as two completely independent processes, and the impact of resource demands of computing tasks on optimization results is not considered when deploying UAVs.

PSO-G. The PSO [24] and greedy algorithms are adopted to handle the optimization problem of UAV deployment and computation offloading, respectively. In the PSO-G, UAV deployment and computation offloading are jointly considered. In each iteration, the particles of UAV deployment and offloading plans are updated for continuously optimizing results.

5.3 Result analysis

To evaluate the performance of the PSO-GA-G, the Random-G, the K-means-G, and the PSO-G, we conduct 50 experiments on each scenario and make averages to increase the stability of the experimental results. The results are shown in Fig. 6. In all these four scenarios, the proposed PSO-GA-G owns the best optimization effect in terms of average task response time while the Random-G performs the worst.

Fig. 6
figure 6

Average task response time (s) by various methods in different scenarios

In Scenario 1, the PSO-GA-G is significantly better than the other three baseline methods. The K-means-G always first deploys UAVs according to the distribution of MDs, and then makes offloading decisions based on the UAV deployment results. Therefore, during the process of deploying UAVs, the K-means-G does not consider the impact of resource demands of computing tasks on response time, which makes it impossible to evaluate the UAV deployment results on time. In contrast, the PSO-G and the PSO-GA-G jointly consider the impact of UAV deployment and computation offloading on optimization results in each iteration, and thus they have better performance. By introducing the update operators of the GA, the PSO-GA-G avoids the local optimum and thus obtains better results than the PSO-G.

Compared with Scenario 1, the performance gap between the K-means-G and the PSO-GA-G becomes smaller in Scenario 2. The K-means-G divides MDs into clusters and deploys UAVs at their corresponding centroids. However, the assemble density of MDs in Scenario 1 is higher than in Scenario 2, the K-means-G would still deploy UAVs in positions with scattered MDs, which results in the serious uneven resource utilization of UAVs in different areas. In contrast, the PSO-GA-G avoids deploying UAVs in areas with scattered MDs, which improves the resource utilization of UAVs. In Scenario 2, since the assemble density of MDs is declined, the UAV deployment plan obtained by the K-means-G leads to higher resource utilization of UAVs, and thus the performance of this method can be improved.

Compared with Scenarios 1 and 2, the average task response time achieved by the PSO-GA-G basically remained unchanged, while that of the PSO-G increases greatly. This is because there are two local areas where MDs are assembled in Scenario 1, which easily causes the PSO-G to fall into the local optimum. The results fully demonstrate that the PSO-GA-G, which introduces the update operators of the GA, owns a stronger global search capability.

In Scenario 4, all MDs are randomly distributed. Although the performance gap between the PSO-GA-G and the other three baseline methods is reduced, the PSO-GA-G can still achieve the best optimization results.

Next, based on Scenario 1, we test the performance of the proposed PSO-GA-G by changing the number of UAVs. As shown in Fig. 7, as the number of UAVs increases, the average task response time of all these methods decreases. This is because, when more UAVs are deployed, computing tasks are more likely to be offloaded from MDs to UAVs for execution, and the distance between MDs and UAVs also decreases. Compared to the other three methods, the PSO-GA-G can always achieve better performance. Moreover, the decrease of the average task response time has a non-linear relationship with the increasing number of UAVs. When the number of UAVs is less than 10, the computational resources of UAVs are insufficient, and thus the system performance can be significantly improved by increasing the number of UAVs. However, when the number of UAVs is greater than 10, the computational resources of UAVs are already sufficient, and thus the system performance cannot be obviously improved by continuing to increase the number of UAVs.

Fig. 7
figure 7

Average task response time (s) by various methods with different numbers of UAVs

6 Conclusion

In multi-UAV-enabled MEC systems, the response time of the computing tasks from MDs can be greatly reduced by deploying UAVs to provide computation offloading services. In this paper, we propose a two-layer joint optimization method (PSO-GA-G) to jointly optimize UAV deployment and computation offloading. The extensive simulation experiments are conducted to verify the feasibility and effectiveness of the proposed method. The results show that the proposed method can achieve a lower average task response time than other three baseline methods in different scenarios.

The PSO-GA-G can effectively optimize the average task response time, but its training efficiency is not high enough and it may fall into the local optimum when combining the greedy algorithm. In our future work, we will continue to improve the performance of the proposed method according to its limitations. Moreover, we will jointly consider response time and system energy consumption to further research on the optimization problem of resource allocation.