Joint Social-Aware and Mobility-Aware Computation Offloading in Heterogeneous Mobile Edge Computing

With increasing computation-intensive tasks of various applications running on mobile devices, the limitation of computing resources and battery capacity on mobile devices makes it impossible to meet the users’ Quality of Service (QoS). Fortunately, with the emergence of mobile edge computing (MEC), mobile devices can offload tasks to edge servers to efficiently solve the above problems. However, meeting the users’ QoS requirements with the help of deployed MEC facilities is still challenging since mobile users’ service demands vary depending on their dynamic location. In addition, increasing the number of edge servers to meet the requirements of applications would burden the initial investment and maintenance fee accordingly. In this case, using idle resources from nearby mobiles may become an effective solution. Most of the existing works do not consider the mobility of devices and users’ willingness to share. Therefore, in this paper, we propose the mobile device selection algorithms (MDSA), in which the social relationship, location correlation, and mobile activity of mobile devices were considered in the selection of target mobile devices, providing device-to-device offloading. In addition, we propose the joint social-aware and mobility-aware computation offloading algorithm (JSMCO) based on the improved Kuhn–Munkres (KM) algorithm to obtain a resource allocation strategy that minimizes the energy consumption while satisfying the minimum latency condition. The proposed algorithms have been verified to reduce the offloading success rate and decrease the users’ time and energy consumption in extended real datasets.


I. INTRODUCTION
Augmented reality, natural language processing, virtual reality [1]- [3], and other similar applications require high computing capability; thus, they have higher performance requirements for mobile devices. However, due to the limitation of the physical size of mobile devices, the resources (computing resources and battery capacity) of mobile devices are usually limited [4]. Cloud computing [5] allows users to migrate computation-intensive tasks to the cloud, thus improving the performance experience and reducing the energy consumption of mobile devices. However, the service The associate editor coordinating the review of this manuscript and approving it for publication was Pedro R. M. Inacio . quality of cloud computing is significantly affected by the network status. Moreover, as the number of tasks increases, the processing delay also increases. As a result, offloading tasks from mobile devices to the cloud are faced with high latency.
Mobile edge computing (MEC) is an appropriate solution to the problem in cloud computing [6], [7]. An emerging paradigm reduces latency by offloading tasks to edge servers close to users rather than to cloud servers [8]. Because MEC is implemented at the edge of the network, it provides low latency and flexible computing services for device users. However, there are more mobile devices and more offloading task requirements in urban hotspots, and the processing capacity of the edge server cannot be dynamically adjusted according to the users' needs. If many edge servers are deployed, hardware resources will be wasted. Conversely, if the deployed edge servers are insufficient, they cannot cope with the requirements for task offloading. There are many idle computing resources among mobile devices. Suppose the tasks that the edge server cannot handle can be offloaded to idle mobile devices. In this case, the problem of insufficient processing capacity of the edge server can be solved [9], [10].
However, offloading tasks to nearby mobiles may consume their valuable battery power and computing resources as well as increase security risk, raising the issue of low willingness to share resources among mobile users [11], [12]. Therefore, promoting cooperation and improving user participation have become important issues [13]- [15]. On the other hand, the location of mobile devices varies, and each mobile device has different computing resources to use. Task offloading will fail when the selected device cannot complete the calculation or return the results on time; thus, finding a suitable mobile device to complete the task of computing offloading is also a complex problem. In addition, when dealing with many tasks with different requirements, allocating them efficiently is also a problem that needs to be solved [16], [17] because failure to allocate them rationally can lead to waste of resources and many tasks not being completed on time. Therefore, it has become challenging to utilize the powerful computing capabilities in the cloud, the advantage of ultra-low latency at the edge, and the computing resources provided by idle mobile devices.
Social networks are a continuation of real social relationships, and users with social relationships [18] are more willing to share resources on social networks. Therefore, the social relationships between users could be used to measure their willingness to share computing resources. The mobility of users affects the selection of offloading devices [19]. To select the appropriate device that provides computation offloading, we proposed the mobile device selection algorithms (MDSA) by combining social relationships and mobility (location correlation and mobile activity).
The cloud has powerful computing capability, the edge can provide ultra-low latency services, and the resources of idle mobile devices can solve the problem of insufficient computing resources in hotspots. Therefore, combined use of the above resources can meet the needs of mobile devices, which has practical significance. However, flexibly allocating these resources according to the actual environment becomes a problem that needs to be solved. We propose the joint social-and mobility-aware computation offloading (JSMCO) algorithm to solve this problem.
Our contributions are summarized as follows: • We considered a multitier system with multiusers, multiple edge servers, and a cloud server. We established a social relationship to describe the relationship between users and measured their willingness to share. In addition, we considered the mobility of users in the system to make the offloading strategy more suitable for realworld scenarios.
• We proposed an MDSA that integrates social relationships, location correlation, and mobile activity attributes to select the appropriate node to provide offloading services according to the actual requirements.
• We proposed a multiobjective optimization-based JSMCO algorithm to assign resource allocation under multiple offloading methods and multiple offloading tasks conditions.

