# UAV-Assisted Caching Strategy Based on Content Cache Pricing in Vehicular Networks
## 4 RSU Caching Strategy Considering Content Cache Pricing
### Stackelberg Game for Joint Pricing and Cache Decision Optimization
#### 4.1.3 Iterative-Based Dynamic Programming Algorithm  
For problem \(P1.2\), with constant lease price \(a\), it can be viewed as a backpack problem, where two RSUs with limited capacity are equivalent to two backpacks with different benefits obtained by placing content into different backpacks. The content caching decision is optimized according to the cache capacity and the utility obtained by each content in different RSUs so as to maximize the utility. However, this problem is different from the traditional knapsack problem in that, first, there are multiple knapsacks (two RSUs) and, second, the content cache obtains different benefits in different RSUs and the caching situation of two RSUs for the same content affects the mutual utility. That is, if the utility obtained by NO is \(u_{l}\) when only \(R_{l}\) caches content \(f_{i}\) and \(u_{r}\) when only \(R_{r}\) caches, but the total benefit obtained when both RSUs cache \(f_{i}\) is not equal to \(u_{l}+u_  
```
1. \(db_{1,0,0}=u_{1,[1,0]}^{MNO}\); \(db_{0,1,0}=u_{1,[0,1]}^{MNO}\)
2. For \(c_{l}=0\) to \(C_{l}\) do:
3. For \(c_{r}=0\) to \(C_{r}\) do:
4. \(db_{c|_{L},c_{r}|0}=0\)
5. end for
6. end for
7. For \(c_{l}=0\) to \(C_{l}\) do:
8. For \(c_{r}=0\) to \(C_{r}\) do:
9. For \(i=1\) to \(l\) do:
10. Calculate \(U_{l}=\left[u_{i,[1,0]}^{MNO},u_{[0,1]}^{MNO},u_{i,[1,1]}^{MNO},u_{i,[0,0]}^{MNO}\right]\) according to Equation (25)
11. If \(c_{l}\geq s\) and \(c_{r}\geq s\):
12. \(db_{i,c_{r},i}=\max\left[db_{i-1,c_{r},i-1}+u_{i,[1,0]}^{MNO},db_{i-1,c_{r}-1,i }+u_{i,[1,1]}^{MNO},db_{i-1,c_{r}-1,i-1}+u_{i,[1,1]}^{MNO},db_{i,c_{r}-1}+u_{i,[ 0,0]}^{MNO}\right]\)
13. If \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r}-1,i-1}+u_{i,[0,1]}^{MNO}\): \(y_{l}^{\prime}=1\);\(y_{i}^{\prime}=0\)
14. Else if \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r}-1,i-1}+u_{i,[0,1]}^{MNO}\): \(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=1\)
15. Else if \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r}-1,i-1}+u_{i,[1,1]}^{MNO}\): \(y_{l}^{\prime}=1\);\(y_{l}^{\prime}=1\)
16. Else: \(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=0\)
17. End if
18. Else if \(c_{l}\geq s\):
19. If \(db_{c|_{L},c_{r}-1,i-1}+u_{i,[1,0]}^{MNO}\)\(>\)\(db_{c|_{L},c_{r}-1}+u_{i,[0,0]}^{MNO}\):
20. \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r},i-1}+u_{i,[1,0]}^{MNO}\):\(y_{l}^{\prime}=1\);\(y_{l}^{\prime}=0\)
21. Else:
22. \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r},i-1}+u_{i,[0,0]}^{MNO}\):\(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=0\)
23. End if
24. Else if \(c_{r}\geq s\):
25. If \(db_{c|_{L},c_{r}-1,i-1}+u_{i,[0,1]}^{MNO}\)\(>\)\(db_{c|_{L},c_{r}-1}+u_{i,[0,0]}^{MNO}\):
26. \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r}-1,i-1}+u_{i,[0,1]}^{MNO}\):\(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=1\)
27. Else:
28. \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r},i-1}+u_{i,[0,0]}^{MNO}\):\(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=0\)
29. End if
30. Else:
31. \(db_{c|_{L},c_{r},i}=db_{c|_{L},c_{r},i-1}+u_{i,[0,0]}^{MNO}\):\(y_{l}^{\prime}=0\);\(y_{l}^{\prime}=0\)
32. End if
33. End for
34. End for
35. End for
36. \(U^{MNO}*=db_{c_{L}^{\mathrm{R}},C_{l}^{\mathrm{R}},j}\); \(Y*=\left[y_{a}^{l},y_{a}^{\prime}\right]\)
```  
**Algorithm 1**Dynamic programming algorithm  
Based on Algorithm 1, an iterative-based dynamic programming algorithm is designed in this paper to find the equilibrium point of all Stackelberg games; the specific process is shown in Algorithm 2. Algorithm 2 involves an iterative interaction between the CP and the NO. As the leader, the CP first initializes the lease price \(a\) to \(0\) and then starts the game. In the process of the game, the NO obtains the optimal content caching decision and the corresponding maximum utility at the current rental price by Algorithm 1 based on the content popularity and the local cache space. After that, the CP calculates its own utility based on the caching decision made by the NO and then increases the rental price \(a\) slightly by \(\Delta a\) and iterates to repeat the above interaction.