An Algorithm of Mobile Edge Computing O�oading Based on Improved SPEA2 Algorithm

: Internet of things devices can offload some tasks to the edge servers through the wireless network, thus the computing pressure and energy consumption are reduced. But this will increase the cost of communication. Therefore, it is necessary to maintain the balance between task execution energy and experiment when designing the offloading strategy for the edge computing scenario of the Internet of things. This paper proposes an offloading strategy which can optimize the energy consumption and time delay of task execution at the same time. This strategy satisfies different preferences of users. First, the above task is modeled as a multi-objective optimization problem, and the Pareto so-lution set is found by improving the strength Pareto evolutionary algorithm (SPEA2). Based on the Pareto set, the offloading strategy satisfying the requires of users with different preferences by offloading cost estimation. Second, a simulation experiment is carried out to verify the robustness of the improved SPEA2 algorithm under the influence of different main parameters. By comparing with other algorithms. It is proved that the improved SPEA2 algorithm can minimize the balance between task execution delay and energy consumption.


Introduction
With the growth of the number of smart mobile devices and the popularization of 5G network technology，the scale of the Internet of things (IoT) is expanding rapidly [1]. The application requirement of the Internet of things is also improved [2]. IoT devices is facing two problems: limited computing power and small battery capacity, which urgently needs to find a solution [3][4]. Mobile edge computing (MEC) technology is hopeful to become a solution. IoT devices can solve the problems of insufficient processing capacity and small battery capacity by offloading intensive tasks to the edge server [5][6]. Before MEC offloading technology appears, the intensive tasks of IoT devices are usually offloaded to remote cloud processing. However, cloud servers are usually deployed in remote locations, which greatly increases the transmission delay of tasks. Edge servers are usually deployed closer to the device, which can reduce the task transmission delay [7][8][9]. This paper focuses on the problem of computing offloading in the MEC scenario of IoT. Generally, an extensive number of IoT devices are connected to IoT. Simply deploying one edge server in IoT is not enough to handle the intensive tasks generated by a great quantity IoT devices. Therefore, in the Internet of things MEC system studied in this paper, multiple edge servers with different performance are deployed, which is a multi-user multi MEC server system. IoT devices can reduce the energy con-sumption of the device by offloading the intensive tasks to the edge server. However, with the increase of accessed devices, the cost of mission transmission will also increase. Most IoT applications are limited by time delay and energy consumption when designing offloading strategies [10]. Task execution delay or device execution energy consumption is often considered as an optimization index in the MEC offloading problem, while another condition is used as a constraint [11][12][13]. In IoT scenario, some users require low latency, some users require low energy consumption, and even a small number of users require low latency and low energy consumption. If the offloading strategy is designed in the above way, it may not satisfy the requires of all users.
Consequently, when designing the offloading strategy, this paper expects to achieve a balance between the delay and energy consumption of the task execution. The purpose of this paper is to design an offloading strategy that can balance and minimize the execution delay and energy consumption of tasks in the Internet of things MEC system. In this paper, task execution delay and device energy consumption will be optimized simultaneously as a performance index. This is a multi-objective optimization problem [14]. By constructing a multi-user and multi MEC server scenario, this problem is modeled as a multi-objective optimization problem. By improving the operator coding mode and operator crossover and mutation mode of the strength Pareto evolutionary algorithm (SPEA2) [15], the Pareto optimal set the requirements is found. Pareto optimal set is a compromise optimal solution set for the two optimization indexes proposed in this paper. Through the evaluation of the performance indexes proposed in this paper, the offloading strategies that satisfy the requirements of different users can be quickly found from this set.
The main contributions of this paper are as follows:


This paper considers the multi device and multi MEC server system in IoT. Combined with the system scenario constructed in this paper, the local execution process, task transfer process and MEC server execution process are modeled.;


The offloading problem in this paper is modeled as a multi-objective optimization problem. The Pareto optimal set of the multi-objective optimization problem is obtained by the improved SPEA2 algorithm.;


The effectiveness of the improved SPEA2 algorithm is verified by simulation experiments, The performance of the algorithm under the influence of different parameters is analyzed and evaluated. By comparing with other baseline algorithms, the algorithm finds that which can minimize the energy consumption and the time delay of task execution.
The following parts of the article are as follows. The second section introduces recent work related to MEC computing offloading. The third section introduces the MEC system studied in this paper and modeling it. The fourth section introduces the details of the improved SPEA2 algorithm. In the fifth section, the performance of the improved algorithm is verified by simulation experiments. Finally, the sixth section summarizes the work of this paper.