II. RELATED WORK
This section provides an overview of works related to edge computation offloading, D2D computation offloading, and joint social-aware computation offloading. MEC can provide computing and storage services close to the terminal devices at the network's edge. Its advantage is that it reduces device energy consumption and computing time. For these reasons, MEC research has received a considerable attention from academia and industry.
Chen et al. [20] studied task offloading in software-defined ultradense networks. They proposed a method to minimize the delay while saving the battery life of user equipment. Guo et al. [21] proposed a two-layer game-theoretic greedy offloading scheme to solve the mobile edge computation offloading problem in ultradense Internet of Things networks. They also verified that the approach has certain advantages under the conditions of computation offloading among multiple edge servers. Dinh et al. [22] proposed an optimization framework for offloading from a single mobile device to multiple edge devices. This framework minimizes the processing delay of all tasks and the energy consumption of mobile devices by jointly optimizing task allocation decisions and the frequency of the central processing unit (CPU) of the mobile device. You et al. [23] studied resource allocation in a multiuser MEC system based on time-division multiple access and orthogonal frequency-division multiple access. Zhao et al. [24] studied the problem of computation offloading from multiple mobile devices to one mobile edge server to minimize energy consumption. They proposed a branch delimitation approach based on the reconfiguration linearization technique (Gini coefficient-based greedy heuristic) and a greedy heuristic algorithm based on the Gini coefficient. Ning et al. [25] proposed an iterative heuristic MEC resource allocation algorithm that combined cloud computing and MEC. The algorithm can make offloading decisions dynamically to optimize processing latency and offloading efficiency. Ren et al. [26] proposed a collaborative cloud edge computing scheme with federated communication and computing resources to improve the efficiency of edge clouds under the condition of limited communication and computation capacity. Xu et al. [27] proposed a computation offloading algorithm based on a neural network task model and presented an adaptive task scheduling algorithm using an improved ant colony algorithm. A cloud edge collaboration framework for distributed neural networks was proposed based on the above algorithms. Zhao et al. [28] proposed a cloud edge collaboration approach by jointly optimizing computation offloading decisions and computing resource allocation, which can offload services to vehicles in an in-vehicle network.
Ahani and Yuan [29] proposed the use of BS to assist D2D offloading (BS acts as a relay for task distribution and result collection) and adopted the Lagrangian duality algorithm to balance the increased overhead and reduce the computation offloading time. Lin et al. [30] used D2D offloading and local offloading to minimize the total energy consumption. Xing et al. [31] studied a multiassisted MEC system that supports D2D offloading. They proposed a heuristic scheme for joint optimization of wireless communication, computing resources, and tasks allocation. Xie et al. [32] proposed a computation offloading scheme for precedence-constrained tasks with the aim of minimizing the time consumption and computing cost of computation offloading.
He et al. [13] proposed an incentive mechanism based on an online auction where the users' mobile devices dynamically participate in the system, which can obtain better unloading decisions without future information. Pu et al. [33] proposed an online incentive-aware task offloading framework, which ensures that the computing resources obtained by mobile devices from other mobile devices do not exceed their contribution. Jin et al. [33] proposed a multimarket dynamic double auction mechanism (mobiauc) to promote fair resource exchange. Li et al. [34] regarded the collaborative task offloading problem as a social welfare maximization problem and used a prime dual framework to develop an online incentive mechanism for the execution of the tasks. It considers the dynamic participation characteristics of the users' mobile devices. Saha et al. [35] designed an incentive mechanism to improve user participation, considering mobile device resource allocation and reputation. Noor et al. [36] proposed a cell cloud architecture, which refers to the reputation-based economic incentive model, encouraging mobile users to actively share their mobile device resources. Qiao et al. [14] proposed a reputation-based consensus mechanism (Proof of Reputation) so that the proposed computing scheme can be safely and effectively deployed in the device-to-device edge computing networks (D2D-ECN) framework. Chatzopoulos et al. [15] put forward a framework of joint incentive mechanism and reputation mechanism so that the devices participating in cooperation can obtain corresponding rewards, whereas the selfish devices are punished accordingly to achieve a better computing unloading effect. Roostaei et al. [37] proposed a mobile cloud computing framework supporting device-todevice. At the same time, to encourage mobile devices to contribute to the D2D cloudlet, an incentive mechanism based on credit and reputation was developed. The incentive mechanism uses a second-price reverse auction to measure the value of resources in the D2D cloudlet.
Cao et al. [9] leveraged social-aware to select the sharing of idle communication and computing resources among mobile users to reduce energy and communication resource consumptions. In addition, they proposed a joint task-data offloading framework and a matching-based and game theory-based scheme to resolve the association between mobile devices. Chen et al. [38] proposed a D2D crowd framework in which network edge devices use networkassisted D2D collaboration to share computing and communication resources so as to reduce energy consumption. To reduce the task computing time and energy consumption, Ciobanu et al. [39] proposed transferring data and computing from mobile devices to the cloud, fog nodes, or other mobile devices. Chen et al. [40] proposed considering social relationships as an essential factor for collaborative computation offloading and taking the minimum weight of a perfect bipartite graph as the decision-making method of multitask computation offloading. Yu et al. [41] proposed a hybrid multicast-based task offloading framework that uses social-aware to establish D2D connections and reduces energy consumption through the task assignment strategy of the framework.
In [20]- [28], only one local computing, edge server computing, cloud computing, or cloud edge collaboration can be selected for offloading computation. Computation offloading using this strategy in urban hotspots will cause a high network load and insufficient server resources. If idle mobile terminal resources can be fully utilized, the efficiency of computation offloading will be improved. D2D communication has become a hot research topic [29]- [32], which does not rely on local base stations but uses physical proximity to reduce end-to-end latency and energy consumption. However, due to the increasing number of mobile devices, the demand for mobile devices for computation offloading is also increasing, which leads to several problems in the use of mobile devices for computation offloading or data transfer. On the one hand, using other mobile devices for computation offloading can pose security risks. Alternatively, mobile devices have a lot of idle computing resources; however, they are unwilling to provide computation offloading to everyone. [13]- [15], [33]- [37], [42] have considered cooperation between devices, incentive mechanism, reputation or a combination of incentive mechanism, and reputation. The above methods can improve the users' effective participation and cooperation, but these methods have higher system overhead and more complex operability. The studies in [9], [38]- [41] considered social-aware for computation offloading, but none considered the mobility of users. Mobile device locations are dynamically determined by user behavior, unlike cloud or edge servers, where the location is relatively constant. Therefore, this paper considers mobility (location correlation and mobile activity) and social-aware while combining cloud servers, edge servers, and mobile devices for offloading computation.

