A Two-Stage Service Migration Algorithm in Parked Vehicle Edge Computing for Internet of Things

Parked vehicle edge computing (PVEC) utilizes both idle resources in parked vehicles (PVs) and roadside units (RSUs) as service providers (SPs) to improve the performance of vehicular internet of things (IoT). However, it is difficult to make optimal service migration decisions in PVEC networks due to the uncertain parking duration and resources heterogeneity of PVs. In this paper, we formulate the service migration of all the vehicles as an optimization problem with the objective of minimizing the average latency. We propose a two-stage service migration algorithm for PVEC networks, which divides the original problem into the service migration between SPs and the serving PV selection in parking lots. The service migration between SPs is transformed to an online problem based on Lyapunov optimization, where the expected parking duration of PVs is utilized. A modified Hungarian algorithm is proposed to select the PVs for migration. A series of simulation experiments based on the real-world vehicle traces are conducted to verify the superior performance of the proposed two-stage service migration (SEA) algorithm as compared with the state-of- art solutions.


Introduction
The development of the automotive industry and the popularity of private cars have led to various issues such as traffic congestion, accidents, air pollution, etc. [1,2]. To ensure the safety and quality of experience (QoE), many novel vehicular Internet of Things (IoT) services are designed to control vehicle behavior by collecting the data from on-board sensors, for example, surrounding vehicle perception and collision risk [3]. In order to cope with great demands for these services, roadside units (RSUs) that are generally located in different geographic regions can be deployed on an edge server to act as a service provider (SP) [4]. However, the RSUs are always overloaded with the rapidly increasing number of vehicles and various service requests [5]. As such, more available resources are on demand [6]. It has been observed that the idle resources in parked vehicles (PVs) can be explored to efficiently provide services to other vehicles [7]. Therefore, a new computing paradigm, called parked vehicle edge computing (PVEC), has emerged to improve the vehicular IoT performance [8].
Generally speaking, private cars usually spend most of the time in parking lots with their resources in idle states, where the average parking duration is approximately seven hours [9]. PVs may consume energy for providing services to other vehicles, a discount in parking fees can be an incentive to a PV [10]. PVEC can take the parking lots as SPs by managing and integrating the rich resources such as storage resources and computing resources of the PVs [11]. The access point of the parking lot

•
We investigate the service migration problem in PVEC, and formulate the service migration process as a mixed integer nonlinear programming (MINP) to minimize the average service latency, where the QoE constraints and the available energy of PVs are taken into account. To our best knowledge, this is the first work that studies service migration in PVFC networks.

•
We propose an efficient SEA algorithm to solve the formulated problem, where the original problem is divided into service migration between SPs and the selection of PVs for migration in parking lots. Utilizing Lyapunov optimization, we perform service migration decision between SPs in an online fashion without requiring future information. Meanwhile, a modified Hungarian algorithm is proposed to effectively tackle the difficult in selection of PVs with different available energy.

•
The effectiveness of the proposed SEA algorithm is verified by simulation based on the real-world vehicle traces. Compared with three benchmarks, the simulation results demonstrate SEA algorithm has the superior performance in terms of average latency, utilization of PVs and energy consumption, especially with large total number of vehicles.
The rest of this paper is organized as follows. Section 2 reviews the relevant existing literature. The system model considered in the paper is presented in Section 3. Section 4 proposes SEA algorithm and conducts the complexity analysis. Section 5 discusses the performance of SEA algorithm. Section 6 concludes the paper.