Related Work
Computational offloading is an important technology in MEC, which determines whether the tasks produced by the device are offloaded and which MEC servers are offloaded. In this section, the recent research work and process on this optic will be introduced.
In [  consumption as performance indicators, and found the Pareto optimal solution set to solve the problem by improving NSGAII algorithm. The NSGAII algorithm they use is a typical multi-objective evolutionary algorithm (MOEA) [25]. Such algorithms will eventually get a set of optimal solutions and become Pareto sets. When user preferences change, the offloading strategy satisfying user requires can be found quickly from the Pareto set, which is exactly the same as the purpose of this article. In [23], the performance indicators selected are user satisfaction and provider cost, which are different from the main performance in-dicators considered in this paper. In [24], the scenario of unit centralized cell is mainly considered as a single MEC server scenario, which is different from the MEC scenario of multi device and multi MEC server in this paper.
This article considers a distributed Internet of things MEC scenario with multiple edge devices and multiple MEC servers.
We focus on finding an offloading strategy that can minimize the delay and minimize the energy consumption. This problem is modeled as a multi-objective optimization problem. Through the improved SPEA2 algorithm proposed in this paper, the Pareto optimal solution satisfying the optimization problem is found. The offloading strategy satisfying different user requires can be found quickly from this Pareto optimal solution set.

System Model
In this section, the details of the system model will be introduced in detail. This paper considers an × ( 2 ) MEC system. As shown in Figure  This paper mainly considers the energy consumption and task delay of edge devices in processing tasks. Next, these two problems will be modeled separately.

Communication Model
The tasks of edge devices can be executed locally or unloaded to the MEC server. The energy consumption of the edge device execution task is mainly composed of two parts: the energy consumption of the local execution task and the energy consumption of the transmission task to the MEC server. The delay of task execution is mainly composed of three parts: the delay of local execution task and the delay of MEC execution task and the delay of task transmission [26]. Two tuples = ( , ) is used to represent tasks on device . Here denotes the size of computation input data of task , denotes the required total Table 1. Some parameters and their implications

Notation Description
The set of IoT devices The set of MEC servers The size of computation input data of task The required total CPU cycles to accomplish the task f i l The computation capability of the edge device f j s The computation capability of the MEC server σ i The power consumption coefficient when executing tasks locally The time of the task executes locally The energy consumption of task executed locally T i,j s The execution time of task offloaded to MEC server E i,j s The energy consumption of task offloaded to MEC server Offloading policy ( ) The average time that takes offloading decision to process all tasks ( ) The average energy consumption of edge devices that take offloading decision to process all tasks

Local Computing Model
Calculates the time that the task was executed locally. The computation capability of the edge device is represented by f i l .
Then, the time of the task executes locally is given by: Next, the power consumption coefficient when executing tasks locally is expressed in σ i . Then, the energy consumption of task executed locally E i l is given by:

Edge Computing Model
In general, the performance of the server is better than that of the edge device. The execution time of task offloading to MEC server is mainly composed of three parts: task uploading time, task execution time in MEC server and result feedback time.
Generally, the feedback time is far less than the uploading time and task processing time [27]. Therefore, this paper calculates the time of task processing on the edge server, considering only the uploading time and the execution time of the task.
The transmission rate r i,j of task to server can be given by [28]: Here, W is the channel bandwidth, p i tu is the transmission power of the device , H i,j is the link channel gain between device and MEC server . N 0 is the receiver's noise power density.
The execution time of task offloaded to MEC server includes two parts: task transfer time and task execution time in MEC. The computation capability of the MEC server is represented by f j s . The execution time of task offloaded to MEC server is given by: Here, d i r i,j ⁄ is the task transmission time, c i /f j s is the execution time of the task on the MEC server.
Next, calculate the energy consumption of the task offloaded to the MEC server, consider only the energy consumption of the device, in other words, only consider the energy consumption when the device sends tasks. The energy consumption of task offloaded to MEC server is given by:

Problem Formulation
Use a set of to represent the set of offloading policies, record as = { 1 , 2 , … , }. An element in the collection represents one offloading decision. Specifically, , ∈ represents an offloading policy, expressed as: As in equation (6), the size of the decision matrix is × . Each row vector in the matrix represents the decision vector of the corresponding task. The value of the row vector should be 0 or 1. The sum of the elements of a row vector should not exceed 1. This is because a task can only be offloaded to one MEC server. The − ℎ line in the offloading decision matrix , ∈ is the decision made by the decision against the task of device . If all elements in line are 0, the task is executed locally. If line has and only one element has a value of 1, the task is offloaded to the server ′ execution. Here, ′ is the corresponding column element of element 1 in line .
For , combined with computational modeling, the completion time ( ) of offloading decision processing task is given by: Next, the energy consumption ( ) of offloading decision processing task is given by: In combination with the above, the average time ( ) required to take offloading decision to process all tasks can be given by: Next, the average energy consumption ( ) of edge devices that take offloading decision to process all tasks can be given by:

10)
Finally, the decision problem is described as a multi-objective optimization problem with two objective functions. This problem is represented by 1 and given by: . . 0 < ≤ (12) 0 < ≤ (13) 0 < ≤ (14) , Here, constrained (12) guarantees the computation capability of edge devices. Constrained (13) guarantees the computation capability of the MEC server. Constrained (14) guarantees the transmitting frequency of edge devices. Constrained (15) and (16), as described above, guarantee the rationality of .