III. SYSTEM MODEL AND PROBLEM FORMULATION
In this section, we first built a task model, task computing model, social relationship model, location correlation model, mobile activity model, and energy consumption minimization problem formulation.
As presented in Fig. 1, we considered a system model with multiuser, multi-edge and cloud servers, where the set of mobile devices can be denoted as M = {1, 2 . . . . . . , M}. Each mobile device location is not fixed, they can move in the area covered by the base stations, and different base stations in different locations can serve them. We assumed that all mobile devices could communicate with wireless base stations and with each other by D2D. When the mobile device handles computation-intensive tasks or latency-constrained tasks, the mobile device can perform computation offloading according to actual conditions. Mobile devices can transmit tasks to the edge or cloud server for computation offloading through the wireless base station. Tasks can be offloaded to other mobile devices when other mobile devices are available. The mobile devices can assist other mobile devices in offloading tasks to the edge or cloud server when far from the base station. In Fig. 2, we also assumed that the relationship between mobile devices is based on the social relationship between users.
The detailed system model is as follows: A. TASK MODEL We represent the task as a quadruple < λ i , ψ i , µ i , lt i >; parameter λ i indicates the size of the input data for the task of device i; parameter ψ i , the required computing resource (we use the number of CPU clock cycles needed to indicate the required computing resources); µ i , the size of the output data; and parameter lt i , the task processing time limit. The task processing time limit represents the maximum time allowed to complete the task, and the task must be processed within this time to satisfy the requirements of the mobile device. The task processing time is determined by finding the ratio of the required computing resource per task to the CPU performance of the device, which can be defined as follows: where f i denotes the computing power of device i using the CPU frequency (number of clock cycles per second) as the computing unit. If the same devices consume the same amount of energy consumption per unit of time, the energy consumption ρ i can be calculated based on the task processing time, and it is defined as follows: ρ ec i denotes the energy consumption generated by the computation of device i per unit time, and t i denotes the time required for the task computation.