Related Works
PVEC is an extension of edge network to relieve the high load pressure of RSUs in IoT. According to [22,23], the total number of PVs tend to remain stable with an average parking duration of around 6 h in North America. Many existing works design a incentive mechanism to encourage PVs to share its idle resources [18]. Malandrino et al. [24] leverages optimization model, where PVs serve as relay nodes, to maximize both freshness of the content that download retrieve and the efficiency in the utilization of radio resources. Balen et al. [25] utilize PVs that are near to passing vehicles to distribute messages. The objective of these methods is minimizing the download delay by choosing optimal PVs. Tonguz et al. [26] design a local rule to cache services in PVs, which are selected by biologically inspired self-organizing network approach, and thus achieve low latency of download updates. Li et al. [4] classify PVs into different types according to their parking duration. They design a contract-based incentive mechanism to motivate PVs with long parking duration to contribute their idle resources, and thus maximize the utility of the SP. However, these methods did not fully utilize the resources of PVs.
Recently, the majority of the literature on PVEC have focused on allocating the resources of PVs [7,27]. Gu et al. [13] propose a two-tier data center architecture that leverages the excessive storage resources in parking lots. They design three management policies for data center, i.e., non-replication, simple replication and network coding based replication, which aim to minimize the total communication cost in a closed form. Zhang et al. [28] study task assignment problem in PVs based on Stackelberg game. Through the game between PVs and tasks, it decide the serving PV for each task, and thus minimize the overall cost of a task publisher and subjective dissatisfaction caused by un-offloaded workloads. Huang et al. [29] minimize the service latency by introducing a machine learning framework, which allocates the heterogeneous resources of PVs based on the requirements of the services. Ouyang et al. [30] introduce a scheme based on Lyapunov optimization to minimize the system costs over time in compliance with the time-varying resources of SPs. Zhu et al. [31] make a trade-off between the average service latency and the overall quality loss by designing an event-triggered dynamic allocation scheme based on particle swarm optimization. However, these methods did not take the mobility of vehicles into account. As the vehicle moves, the SP of the vehicle changes constantly, therefore the latency performance obtained by these resource allocation schemes can not be maintained.
To tackle the mobility of vehicles, service migration has been extensively studied in edge networks to reduce the service latency [32,33]. Ksentini et al. [34] assume the user makes the rectilinear translation, and build a one-dimension (1D) MDP model to predict the trajectory. According to the predicted trajectory, the users determine the target serving node of the service migration. Nadembeg et al. [35] select optimal serving node by predicting the throughput in the target node. The service request is assumed to be split into several parts, and the service can be served by many servers at the same time. To be closer to the real scenes, Wang et al. [33] build a 2D Markov Decision Process (MDP) model to predict the user movement behavior in cellular networks, and further make the service migration to achieve the lowest system cost. Yu et al. [36] study a single-user service migration algorithm to select a fraction of the services according to the priority queue, and only migrates these services to reduce the negative effect of trajectory prediction error. Although these service migration strategies have a good performance in edge networks, it can not be directly applied to PVEC networks due to the uncertain parking duration and resources heterogeneity of PVs.

System Overview
In this paper, we consider a PVEC networks consisting V vehicles and N SPs, as shown in Figure 1. As vehicle A moves along the main road, it connects to SP 1, SP 2 and SP 3 sequentially. Initially, a service is deployed on SP 1 which can be accessed by vehicle A directly. As vehicle A approaches SP 2 and SP 3, a proper service migration decision will be made to decide whether to migrate the service by considering both the migration cost and response delay. As shown in the Figure 1, the service is migrated to SP 2 when vehicle A is near SP 2, and is not migrated to SP 3 when vehicle A is near SP 3. In the latter case, vehicle A gets access to the service by request routing. We divide the total time into T time slots, where each time slot lasts for π seconds. In time slot t ∈ [0, T − 1], the vehicles move among the coverage regions. In general, a vehicle connects to the SP with the largest indicator of received signal strength. As the vehicle moves, each vehicle v ∈ [1, V] generates its service request randomly to SP n ∈ [1, N]. In each time slot, the operator decides whether and where to migrate the services for the vehicles. By deploying the vehicular services, SPs can provide services to the vehicles within their radio ranges. When the corresponding service is deployed by the SP which the vehicle is connected with, the service request can be served locally with and minimized latency. These SPs are connected to each other via Ethernet so that any vehicle is able to access all the services along the request routing once it is in the coverage region of a SP.
Assume the SPs contain I RSUs and J parking lots (I + J = N), where SPs i ∈ [1, I] are RSUs with an edge server and other SPs j ∈ [I + 1, I + J] are the parking lots equipped with a access point which is used to communicate with the PVs. The parking lots use the idle resources (e.g., storage capacity) of PVs to serve the vehicles. Let K j t denote the set of PVs in parking lot j, which is updated by where K j t,in and K j t,out are the set of the PVs which enter the parking lot j in time slot t, and the set of the PVs which leave the parking lot j in time slot t, respectively. Thus, we have Each PV k ∈ K j t provides its idle resources to get a discount for its parking fees. There are M different vehicular services that the vehicles may request for. We use a 5-tuple < λ m , γ m , D m , f m,v , θ m,v > to describe service m, where the five coordinates denote the request data size, the computation intensity (i.e., CPU cycles/bit), the response deadline, computing capacity and storage requirement of service m for vehicle v, respectively. What a vehicle requests for multiple services is the same as that multiple vehicles request for a service. We assume each vehicle v continuously requests for one service m(v) ∈ [1, M] in this paper. Table 1 summarizes the key parameter notations in our paper.
the input data size of service m γ m the computation intensity of service m D m the response deadline of service m Ω m the priority of service m f m,v the CPU cycle requirements of a service m request from vehicle v θ m,v the storage requirements of a service m request from vehicle v R t (i, j) The transmit rate between SP i and SP j in time slot t L(v, t) the total latency of vehicle v in time slot t P the communication power E(k, j, t) the total energy consumption of PV k in parking lot j at time slot t τ(k),τ(k) the enter time and leaving time of PV k

