# Optimal Task Offloading Strategy for Vehicular Networks in Mixed Coverage Scenarios
## 3 System Model and Problem Formalization
### Task Offloading Problem Formalization
#### 3.2.2 Task Offloading Decision Problem  
According to the task offloading ratio allocation to the RSU and BS, we obtain processing rate constraints for offloading tasks to each target.  
\[V_{vr}=\frac{\alpha ks}{T_{vr}},V_{vb}=\frac{\theta ks}{T_{vb}},V_{v}=\frac{ \gamma ks}{T_{v}}, \tag{11}\]  
where the processing rates of vehicle offloading tasks to RSUs, BSs, and the local area are \(V_{vr}\), \(V_{vb}\) and \(V_{v}\), respectively.  
In addition to the task allocation and rate constraints, there are also spatial relationship constraints between vehicles, RSUs, and BSs, as  
\[T_{\text{local}}=\frac{ks}{f_{v}},T_{r}=\frac{ks}{f_{r}},T_{b}=\frac{ks}{f_{b}}, \tag{12}\]  
\[T_{cross}=\min\{T_{\text{local}},T_{r},T_{b}\}, \tag{13}\]  
where \(T_{\text{local}}\) represents the delay when all tasks are computed locally, \(T_{r}\) represents the delay when all tasks are offloaded to the RSU, \(T_{b}\) represents the delay when all tasks are offloaded to the BS, and \(T_{cross}\) represents the minimum value among the three delays.  
Based on the evaluated position relationship between the RSU, BS, and vehicle, we can decide whether the task should be offloaded to the RSU or BS. \(\Delta x\) can be calculated as  
\[\Delta x=v_{i}T_{cross}, \tag{14}\]  
where \(v_{i}\) is the certain speed of the vehicle.  
\[\alpha=\begin{cases}k_{1},&\Delta x<x_{r}-x_{i}\\ 0,&\Delta x\geq x_{r}-x_{i}\end{cases}, \tag{15}\]  
\[\theta=\begin{cases}k_{2},&\Delta x<x_{b}-x_{i}\\ 0,&\Delta x\geq x_{b}-x_{i}\end{cases}, \tag{16}\]  
where \(k_{1}\) and \(k_{2}\) are variables, \(k_{1},k_{2}\in(0,1)\), \(x_{i}\) is the current position of the vehicle, \(x_{r}\) is the coverage boundary position of the RSU where the vehicle is located, and \(x_{b}\) is the coverage boundary position of the BS where the vehicle is located. It means that the vehicle's offloading strategy is not affected when the vehicle does not exceed the coverage range of the current \(\text{RSU}/\text{BS}\) after passing \(T_{cross}\) at a certain speed \(v_{i}\). Otherwise, the vehicle will exceed the coverage range of the current \(\text{RSU}/\text{BS}\), and the vehicle will not choose the \(\text{RSU}/\text{BS}\) as the offloading target.  
Therefore, the task offloading optimization problem can be formulated as  
\[\min_{\{\alpha,\theta,\gamma\}}T \tag{17}\]  
subject to  
\[\min\{V_{vr},V_{vb},V_{v}\}\geq V_{\text{th}}, \tag{18}\]  
\[\alpha+\theta+\gamma=1, \tag{19}\]  
\[\alpha=\begin{cases}k_{1},&\Delta x<x_{r}-x_{i}\\ 0,&\Delta x\geq x_{r}-x_{i}\end{cases},k_{1}\in(0,1), \tag{20}\]  
\[\theta=\begin{cases}k_{2},&\Delta x<x_{b}-x_{i}\\ 0,&\Delta x\geq x_{b}-x_{i}\end{cases},k_{2}\in(0,1), \tag{21}\]  
\[\gamma\in(0,1]. \tag{22}\]  
where function (17) minimizes the total task processing delay. Constraint (18) requires that all the processing rates must be larger than the minimum expected rate \(V_{\text{th}}\). Constraint (19) means the task split ratios should add up to 100%. Constraint (22) means that there are always tasks left to compute locally.  
The objective problem (17) with constraints (18)-(22) is expressed as a constrained optimization problem in the field of task offloading. Because \(L_{b}\) is related to \(T_{b}\) in the objective problem (17), but it is difficult to obtain the actual data of \(L_{b}\) in the system, therefore, we introduced the LSTM to estimate \(L_{b}\), which is the load state of BSs. And we use the PPO algorithm to solve the constrained optimization problem, striving to achieve stable and excellent offloading performance. In the next section, we will use the two-stage optimization approach to solve the load state estimation problem of BSs and the task offloading optimization problem.