B. TASK COMPUTING MODEL
As a result of the different computing capabilities of cloud servers, edge servers, and mobile devices, the delay and energy consumption are also different. Comprehensive utilization of these computing resources is necessary to obtain better offloading results. Meanwhile, we will define the energy consumption and the delay associated with each strategy to evaluate offloading strategy.
Since this paper mainly considers the effects of social relationships, location correlation, and mobile activity on the computation offloading results, signal fading will not be considered in the data transmission. Figure 3 presents the computation offloading.

1) LOCAL OFFLOADING (LO)
Energy consumption is determined by the energy consumption of the local device and the computing time of the task when a local device processes the task. The diagram is presented in Fig. 3(a). The local offloading energy consumption is defined as follows: Because the task was locally processed, its processing time only depends on the performance of the device and the amount of task calculation. Therefore, the task processing time is calculated as follows: In Fig. 3(a), x i i determines whether the task is locally processed: if the task T i is processed locally 0; otherwise (5) VOLUME 10, 2022 FIGURE 2. Illustration of the connection between users, social relationship, and device relationship.

2) DIRECT CLOUD OFFLOADING (DCO)
Since task offloading aims to increase the processing speed and reduce the energy consumption of the mobile device, the energy consumption of the cloud is not considered. When offloading tasks to the cloud, the energy consumption includes the energy consumption of the mobile device sending data to the cloud server and the mobile device receiving the processing result from the cloud, which is schematically presented in Fig. 3(b). It can be defined as follows: where EC s i,c denotes the power of mobile device i to send data to the cloud, and EC r i,c denotes the power of mobile device i to receive data sent from the cloud.
When offloading tasks to the cloud, the time consumption includes the transmission delay between the mobile device and cloud server and the processing delay of the cloud server. Therefore, the task processing time t i,c is defined as follows: where f c i indicates the computing capacity that the cloud server allocates to node i; λ i /R i,c , the time of sending data from the mobile device to the base station; µ i /R c,i , the time of receiving data from the mobile device; R c1,c2 , the data transmission rate between the base station and the cloud server; and s c1,c2 , the distance between the base station and the cloud server. In Fig. 3(b), x c i determines whether the task is offloaded to the cloud: If the task T i is offloaded to the cloud server c 0; otherwise (8)