Problem Solving Based on Improved SPEA2
The optimization problem 1 proposed in this paper is a multi-objective optimization problem. SPEA2 is a classical multi-objective optimization algorithm. It distributes and selects fitness based on the concept of Pareto dominance, and uses the idea of "k-nearest neighbor" to maintain diversity. Finally, an optimal Pareto solution set will be obtained. The offloading strategy satisfying different user requires can be quickly found from this optimal solution set. In addition, the network size of the MEC system is smaller than that of the traditional network [24]. This feature also reduces the solution space of the problem, so it is possible to use SPEA2 algorithm to solve the offloading problem. At the same time, the SPEA2 algorithm also has the disadvantage of insufficient local search capability. In this paper, an improved SPEA2 algorithm is proposed, which strengthens the local search ability of the algorithm, and uses the improved SPEA2 algorithm to solve the P1 problem.

Initialization Parameter
First, initialize some parameters required for SPEA2 i.e., Initialize a population (size ) and an empty external reserve set ′ (size ′ ), maximum iteration number , crossover probability and mutation probability . And some MEC related data i.e., the number of edge devices is , and the number of MEC servers is .

Chromosome Encoding
In general, the chromosome of traditional SPEA2 algorithm can be an arbitrary number of intervals, and the chromosome genes in this paper need to satisfy the constraints (15) and (16) As shown in Figure 2, this is a population initialized with a size of . It is a MEC system for MEC servers and edge devices. The gene on each chromosome is the offloading strategy of its corresponding edge device. As shown in Figure 2, the first gene of the first chromosome is 3, which means that the task of the edge device numbered 1 is offloaded to the MEC server numbered 3. The second gene indicates that the task of the edge device numbered 2 will be executed locally, etc.

Fitness Assignment
In the SPEA2 algorithm iteration, the fitness value corresponding to chromosomes in and ′ should be calculated. To avoid the situation that individuals dominated by the same archive members have identical fitness values, with SPEA2 for each individual both dominating and dominated solutions are taken into account [15]. Before that, it is necessary to explain the definition of Pareto [14]. Assign an intensity value ( ) to each individual (chromosome) in and ′: In fact, ( ) is to calculate the number of dominant points of point . Based on the value of ( ), the initial fitness ( ) of individual is calculated: In fact, ( ) is the sum of the value of ( ) that dominates the point of . In other words, the point of ( ) = 0 is a non dominated point. The purpose of the algorithm is to find individuals with smaller ( ) values and save them. However, most of the individuals do not dominate each other during the actual operation of the algorithm. Therefore, additional density information is introduced to distinguish individuals with the same original fitness value [15]. The density ( ) of individual is given by: Here, = √ + ′ . The fitness ( ) of is obtained by adding the density of individual ( ) to the original fitness value ( ).

Environment Selection
First, the non-dominated individuals in and ′ (individuals whose fitness is less than 1) is copied to +1 ′ . There will be three situations: 1) The number of individuals in +1 ′ is equal to ′ ; 2) The number of individuals in +1 ′ is less than ′ ; 3) The number of individuals in +1 ′ is greater than ′ .
If it is the case 1, then the environment selection phase ends. In the case of 2, the best dominant individuals in and ′ are copied into +1 ′ to fill the number of individuals equal to ′ .In the case of 3, +1 ′ needs to be truncated. During each interception iteration, the individual that nearest to the ℎ individual is deleted until the number of +1 ′ individuals is equal to ′ .

+1 ′
preserves the outstanding individuals of the previous generation. +1 needs to increase the diversity of the population to prevent the algorithm from falling into local optimization. Therefore, +1 individuals need to be obtained by crossover and mutation from +1 ′ individuals.