Service Placement
The vehicle states are composed of its connected SP information, its serving node information in each time slot t, and the migration decision made by the networks operator.
For each vehicle v, we use c v (t) to denote the number of its connected SP. Thus, we have Let b t (v) denote the serving node of vehicle v for service m(v) in time slot t, where b t (v) = n means vehicle v requests for service from SP n in time slot t. In addition, we use b t (v) to represent the migration decision, where the b t (v) = n means the service m(v) of vehicle v migrates to SP n in time slot t. Thus, the SP in the next time slot is updated by Moreover, the service request to SP j will be further allocated to the PVs. We define a p t (v), where p t (v) = k represents PV k in parking lot j which provides the service to vehicle v in time slot t. Meanwhile, we use p t (v) to represent the migration decision, where p t (v) = k represents the service of vehicle v is migrated to PV k in parking lot j at time slot t. The PV for migration in the next time slot is updated by Thus, we have

Service Latency
The service latency is composed of transmission latency, computing latency and migration latency. The transmission latency refers to the time it takes to send a request to the service node. The mobile edge network state in time slot t is described by an N-by-N matrix denoted by R t . The (a, b)th (a ∈ [1, N], b ∈ [1, N]) element R t (a, b) denotes the available channel resources between SP a and SP b in time slot t. When a = b, element R t (a, b) is the positive infinity. Otherwise, it is randomly distributed in (η min , η max ).
Meanwhile, we useR t (a, b), (a ∈ (I, N], b ∈ K j t ) to denote the transmission rate between the access point in parking lot a and PV b in time slot t, which is randomly distributed in (η min ,η max ). As the distance from the access point and the PV is short,η max is much higher than η max .
Moreover, since the transmission latency between the vehicle and SP is hard to calculate precisely due to the movement of the vehicles, we use a constant C to approximate it. Assuming vehicle v generates a request to service m(v) at the beginning of time slot t, the request transmission latency includes the transmission latency between vehicle v and and the transmission latency between The total transmission latency is The computation latency of vehicle v for service m(v) is Note that service m(v) may be migrated from

The migration latency includes the migration latency between SP
the migration latency between SP b t (v) and PV p t (v) and the migration latency between SP b t (v) and PV p t (v) The total migration latency is Thus, the service latency for vehicle v in time slot t is

Energy Consumption
When entering the parking lot, PV k messages its available energyê(k, j) to the access point in parking lot j. The energy consumption in PV must satisfy this available energy constraint. The transmission energy consumption of PV k for vehicle v in parking lot j at time slot t is where where P is the communication power. The computing energy consumption of PV k for vehicle v in parking lot at time slot t is where κ is the unit energy consumption per CPU cycle. The migration energy consumption of PV k for vehicle v in parking lot j at time slot t is The total energy consumption in PV k for vehicle v in parking lot j at time slot t is Thus, the available energy of PV k in parking lot j at the beginning of time slot t is where τ(k) andτ(k) are the enter time of PV k and the corresponding leaving time, respectively.