3) DIRECT EDGE OFFLOADING (DEO)
The computing power of the edge server is not as strong as the cloud server, but its proximity to the mobile terminal makes the propagation delay lower than the cloud server. When the edge server processes the task, its energy consumption is equal to the sum of the energy consumption of the mobile device sending the data to the edge server and receiving the data result from the edge server. Its schematic is presented in Fig. 3(c), and its energy consumption is defined as follows: where EC s i,e denotes the power sent by a mobile device to the edge server; R i,e , the rate sent by a mobile device to the edge server; EC r i,e , the power of the mobile device to receive data from the edge server; R e,i , the reception rate.
The time consumption includes the time delay in sending and receiving data and the time delay in processing data by the edge server. The time consumption t i,e can be defined as follows: where f e i denotes the computing capacity of the edge server. In Fig. 3(c), the x e i determines whether the task is offloaded to the edge: D2DO is a strategy for computation offloading using idle mobile devices. Its data transmission can be done without cellular networks, and it accomplishes computing tasks without cloud or edge servers. The energy consumption of D2DO consists of the energy consumption of the mobile device for sending and receiving data and the energy consumption of the mobile device for completing the computation task. The schematic is presented in Fig. 3(d), and energy consumption EC i,j is defined as follows: where EC s i,j denotes the power of mobile device i to send data to j; EC r i,j , the power of mobile device i to receive data from j; and R j,i , the transmission rate between node i and j. The transmission rate is determined by the type of wireless transmission network (Bluetooth, WLAN) used between node i and j.
The time consumption of D2DO is related to the sending time of mobile device i, the computing time of mobile device j, and the receiving time of mobile device i. We define the time consumption t i,j as follows: In Fig 3(d), the x j i determines whether the task is offloaded to other mobile devices: When mobile devices cannot transmit data directly to the cloud server for computation offloading, other devices can be regarded as a relay to transmit data to the cloud server. Figure 3(e) presents the diagram. The energy consumption of D2DCO consists of device i sending data to j, mobile device i receiving data from j, mobile device j sending data to the cloud server, and mobile device j receiving data from the cloud server. The energy consumption EC i,j,c for D2DCO can be expressed as follows: where EC s j,c denotes the power of mobile device j to send data to the cloud, and EC r j,c denotes the power of mobile device j to receive data from the cloud.
The time consumption of D2DCO includes mobile device i sending data to j, mobile device i receiving data from j, mobile device j sending data to the cloud server, mobile device j receiving data back from the cloud server, and the time consumption required for cloud server calculation. The time consumption of D2DCO t i,j,c can be defined as follows: Fig. 3(e), the x j,c i determines whether the task is offloaded to the cloud with the help of other mobile devices: The signal transmission range of edge servers is limited; therefore, computing resources available to different edge servers are different so that D2DEO can provide a better quality of service (QoS) and a more reasonable allocation of computing resources. Figure 3(f) presents a schematic of D2DEO. The energy consumption is related to mobile device i sending data to j, mobile device i receiving data from j, mobile device j sending data to the edge server, and mobile device j receiving data back from the edge server by analysis. Thus, the energy consumption EC i,j,e for D2DEO can be expressed as follows: The time consumption of D2DEO includes sending data from mobile device i to j, receiving data from mobile device i to j, sending data from mobile device j to the edge server, receiving data from the edge server to mobile device j, and computing by the edge server. The time consumption t i,j,e can be defined as follows: The concept of community is often used to describe social relationships, where nodes (users) with similarities (interests, behaviors, etc.) are grouped into a community. Nodes within the same community are more closely related than those from different communities. Therefore, to describe the social relationship between nodes, we consider the similarity between nodes and communities as well as the similarity between nodes and nodes to model social relationships. This paper presents the social similarity [42] between users by the weight matrix calculated from social relationships. This matrix reflects the closeness of social relationships between mobile devices, and the weight matrix A is expressed as follows: (21) where N de denotes the number of mobile device nodes, including edge devices, a i,j ∈ [0, 1] , a i,j = 0 indicates that device i and j are not socially related, and a i,j = 1 indicates that the social relationship is closely related. Since social relationships are directional, a i,j is different from a j,i (e.g., we recognize celebrities, but they usually do not recognize us). The social similarity attribute determines the value of a i,j . In this paper, a i,j is determined by the similarity between node and community and between nodes. It can be defined as follows: CS i,j indicates the similarity between node i and community C j (the community where node j is a member), and NS i,j indicates the similarity between node i and j. η is a variable parameter that adjusts the importance of CS i,j and NS i,j .
The similarities between nodes and communities can be used to reflect the relationship between them [43]. The similarity between communities CS i,j is defined as follows: Using (5), we can calculate the similarity between user i and community C j . k denotes the attribute set of nodes i, and k denotes the attribute set of community C j . γ i,j represents the intersection of the social relationship attribute set of the node i and the community j : The similarity between nodes reflects attributes similarity between nodes, which is defined as follows: where i,j indicates the intersection of social relationship attributes between user i and user j.

D. LOCATION CORRELATION MODEL
The exact location of people's movements is uncertain, but the areas frequently visited (e.g., home and office) are relatively fixed. They will stay a long time in these areas. If the mobile devices are selected for computation offloading, they will be more likely to complete it. Therefore, by considering the location correlation when selecting the offloading nodes, better offloading results can be obtained. In this paper, the position relationship matrix represents the position relationship between nodes. The relationship matrix can reflect the location correlation between the served node and the service node. It reflects whether the service node is in a frequently active area. Thus, the relationship matrix can find more suitable server nodes. The position relationship matrix is defined as follows: (27) where N d denotes the number of mobile device nodes. The variable b i,j is defined as follows: When it is satisfied that node i and j are in the same area, and j is in a frequently active area, b i,j is equal to 1; otherwise, it is equal to 0. ρl i indicates where the device i is located, and Area j denotes the area where j is frequently active.
The regions are divided by geographical location, and n represents the number of regions.

E. MOBILE ACTIVITY MODEL
Mobile activity indicates the degree of activity, and higher activity indicates that the user's location changes fast, which means that the user stays in a fixed area for less time. This type of user is more suitable for less computationally demanding tasks. We use Mob i ∈ [0, 1] to represent mobile activity.
where ρl i denotes the location of the user; dur, the duration of the user at the current location; and date, the date of the user at the current location. Mob i is obtained by analyzing the user's movement track data.