Chromosome Crossover
The traditional crossover operator only partially reconstructs two individuals according to a certain cross probability. If the similarity between two individuals is very high, the significance of this cross evolution to population diversity is not large, and the evolution of population will become stagnant and increase the possibility of falling into local optimum [29]. In this paper, the improved SPEA2 algorithm will determine the difference of chromosomes before crossing. Only when the difference is greater than a certain value will crossover and add the result to +1 . The chromosome genes in this paper are all integers with the same chromosome length. The difference between two chromosomes can be judged by calculating Hamming distance [30].
Here, represents Hamming distance between two individuals. The result of Hamming distance is the number of identical genes between two individuals. The smaller the value of , the better. is a similarity threshold. The value of is 1, indicating that these two individuals can crossover. The value of is 0, indicating that the similarity between these two individuals is too high to crossover. It is necessary to find new individuals for crossover operation.

Chromosome Mutation
The traditional SPEA2 algorithm has strong randomness in genetic operation. Although randomness can increase the scope of search, avoid falling into local convergence. But it also weakens the local search ability of SPEA2 algorithm [28]. In order to maintain the global search ability of SPEA2 algorithm and enhance the ability of local search, the mutation individuals are divided into two parts, and two ways are used for mutation.
The individuals in the mutation pool ′ are randomly selected from the +1 ′ . The individuals in the ′ are arranged from small to large according to their fitness . The first half of ′ is considered to be an excellent individual in the mutant pool, and needs to retain their advantages. Formula (7) and (8) are used to calculate the time delay and energy consumption of gene corresponding tasks on chromosome. The two genes corresponding to the minimum time delay and energy consumption are considered to be the dominant genes. In addition to these two dominant genes, one gene is randomly selected to mutate on this chromosome. In this way, the mutation maintains the advantage of the chromosome itself and fine-tuning the chromosome.
For the remaining individuals in ′ , two locations are randomly selected from chromosomes to exchange their corresponding genes. In the exchange process, a certain probability mutation coefficient is introduced. In other words, a gene may mutate in the process of gene exchange, which also ensures the global search ability of the algorithm.

Improved SPEA2 Algorithm Steps
In conclusion, the improved SPEA2 algorithm proposed in this paper solves P1 steps as follows: Algorithm 1： Improved SPEA2

Simulation and Result Analysis
In this paper, experimental comparison is carried out to verify the performance of the improved SPEA2 algorithm in solving the MEC computing offloading problem. The sensitivity of the algorithm under several important parameters is analyzed by experiments. The performance of the algorithm is verified by comparison with some baseline algorithms offloaded by MEC.
This paper mainly uses MATLAB to verify the MEC scenario and algorithm proposed in this paper. The data collected in this paper are as follows: The bandwidth of the wireless channel is set to 20 . The size of the task to be processed and the CPU number needed to execute the task are randomly generated between [1000,3000] and [0.2,0.3] . The processing capacity of the MEC server is generally stronger than that of the edge devices. The MEC server computing capability of this article is [20,40] .The During testing, all variables except the test amount are tested by the median value of the change interval.
For the SPEA2 algorithm, we set the maximum number of iterations to 100, the number of population to 50, and the number of external storage sets ′ to 50. The crossover probability is 0.7, the mutation probability is 0.3, and the mutation probability is 0.001.

The Impact of Number of Edge Devices
The impact of the number of edge devices on the algorithm results will be verified in this section. In the MEC network of this paper, the task to be handled by an edge device is an indivisible and independent whole. When the number of edge devices in the IoT changes, the number of tasks to be processed will also change. In this group of experiments, there are ten different MEC servers in the MEC scenario, and the Pareto solution set of formula (9) and (10) can be satisfied by the improved SPEA2 algorithm. The number of edge devices n = {20, 30, 40, 50} is verified respectively. Pareto front is shown in Figure 4. In this group of experiments, in order to reduce the influence of irrelevant variables, the performance of the MEC server is controlled at [30,35] . In this group of experiments, the number of MEC servers = 10. Through the principle of greedy algorithm, the formula (9) and (10) are optimized respectively, and the greedy limit values GE and GT for single target are obtained. It's shown in Figure 4, The improved SPEA2 algorithm can achieve a balance between GE and GT. This shows that the improved SPEA2 algorithm can find a better offloading strategy for the system. With the increase of the number of access devices, the optimal set is getting bigger. This is because with the increase of the number of edge devices, the task of decision making is also increasing, which increases the dimension of algorithm decision. And the number of access devices will increase, which will also increase the overall communication cost and execution cost of the task.

