## 3 Beam Allocation Algorithm Based on MAPPO and Stackelberg Game
### Beam Allocation Algorithm Based on MAPPO
```
1:
2:while\(i<n_{out}\)do
3: Fix \(p^{*}_{k^{\prime},n}(i-1)\), calculate \(p^{*}_{m,n}(i)\) (19);
4: Initialize \(I_{k^{\prime},n}(0)\);
5:while\(j<n_{in}\)do
6: Fix \(p^{*}_{m,n}(i)\), solve problem (22), obtain \(p^{*}_{k^{\prime},n}(j)\);
7: Update \(\lambda_{k^{\prime}}(j)\);
8:if\(|\lambda_{k^{\prime}}(j)-\lambda_{k^{\prime}}(i-1)|\leq\Delta_{1},\forall k^{ \prime}\in\mathbf{k^{\prime}}\)then
9:\(p^{*}_{k^{\prime},n}(i)\gets p^{*}_{k^{\prime},n}(j)\)
10:endif
11: According \(p^{*}_{m,n}(i),p^{*}_{k^{\prime},n}(j)\) to update \(I^{c}_{k^{\prime},n}(j)\), \(I^{c}_{k^{\prime},n}(j)\);
12:\(j=j+1\);
13:endwhile
14:if\(\left|p^{*}_{k^{\prime},n}(i)-p^{*}_{k^{\prime},n}(i-1)\right|\leq\Delta_{2}, \forall k^{\prime}\in\mathbf{k^{\prime}}\)then
15:Output:\(p^{*}_{m,n}(i),p^{*}_{k^{\prime},n}(i)\);
16:endif
17:\(i=i+1\);
18:endwhile
```  
**Algorithm 1** Joint Power Allocation Algorithm Based on Stackelberg Game  
```
1:for\(k^{\prime}\in\) SNLdo
2:if\(\text{length}(G_{k^{\prime}})>1\)then
3:\(\text{max\_sinr}=-\infty\);
4:\(\text{idx}=-1\);
5:for\(i=1\) to \(\text{length}(G_{k^{\prime}})\)do
6:if\(\omega^{\prime}_{i,n}>\text{max\_sinr}\)then
7:\(\text{max\_sinr}=\omega^{r}_{i,n}\);
8:\(\text{idx}=i\);
9:endif
10:endfor
11: Retain the sensing information with idx within \(G_{k^{\prime}}\);
12:endif
13: Compute the distance \(d_{k^{\prime},n}\) between the current vehicle \(k\) and vehicle \(k^{\prime}\) based on \(\left\|P_{k,n}-\hat{P}_{k^{\prime},n}\right\|_{2}\);
14:endfor
15:\(\text{min\_d}=\infty\);
16:\(k^{\prime}=-1\);
17:for\(i\in\) SNLdo
18:if\(d_{i,n}<\text{min\_d}\)then
19:\(\text{min\_d}=\bar{d}_{i,n}\);
20:\(k^{\prime}=i\);
21:endif
22:endfor
23:Output: Vehicle \(k^{\prime}\) as the new target vehicle. ```  
**Algorithm 2** Target vehicle switching based on sensing domain sharing```
1:Initialize: Initialize actor network parameters \(w_{act}\); initialize critic network parameters \(w_{val}\); initialize the experience pool \(\mathcal{F}\);
2:for episode = 1:MaxEpisode do
3: Reset the vehicles' position and the experience pool;
4: Obtain the initial local state \(o_{k,0}\);
5:while n \(\leq\) MaxStep-1 do
6: Input \(o_{k,n}\) into the actor network and select action \(a_{k,n}\) based on the output policy \(\pi_{w_{val}}\);
7: Execute Algorithm 1 Joint Power Allocation Algorithm. 8: Execute Algorithm 2 Target Vehicle Switching Algorithm. 9: Observe the next time slot state \(o_{k,n+1}\) and calculate the reward \(r_{n}\) (14);
10:\(o_{k,n}\gets o_{k,n+1}\);
11:endwhile
12:if evaluate == False then
13: Save the current episode trajectory to the experience pool \(\mathcal{F}\);
14:if length(\(mathcal{1}F\)) == \(samp\)then
15: Calculate the advantage function \(\hat{A}_{n}\) and target value function \(V_{tar}\);
16: Calculate \(L(w_{act})\) (15);
17: Calculate \(L(w_{val})\) (17);
18: Backpropagation and use the Adam optimizer to update \(w_{act},w_{val}\);
19: Clear the experience pool \(\mathcal{F}\);
20:endif
21:endfor
```

**Algorithm 3** ISAC Beam Allocation Scheme Based on MAPPO and Stackelberg Game (IMSBA)

### Joint Power Allocation Based on Stackelberg Game

In the Internet of Vehicles, resource optimization problems are typically complex and non-convex. Therefore, mathematical methods and tools are crucial for facilitating the solution of these problems. Difference of Convex (DC) approximation is a method that can be used to obtain approximate optimal solutions for complex non-convex problems [37]. Additionally, methods based on Stackelberg games are considered useful tools for solving complex problems [38]. In a Stackelberg game, users with different objectives are divided into leaders and followers who cooperate and compete with each other. Based on this strategy, a high-complexity problem can be decomposed into two subproblems of lower complexity.