Problem Formulation
Our goal is to minimize the long-term average latency with the energy consumption constraint in PVs by selecting the optimal migration strategy b v (t) and p v (t), which can be expressed as (3), (5), (7).
Constraint (23) ensures the service request can be completed before its response deadline. Constraint (24) denotes the energy of PV k in parking lot j can support the service request. The lack of future information is the difficulty in deriving the optimal solution to the above problem as solving P1 optimally requires the complete information. Moreover, P1 is an MINP problem that is proven to be NP-hard.
To solve P1, first we decouple P1 into two sub-problems, service migration between SPs problem and serving PV selection problem. Then we propose a two-stage algorithm, SEA, to solve these two sub-problems. In the first stage, we solve the service migration between SPs problem, i.e., deciding the serving SP for each vehicle. We utilize the Lyapunov optimization to convert this problem to per-slot optimization problem, which can be solved in an online style requiring only the current slot information. In the second stage, we solve the serving PV selection problem, i.e., deciding the serving PVs for vehicles whose serving SP is parking lot. We propose a modified Hungarian algorithm to choose the suitable PVs for vehicles, which fully utilizes the resources of all the PVs.

Problem Decomposition
The difference between RSUs and parking lots is that the parking lot needs to allocate its received service request from the vehicles to PVs with the energy constraint. Thus, we first consider parking lot j as a special RSU, which produces a extra latency during the request process. Replacing the transmission rateR(b t (v), p t (v)) in (9) and (13), and the transmission rateR(b t (v), p t (v)) in (14) with a constantη max 2 , we can obtain a new total latencyL 1 (v, t). Meanwhile, the available energy in parking lot j at the beginning of time slot t isĒ Note that this energy only can be used before the PVs leave the parking lots. The first stage can be described by (3), (5).
After obtaining the solution of P2, solving the original problem P1 only needs to select the serving PV for the received migrated service in each parking lot j at time slot t. The total service latency in parking lot j isL Let V j t denote the set of the vehicles, which migrate the service to parking lot j at time slot t, i.e., b t (v) = j. In this way, the second stage problem for parking lot j in time slot t can be represented by P3 : min , (24).
The detail of the SEA algorithm is shown in Algorithm 1. In each time slot t, we obtain the migration decision b v , i.e., the SP of each vehicle by solving the first stage problem (Line 2). Based on this, we obtain the migration decision p v (t), i.e., actual serving PV of the vehicle which migrates the service to the PV in parking lot j by solving the second stage problem (Lines 3-5). Obtain b v (t) by solving P2 according to Algorithm 2; 3: for j = I + 1 to N do 4: Obtain p v (t), v ∈ V j t by solving P3 according to Algorithm 3; 5: end for 6: end for

Service Migration between SPs
In this subsection, we transform the P2 to per-slot optimization problems based on Lyapunov optimization.

Expected Parking Duration
The energy consumption under a certain migration decision greatly influences the available energy in the future, e.g., the parking lot needs to store the energy to attend frequent requests. We predict the average parking duration to ensure the energy consumption in each time slot is reasonable, in order to avoid rapidly running out of energy and lack of energy in the future, and also avoid using too little energy and compromising, the current latency performance.
However, the information asymmetry between the SP and the PVs causes the SP can not realize the type of PVs. We generate the probability distribution of PV types through the historical data statistics. The probability that a PV belongs to type-n in parking lot j is denoted by Pr(δn), and N ∑ n=1 Pr(j, δn) = 1.
The expected parking duration of PVs in parking lot j is Pr(j, δn)δn.

