# LIransformer: A Transformer-Based Framework for Task Offloading in Vehicular Edge Computing
## 3 Method
### Task Offloading
#### 3.1.1 Task Offloading Optimization Approach  
The task offloading optimization approach can be divided into the training process and the prediction and optimization process. The training process involves gathering historical trajectory data, training the predictive model, and deploying the model. The input data of this process are the trajectory data stored by the vehicle, and the output datum of this process is the trajectory predictive model stored by edge servers. The detailed steps are shown in Figure 2a. The prediction and optimization process encompasses the collection of trajectories for prediction, the generation of prediction results, and the optimization of computational tasks. The input data are the trajectory data stored by the vehicle, and the output data are the results of the computational task transmitted to the vehicle, the detailed steps of which are shown in Figure 2b.  
The training process can be divided into three steps, each of which corresponds to the serial number in Figure 2a. The details of the training process are as follows:  
Input: the vehicle trajectory set \(A\) is stored in the vehicle set \(V\), where \(A=\{T_{1},T_{2},\ldots,T_{n}\}\), \(T=\{s_{1},s_{2},\ldots,s_{1}\}\), \(V=\{v_{1},v_{2},\ldots,v_{n}\}\).  
Output: the predictive model \(M\) is stored in the set edge servers, \(S\), where \(S=\{s_{1},s_{2},\ldots,s_{m}\}\).  
1. Historical vehicle trajectories stored in the vehicle are uploaded into the edge server. Specifically, the vehicle trajectory \(T_{h}\) stored in the vehicle \(v_{h}\) is uploaded to the surrounding edge server \(s_{h}\) through the roadside units (RSU).
2. Edge servers upload vehicle trajectories to the cloud server. Specifically, the vehicle trajectories, \(T_{p},\ldots,T_{q}\) stored in the edge server \(s_{h}\) are uploaded to the cloud server \(c\).
3. The predictive model is trained on the cloud server based on the trajectory data of vehicles. Once the training process is completed, the predictive model is transmitted to the edge servers. Specifically, the predictive model \(M\) is trained on the cloud The prediction and optimization process is similarly divided into three steps, each of which corresponds to a serial number in Figure 2b. The detailed process of prediction and optimization is as follows:  
Input includes the following three components:  
* The computational task \(D_{p}\).
* The vehicle trajectory \(T_{i}\) is stored in the vehicle \(v_{i}\).
* The model \(M\) is stored in the edge server \(s_{j}\).  
Output: the completed computational task \(D_{q}\) stored in the vehicle \(v_{i}\).
* Computational tasks and vehicle trajectories stored in the vehicle are uploaded onto the edge server. Specifically, the computational task \(D_{p}\) and vehicle trajectory \(T_{i}\) stored in the vehicle \(v_{i}\) are uploaded into the surrounding edge server \(s_{j}\) via the RSU.
* The edge server uses the predictive model to predict the vehicle trajectory and optimizes the task offloading according to the prediction result. Specifically, the vehicle trajectory, \(T_{i}\), is predicted in the edge server \(s_{j}\) using the predictive model \(M\). Assuming the prediction result is the edge server \(s_{k}\), the computational task or the result of the task is transmitted to the edge server \(s_{k}\) via V2V or V2I.
* The vehicle downloads the results of the computational task as it arrives around the predicted location. Specifically, the computational task result \(D_{q}\) in the edge server \(s_{k}\) is transmitted to the vehicle \(v_{i}\) when the vehicle \(v_{i}\) arrives in its vicinity.  
The task offloading optimization approach has many applications. For example, in smart cities, this approach can be used to deploy deep learning in VEC to predict and control the overall flow of vehicles, and thus optimize the traffic situation. In in-vehicle services, this approach also deploys deep learning to improve the QoS of users.