F. POWER CONSUMPTION
Under the condition of guaranteed delay, we will find the offloading strategy with the lowest energy consumption. The sum of energy consumption EC is defined as follows: where EC i is the energy consumption for local computing; EC i,c , the energy consumption of DCO; EC i,e , the energy consumption of DEO; EC i,j , the energy consumption of D2DO; EC i,j,c , the energy consumption of D2DCO; EC i,j,e , the energy consumption of D2DEO,; and M, is the set of mobile devices.
Then, the optimization objective is defined as follows: The constraint in (32a) ensures that the sum of the server resources used cannot exceed the computing resources owned by the edge server. The constraint in (32b) ensures that each task can only be calculated by one offloading mode. The constraint in (32c) guarantees that the offloading task cannot be transmitted to nodes outside of the transmission range. The constraint in (32d) ensures that the task processing time cannot exceed the maximum delay.

IV. JOINT SOCIAL-AWARE AND MOBILITY-AWARE COMPUTATION OFFLOADING (JSMCO)
The JSMCO algorithm mainly addresses the problem of energy consumption minimization under the condition of meeting the task latency. In the algorithm, we considered the social relationship, location correlation, and mobile activity while also making full use of idle resources and realizing the collaborative work of cloud, edge, and mobile devices. Figure 4 presents the procedure of offloading strategy. The left side of the figure shows the tasks generated by the mobile device node; the right side, the ways that each task can be offloaded; the middle line, the offloading nodes that the task can choose; and the weight of the line, the energy consumption required for offloading. Therefore, we can transform the optimization problem in this paper into the matching problem of solving weighted bipartite graphs. The improved Kuhn-Munkres (KM) algorithm can handle this problem very well, so the objective function (32) can be transformed into the improved KM algorithm to solve the weighted bipartite graph.

A. FUNDAMENTALS OF THE IMPROVED KM ALGORITHM
The KM algorithm [44] is used to solve the weighted bipartite graph matching problem. It transforms the problem of finding the maximum weight match into finding the perfect match of the bipartite graph and finally obtains a maximum weight perfect match.
It can be seen from Fig. 4 that the task generated by the mobile device node corresponds to a part of the bipartite graph. A mobile device node that can complete the task, edge, and cloud corresponds to another part of the bipartite graph. The connection between the task and offloading method nodes represents the offloading method that the task can adopt and the energy consumed by offloading. Therefore, we can convert the minimization optimization problem to the minimum weight matching of the bipartite graph. When using the KM algorithm for bipartite graph matching, the number of nodes at both ends of the bipartite graph must be the same, and the maximum weight matching is calculated, which is inconsistent with the conditions in this paper. Therefore, in this paper, the KM algorithm could not be used directly, so the optimized KM algorithm [45] was used instead. First, the virtual task node and the weight between the virtual task node and the offloading method were introduced to satisfy the condition that the left and right nodes of the bipartite graph are equal, and then the matching of the maximum weight of the bipartite graph was transformed into the matching of the minimum weight.

B. JSMCO ALGORITHM
The JSMCO algorithm is used to minimize energy consumption to meet the minimum-delay demand. It needs to use the MDSA to obtain the optimal auxiliary unloading mobile device nodes and the optimized KM algorithm to obtain the optimal offloading strategy. The pseudocode of the algorithm is as follows: Algorithm 1 is used to find the optimal computation offloading strategy to obtain the least-energy consumption while satisfying the time delay. The algorithm can be divided into nine steps: (1) obtain the list of task nodes and the available resources (cloud, edge, and mobile devices); (2) obtain a set of nodes around the task node that can assist in offloading according to the current time and the task node; (3) obtain all the offloading methods available for the task nodes; (4) get the optimal offloading node using algorithm 2; (5) calculate Algorithm 1 Joint Social-Aware and Mobility-Aware Computation Offloading Algorithm

Initialization
get TaskList () Get a list of task nodes get Resource () Getting cloud, edge, and mobile device available resources end initialization For all TaskList do 2. procedure getUnloadedNode() Get the nodes around a task node end procedure 3.
procedure disIsSuitable () Get all available offloading methods for the current task end procedure procedure OptAssNode()

4.
Obtain the best assisted offloading node for the current task via algorithm 2 end procedure 5. Procedure energyCo () Calculate the energy consumption of all offloading methods end procedure Procedure timeCon () Calculate the time consumption of all offloading methods end procedure End For 6. procedure getAllTaskUnloadReList() Obtain offloading methods and results that meet the requirements end procedure 7. procedure dataConversion () Data Conversion end procedure 8. procedure UnloadingOptimization () Obtain weight-minimizing offloading methods end procedure 9. procedure Unloading () Computation offloading according to the offloading scheme and calculation of the offloading time and energy consumption end procedure the energy and time consumption of the offloading strategy that meets the offloading time requirements; (6) obtain the initial offloading results for all tasks; (7) transform the offloading result for calculation; (8) obtain the offloading strategy that minimizes the energy consumption by the minimum weight matching of the improved KM algorithm; and (9) calculate the offloading according to the offloading strategy in the previous step.

