# UAV-Assisted Caching Strategy Based on Content Cache Pricing in Vehicular Networks
## 4 RSU Caching Strategy Considering Content Cache Pricing
### Trajectory Optimization of UAV
 \tag{36}\]  
The UAV caches the contents of the RSU lease according to the prevalence, so the utility saved when the UAV is on each road block in different trajectory optimization cycles can be calculated; the utility saved when the UAV stays on road block \(L_{x}\) in optimization cycle \(T_{x}\) is denoted by \(u_{x,z}^{save}\). At this point, \(P3\) can be regarded as a shortest path problem and the UAV trajectory is regarded as a directed graph, as shown in Figure 5, where the point \((x,z)\) indicates that the UAV stays on the rectangular block \(L_{z}\) during the optimization period \(T_{x}\). The edge connecting the two points indicates the path of the UAV and \(u_{x,z}^{save}\) is used as the weight of the edge. This problem can be solved by [PERSON]'s algorithm, which has the main feature of starting from the starting point and using the strategy of greedy algorithm, traversing to the nearest neighboring point of the starting point that has not been visited each time until it is extended to the ending point. The details are shown in Algorithm 3. First, the starting point \(L_{begin}\) and the ending point \(L_{end}\) are given, \(L_{begin}=L_{end}\), and a directed graph is drawn. Initially, the starting point is marked and the distance is recorded as 0, i.e., \(L_{begin}=L_{end}\). All points except the starting point are unmarked and the distance to the starting point is recorded as positive infinity, i.e., \(dis_{0,(T_{0},L_{begin})}=\infty\). Next, iteration is performed. The point just added is denoted as \(pt\), its set of neighboring points is denoted as \(pt_{neu}\), and the distance \(dis_{pt,p}\) of neighboring point \(p\) passing through \(pt\) to the starting point is calculated, \(p\in pt_{neu}\), where the value of \(dis_{pt,p}\) is the weight of \(pt\) to \(pt_{neu}\) plus the distance of \(pt\) to the starting point. If \(dis_{pt,p}\) is less than the distance \(dis_{0,p}\) to the starting point recorded by \(p\), update \(dis_{0,p}\) to the value of \(dis_{pt,p}\). After the distance update, the closest point from the unmarked point to the starting point is selected, marked, and included in the set of optimal  
Figure 5: Directed graph of UAV trajectory. paths. Repeat the last two steps until the update to the end point to achieve the final path and the saved utility. ```
1.\(L_{\min}=L_{z-1}\), \(L_{\max}=L_{z+1}\), \(flag_{(T_{s},l_{p})}=1\)
2. For \(x=1\) to \(X\):
3. For \(z=1\) to \(Z\):
4.\(dis_{0,(T_{s},l_{s})}=\infty\), \(flag_{(T_{s},l_{s})}=0\)
5. end for
6. end for
7.\(pt=\left(T_{0},L_{begin}\right)\), \(dis_{0,pt}=dis_{0,(T_{0},L_{begin})}=0\), \(flag_{(T_{0},L_{begin})}=1\)
8. While Presence of untagged nodes. 9. For \(p\) in \(pt_{net}\):
10.\(dis_{p}=dis_{0,pt}+u_{p}^{sure}\)
11. If \(dis_{p}<dis_{0,p}\)
12.\(dis_{0,p}=dis_{p}\)
13. End if
14. end for
15. Select the closest point to the starting point from the unmarked points, denoted as \(pt\)
16.\(flag_{pt}=1\), add \(pt\) to the trajectory \(G\) of the UAV
```  
**Algorithm 3** Dijkstra-based path planning algorithm  
In summary, the complexity of the algorithm used for this strategy is \(o(C_{l}\cdot C_{r}\cdot I)\). The algorithm can accurately find the optimal RSU caching strategy and UAV flight trajectory, but the complexity is high and the computing time is long, which is suitable for scenarios with smaller contents and higher requirements for accuracy.