Algorithm for the Service Migration between SPs
As discussed in Section 4.1, to solve P2 online, we need to convert P2 to per-slot optimization problems requiring only current slot information. Thus, according to the expected parking duration of PVs, we leverage the Lyapunov optimization technique and build a virtual queue to guide the migration decisions with the energy constraint.
where Q j (t) is the queue backlog for parking lot j in time slot t, indicating the deviation of the current energy consumption from the energy constraint. The Lyapunov function is defined as L(ξ(t)), representing the "congestion level" in energy deficit queue, which is A small value of L(ξ(t)) implies that the queue backlog is small, i.e., the virtual queue has strong stability. To keep the energy deficit queue stable, i.e., to enforce the energy consumption constraints by persistently pushing the Lyapunov function towards a lower value, let (t) denote the one-slot Lyapunov drift, which is (t) = L(ξ(t + 1)) − L(ξ(t)), and we have Under the Lyapunov optimization framework, the underlying objective of our optimal control decision is to minimize a supremum bound on the following drift-plus-cost expression in each time slot.
where the parameter µ > 0 can make the trade-off between the service latency and the energy consumption of SPs.
Under the Lyapunov optimization framework, the underlying migration decision of P2 is made by solving the optimization problem P4 Note that P4 only requires the current available information. By considering the additional term k, j, t), the energy deficit of SPs during the current slot is taken into account.
A high value ofĒ(j, t) means it is critical to minimize the energy deficit. The detail of solving the service migration between SPs is shown in Algorithm 2. We first initialize the PV set as a null set (Line 1). At the beginning of the time slot t, the parking lots update its PVs set (Line 3). After this step, we can obtain b v by solving P4 in an iterative manner (Line 4). Next, we calculate the available energy in the next time slot, and update the energy queue (Lines 5, 6). Finally, the solution in the time slot t of P4 becomes the initial state in the next time slot t + 1 (Line 7).

Algorithm 2 Service migration between the service providers (SPs) algorithm.
Input: Output: : Service migration decision b v ; 1: initialize the PV set K j 0 = ∅; 2: for t = 0 to T − 1 do 3: Update the PV set K j t according to (1); 4: Obtain b t by solving P4; 5: Update Q j (t + 1) according to (32); 6: UpdateĒ(j, t + 1) according to (25), 7: Update b v (t + 1) according to (5); 8: end for According to [21], we find that the average latency satisfies where O * is the optimal value of P2. Meanwhile, the energy consumption in parking lot j satisfies where O max represents the long-term latency achieved by no migration strategy. It demonstrates an [O(1/µ), O(µ)] latency-energy trade-off. The latency performance of P4 improves with µ → ∞. However, it also results in the large energy deficit queue. That is, the energy consumption in PVs grows linearly when µ increases.

Serving PV Selection
After solving P2, we can know the vehicles which request service from parking lots. In each time slot t, we need to select the serving PVs for these vehicles according to the service latency and available energy in PVs. A possible solution is to randomly choose a PV for each vehicle. However, the latency performance may not be optimal. Thus, we propose a modified Hungarian algorithm, which can fully utilize the resources of PVs in each parking lot, to solve P3.
First of all, we build a cost function F(v, k, j, t) to calculate the fitness of a migration decision p t (v) (i.e., k = p t (v)). A low value of F(v, k, j, t) means the vehicle gains a big benefit when it is served by PV k.
where ∆ k is the number of service requests that PV k offers. α > 0 is the weight parameter. The modified Hungarian algorithm is shown in Algorithm 3. It works as follows.