C. MOBILE DEVICE SELECTION ALGORITHMS (MDSA)
We select the optimal offloading mobile device nodes based on three factors, namely, social relationship, location correlation, and mobile activity. Considering the combination of these factors, it is possible to select a more appropriate mobile device that provides computation offloading. This paper assigns weight to social relationships, location correlation, and mobile activity. The core formula om I,j of the MDSA is expressed as follows: ∂, β, and δ are variable parameters, which are adjusted according to the actual demand.

1.initialization:
Initializing the values of the ∂, β, δ parameters of the mobile device selection algorithms. end initialization 2.procedure ParserData () Parsing datasets to obtain social data, trajectory data, interaction data. The MDSA is used to obtain the optimal mobile device for providing offloading services. The algorithm can be divided into seven steps: (1) initialize the parameters according to the optimized parameter values obtained from the experimental results; (2) parse the data from the dataset; (3) select the offloading task node and the initialization task; (4) create tasks based on initialization parameters; (5) obtain the list of contact nodes according to the offloading time and the offloading task node; (6) calculate the social relationship, location correlation, and mobile activity and then used om i,j to obtain a matching set; and (7) obtain the optimal node that provides offloading service.

V. NUMERICAL RESULTS
An extended real dataset was used to evaluate the performance of the MDSA and JSMCO algorithms proposed in this paper. The performance of the algorithms cannot be thoroughly evaluated since relatively few mobile devices were available in the real dataset to assist with offloading. Therefore, the dataset was expanded following the distribution law of the original data. The dataset used was based on the upb-hyccups2012 [39], [46] dataset from a social tracking experiment conducted at Politehnica University, which recorded the interactions between the experiment participants and showed that their social relationships are based on their Facebook profiles. The dataset social relationship network is presented in Fig. 5.
The dots in Fig. 5 represent each node in the dataset, and the different sizes indicate the degree of the node [47]. Larger nodes indicate a greater degree, which means stronger social relationships. The lines between nodes indicate the social relationships between nodes, and the nodes with different colors belong to different communities. We compared the performance of the proposed MDSA and JSMCO algorithms using the following baseline algorithms.
The social relationship algorithm [40] considers the social relationship between mobile devices. They present a socialaware bipartite matching-based cooperative task offloading algorithm by incorporating social tie structure into the device computation and network resource-sharing processes. However, the algorithm does not consider the mobility characteristics of the devices.
The randomized algorithm does not consider user social relationships. When computation offloading is required, the algorithm randomly determines the computation offloading strategy, and the result is uncertain. We used the average value of 100 experimental results as the final result since the randomized algorithm is very unstable. The experiments included only a single-hop D2D communication, and multihop was not considered.
To evaluate the success rate of computation offloading, computation offloading latency, and computation offloading energy consumption, we conducted experiments to determine the task density and size factors.