The Impact of Number of MEC Server
The impact of the number of MEC server on the algorithm results will be verified in this section. In this group of tests, the number of edge devices is set to 30. All variables except MEC server number remain unchanged to reduce the effect of other variables on the experimental results. In this group of experiments, the CPU performance of the MEC server ranges from [20,40] . The results of = {5, 10, 15, 20} are verified respectively, Pareto front is shown in Figure 5. It's shown in Figure 5, the improved SPEA2 algorithm can achieve a balance between GE and GT. This shows that the improved SPEA2 algorithm can find a better offloading strategy for the system. With the increasing number of MEC servers in the access scenario, the algorithm may find new decisions to enable them to find non dominated points with smaller fitness values.
However, as the number of MEC servers increases, the range of values of chromosome genes increases, which also increases the difficulty of algorithm optimization. Therefore, as the number of MEC servers increases, the algorithm may find a more suitable set of solutions, but its search space will also increase.

Offloading Cost Comparison Verification
The improved SPEA2 algorithm proposed in this paper will eventually output a set of Pareto optimal solutions. The offloading strategy that meets different user requirements can be quickly identified from this set. In order to find out the unloading strategy satisfying the needs of different users from the collection, the concept of offloading cost is proposed.
The time delay coefficient and the energy consumption coefficient represent the degree of users requires for delay and energy consumption respectively. Here, + = 1. When users prefer to perform tasks with low latency, a larger value can be obtained. In extreme cases, when takes 1, it means that users only care about the average delay of task execution. Offloading cost is given by: In order to verify the performance of the improved SPEA2 algorithm, we use formula (22) to calculate and find out the minimum offloading cost of each generation External storage set +1 ′ in the algorithm iteration process. When handling different numbers of tasks, the offloading cost varies with the number of iterations, as shown in Figure 6. As shown in Figure 6, the value of decreases as the number of iterations increases. This shows that the improved SPEA2 algorithm continuously finds better solutions when the number of iterations increases.
Finally, we use the offloading cost formula (22) to find out the minimum offloading cost from the set of Pareto optimal solutions exported from the improved SPEA2 algorithm. This minimum value is compared with the results of other baseline offloading algorithms to verify the optimization ability of the improved SPEA2 algorithm. The contrast algorithm includes local algorithm, MEC random offloading algorithm, and greedy based MEC offloading algorithm. Here, the local algorithm is that tasks are executed locally only. MEC random offloading algorithm, namely, tasks will be randomly offloading to the MEC server and cannot be executed locally. Greedy based MEC offloading algorithm is based on greedy algorithm to find the optimal solution for the current task's current goal. Three algorithms are used to calculate the formula (9) and (10)   From Figure 7, it is easy to see that when considering the time delay and energy consumption of task execution, the offloading cost of LOACL algorithms is the highest. MEC random offloading algorithm can reduce the offloading cost of users to a certain extent, but because of its randomness, it is impossible to ensure that the optimal unloading strategy is obtained. The im-proved SPEA2 algorithm and the greedy based MEC offloading algorithm have little difference in the offloading cost. This shows that the improved SPEA2 algorithm can achieve the requirement of user execution delay and energy consumption minimization.
Greedy based MEC offloading algorithm can only calculate the optimal solution of a single target alone, and finally evaluate its offloading cost by weighting. The algorithm does not consider the influence between targets in computation. Moreover, when user preferences change, it is necessary to re run the algorithm to find a user satisfaction offloading strategy. The Pareto set obtained by the improved SPEA2 algorithm is aimed at the equilibrium optimal solution of the two objectives. When user preferences change, the offloading cost formula (22) can be used to quickly find an offloading strategy to meet user needs from the Pareto set.

Conclusions
This paper studies the computing offloading problem in the MEC system of the Internet of things. Based on the requirements of IoT scenario, we hope to design an offloading strategy which can optimize the execution time and energy consumption of devices simultaneously. The Pareto optimal solution set of this multi-objective optimization problem is found by the improved SPEA2 algorithm proposed in this paper. Combined with the offloading cost formula proposed in this paper, the offloading strategy satisfying different user needs is quickly found from Pareto solution set. In this paper, the performance of the improved SPEA2 algorithm is verified by simulation experiments. The simulation results show that the improved SPEA2 algorithm can get the Pareto optimal set between the extremes of the two targets. In addition, by studying the performance of the improved SPEA2 algorithm under different parameters, the robustness of the improved SPEA2 algorithm in MEC offloading problem is verified.