1.
Compare the the number of service requests of vehicles S(V ∆ k * = ∆ k * + 1; 6: end while 7: for k ∈ K j t do 8: Make ∆ k copies of the the PV k; 9: Add the copies of PV k into K j * t ; 10: end for 11: , which the cost function F(v * , k, j, t) = 0; 14: end while 15: Initialize cost matrix F according to (37) based on V j * t , K j * t ; 16: Obtain p t (v) according to traditional Hungarian algorithm; The time-complexity of the modified Hungarian algorithm relies on the difference between cost function of PVs for the vehicles. When the cost function values are same, the time-complexity becomes higher, which is at most O(S 3 (V j * t )).

Performance Evaluation
In order to evaluate the performance of SEA algorithm, we conduct simulation experiments. We build a PVEC system with 10 RSUs and 5 parking lots, deployed in the map. PVs behavior is formulated based on a real dataset which are collected by SmartParking App [37]. Figure 2 shows the cumulative distribution function of the parking duration for PVs. The vehicle trajectories are collected from the real-world Rome taxi traces obtained in 2014 [38]. Four typical vehicular services, i.e., emergency stop, collision risk, accident report and parking, are used as the service that the vehicles may request for. The parameters of the services are listed in Table 2. The other major parameters are listed in Table 3.  Always Migration (AM): the service is always migrated to the nearest SP, while the service in the parking lot is assigned to the PVs that can provide best latency performance regardless of the energy consumption constraint in PVs.

•
Dynamic Markov Decision Process (DMDP) [33]: This is a single-user service migration algorithm, where the serving RSU or PV is predicted using the MDP model. The optimal service migration decision is made to minimize the energy consumption. DMDP were applied to each of the users independently in our simulations. Figure 3 shows the average latency with different total number of vehicles. It was observed that the average latency with NM is the highest, which is owing to a significant amount of latency for request transmission. On the other hand, the lowest average latency is achieved by AM, as AM always migrate service to the nearest SPs and further migrate service to PV that can provide best latency performance. Since the objective of DMDP is to minimize the energy cost, the average latency of DMDP is higher than that of AM and of SEA. Meanwhile, with the total number of vehicles increases from 100 to 1000, the average latency greatly increases to reduce the migration energy consumption. The average latency of SEA is quite close to that of AM when the total number of vehicles is smaller than 500. When the total number of vehicles exceeds 500, SEA slowly grows with the limited energy of PVs. However, it is still very close to AM. Figure 4 shows the average utilization rate of PVs with different total number of vehicles. As can be seen from the figure, the utilization rate of PVs for NM is lowest. This is expected as the services were only migrated when the serving PV was leaving the parking lot. Due to the service requests concentrating on PVs that can provide best latency performance, the utilization rate of PVs of AM is near-minimal. Meanwhile, the utilization rate of PVs of DMDP maintain a second highest performance. It was observed that the highest average utilization rate is achieved by SEA as the modified Hungarian algorithm takes the advantage of available energy of PVs. The average utilization rate of PVs with SEA improves by up to 22.2%, as compared with the state-of-the-art solution. Figure 5 shows the average additional energy consumption, which is the sum of the energy consumption exceeding the available energy in PVs divided by total number of PVs, with different total number of vehicles. The highest average additional energy consumption is achieved by AM, where increases exponentially with the total number of vehicles increases from 100 to 1000. This is because too many service requests are concentrated on a PV, resulting in the rapid depletion of energy in this PV. Meanwhile, the average additional energy consumption of NM is near to highest, which is caused by a significant amount of energy being required for requesting transmissions. The average additional energy of DMDP is near to optimal with the MDP model can not predict the parking duration of PV. The average additional energy consumption of SEA is near to zero when the vehicle number below 600. Even with the total number of vehicles increases from 600 to 1000, the average additional energy consumption grow slowly. Figure 6 shows the average surplus energy in PVs, which is the sum of the residual energy in PVs divided by total number of PVs, with different total number of vehicles. Note that if the energy consumption in PV exceeds the available energy, the surplus energy is zero. The performance of NM, AM and DMDP are consistent with those in Figure 5. The highest utilization rate of PVs of SEA lead the energy in PVs is fully exploited. Thus, the average surplus energy of SEA reduce rapidly to 36.4 mJ with the total number of vehicles increase from 100 to 1000. Such observations above indicate that SEA algorithm is suitable for PVEC networks.   Figure 7 shows the average latency and average additional energy consumption with different α, while the total number of vehicle is 1000. By increasing α from 0.01 to 100, SEA algorithm puts more emphasis on the average latency, i.e., the average latency decreases and the average additional energy consumption increases. By adjusting the value of α, we can achieve a balance between these two. In our simulation experiments, we set α = 10.

Conclusions
In this paper, we investigated a service migration problem in PVEC networks. We formulated the service migration process as an MINP optimization problem to minimize the average service latency while satisfying the energy constraints of PVs. A two-stage algorithm, called the SEA algorithm, was proposed to solve the MINP problem, which divides the original problem into the service migration between SPs and the selection of PVs for migration in parking lots sub-problems. Utilizing Lyapunov optimization, we perform service migration decision between SPs in an online fashion without requiring future information. Meanwhile, a modified Hungarian algorithm is proposed to effectively tackle the difficult in selection of PVs with different available energy and services. A series of simulation experiments based on the real-world traces were conducted to verify the superior performance in reducing the average latency with the energy constraint of PVs by our proposed SEA algorithm. It demonstrated that the proposed solution can reduce average latency by up to 17.2% and improve the average utilization rate of PVs by up to 22.2%, as compared with the state-of-the-art solution DMDP. It indicated that SEA algorithm is suitable for PVEC networks. Besides the available energy, storage and computing resources also affect the migration decision, which will be taken into account in future studies.

Conflicts of Interest:
The authors declare no conflict of interest.