A. IMPACT OF TASK DENSITY
By adjusting task density ρ (the ratio of tasks to helper device), we observed the effect of D2D offloading on the offloading success rate, energy consumption, and time delay. The task density ρ i can be expressed as follows: TN i denotes the number of task nodes in region i, and Sum i denotes the number of nodes in region i that can assist offloading. When ρ is lower, the task can choose more assistance nodes. Conversely, the task can choose fewer assistance nodes.
The D2D offloading success rate ω can be expressed as follows: ω = sum suc /sum all (35) sum suc denotes the number of successful offloading tasks; sum all , the total number of offloading tasks; and ω, the probability that the task assigned to the first offloading node can complete the offloading task.
In this experiment, the randomized algorithm randomly selects the assistance nodes based only on the nodes found. The algorithm based on the social relationship selects nodes according to the closeness of their relationship, and it gives preference to nodes with closer relationships for computation offloading. The proposed MDSA considers social relationships, location correlation, and mobile activity. In the experiment of task density factor, we set ∂ = 3, β = 1, δ = 1, η = 0.3.
In Fig. 6(a), all algorithms maintained a 100% offloading success rate as the task density increases when the task is a low-computing-requirement task. Because all the assistance nodes around the task node can complete the offloading task, selecting any assistance nodes will yield the same result. Figure 6(b) and (c) demonstrates that the offloading success rate decreases as the task density increases. The offloading success rate of the randomized algorithm starts to decrease at ρ = 0.2; the offloading success rate of the social network-based algorithm starts to decrease at ρ = 0.5 and ρ = 0.3, respectively; and the offloading success rate of the MDSA starts to decrease at ρ = 0.8 and ρ = 0.6, respectively. Meanwhile, Fig. 6(b) demonstrates that the offloading success rate of the social network-based algorithm at ρ = 0.7 and ρ = 0.8 is higher than that of ρ = 0.6. This is because the social network-based algorithm does not consider the mobility of mobile devices.
The experimental results in Fig. 7(a) indicate that the energy consumption of the three algorithms is the same for the low-computing-requirement task. In Fig. 7(b), the energy consumption of the JSMCO and social network algorithms are similar when the task density is in the interval of 0.1-0.5, and the energy consumption gap is more apparent when the task density is in the interval of 0.6-0.7 and 0.8-1. It can also be seen in Fig. 7(c) that the JSMCO algorithm consumes less energy compared with the other two algorithms.  The experimental results in Fig. 8(b) and (c) indicate that the JSMCO algorithm has a shorter time overhead than the other two algorithms when solving medium-and highcomputing-requirement tasks. Moreover, when the task density is in the middle part, the JSMCO algorithm offers more apparent advantages than the other two algorithms.
When the task density is in the range of 0.1-0.2, the computation offloading of the task is mainly performed by the edge servers, so their energy consumption gap is relatively small. When the task density is in the range of 0.2-0.8, the mobile devices are more involved in computation offloading, so the energy consumption advantage is more obvious. When the task density is in the range of 0.8-1, the selection of mobile devices available is relatively small, so the energy consumption gap tends to be stable. This also shows the superiority of the JSMCO algorithm.

B. IMPACT OF TASK SIZE
Different users have different offloading requirements. Therefore, to better accommodate the needs of different users, the task offloading strategy should be able to handle the offloading requirements of different task sizes. In the experiment of task size factor, we set ∂ = 3, β = 1, δ = 1, η = 0.3.
The results in Fig. 9(a) indicate that the MDSA and social network algorithms have the same offloading success rates   when the task density is 10%. However, the randomized algorithm is relatively low, and its results are unstable. Figure 9(b) demonstrates that the MDSA is consistent with the social network algorithm when the task density is 60% and the task size is relatively low (1-2 M). When the task size exceeds 3 M, the offloading success rate of the social network algorithm starts to decrease. The offloading success rate of the MDSA starts to decrease only when the task size exceeds 7 M. The results in Fig. 9(c) indicate that the offloading success rate of all three algorithms significantly decreases when the task density is 90%.
The MDSA performs better than the other two algorithms with varying task densities and task sizes according to the above experimental results. The reason is that the randomized algorithm uses a random way to select the offloading nodes, and the social network-based algorithm does not consider the mobility characteristics of mobile devices. Figures 10 and 11 present that the JSMCO algorithm obtains optimal energy and time consumption results in the case of increasing task size. Figure 10(a) shows that both the JSMCO and social relationship-based algorithms have lower energy consumption in the low task density. The energy consumption of the randomized algorithm is higher relative to the other algorithms and shows irregular variations. Figure 9(b) shows a significant increase in the energy consumption of the three algorithms for moderate task densities. As the task size increases, the JSMCO algorithm has less energy consumption compared with the other two algorithms. The gap between the energy consumption of the JSMCO and social network algorithm decreases when the task size is larger than 10 M; however, the algorithm in this paper is still optimal. Figure 10(c) shows that the energy consumption gap between algorithms becomes less at high task densities, but the JSMCO is still optimal. The results of time consumption (a), (b), and (c) in Fig. 11 indicate that the variation pattern is similar to those of energy consumption (a), (b), and (c) in Fig. 10.
The above results suggest that the proposed algorithm still outperforms the other two algorithms in terms of time and energy consumption.

VI. CONCLUSION AND FUTURE WORK
This paper has developed a computation offloading policy for a multiuser multiserver MEC system, where the social relationship among users, user mobility, and dynamic computing resource was considered. To make full use of idle resources of mobile devices and increase the users' willingness to share, we propose the MDSA, which considers social relationships, location relevance, and mobile activity. The MDSA can find suitable mobile devices to provide computational offloading, thus improving the offloading success rate. At the same time, we proposed a matching theory-based algorithm to fully utilize computing resources and reduce energy consumption while satisfying task latency requirements. Finally, the numerical results verified that these methods have better performance than the baseline methods in terms of offloading success rate and time and energy consumption.
In this paper, we have considered the single-hop case for computation offloading. To better utilize the resources in the whole system to provide a better QoS, we will consider the multihop-assisted offloading problem in the future.