# Three-Dimensional Resource Allocation in D2D-Based V2V Communication
## 3 Matching and Resource Block Allocation Scheme
### Optimal Power Allocation  
First, we will find the optimal power allocation for single V2V, V2I, and CUE cases reusing the subcarrier; that is, the lth V2V sharing band with the kth V2I and \(j\) th CUE. For the sake of simplicity, we drop the subcarrier index \(x\) and rewrite Equation (5) as follows:  
\[Max\sum_{k=1}^{K}\sum_{x=1}^{X}E[log_{2}(1+\gamma_{k})] \tag{5}\]  
\[0\leq P_{j}\leq Pmax^{j} \tag{5a}\] \[0\leq P_{k}\leq Pmax^{k}\] (5b) \[0\leq P_{l}\leq Pmax^{l}\] (5c) \[Pr[\gamma_{l}\leq\gamma_{0}]\leq p0\] (5d) \[\gamma_{j}\geq\gamma_{th} \tag{5e}\]  
Here, we assume that the CUE gets the minimum required SINR such that Equation (5e) becomes:  
\[\gamma_{j}=\gamma_{th} \tag{5f}\]  
and  
\[P_{j}=\frac{\gamma_{th}\Big{(}P_{k}h_{k,j}+P_{l}h_{l,j}\Big{)}}{h_{j}} \tag{5g}\]  
Initially, setting the Pk and Pl as Pk_max and Pl_max in Equation (5g) will give us the numerical value of Pj. Applying Equation (5e) for the reliability, we get Equation (6):  
\[Pr\Bigg{\{}\frac{P_{l}h_{l}}{P_{j}h_{j,l}+P_{k}h_{k,l}}\leq\gamma_{0}\Bigg{\}} \leq p0 \tag{6}\]  
For the sake of simplicity in deriving the expression for the powers, we assume that the interference is much greater than the additive noise--i.e., \(\sigma^{2}<<\) interference--and hence we drop \(\sigma^{2}\) from the calculation. Since we know that  
\[h^{a,b}=\alpha^{a,b}g^{a,b}\]  
Equation (6) will become  
\[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]0  
We use Equation (7) and apply the Lemma 1 proposed in [10] (for the case two types of UE), and extend it for the three UEs case. **Lemma 1**: _Considering the reliability constraint for V2V and a minimum guaranteed SINR for the CUE, the power allocation problem becomes (proved in the Appendix A)_  
\[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]1For the zero-crossing point \(\mathrm{Pl}\geq 0\), Equation (9) will become  
\[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]2  
The plot of Equation (8) is shown in \[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]3 In order to find the optimum values for \(\mathrm{Pk}\) and \(\mathrm{Pl}\), we use the Newton-Raphson method for the graph in \[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]4 The red point on the graph shows the optimum points. Once we get \(\mathrm{Pk}\) opt and \(\mathrm{Pl}\) opt, these values are inserted back in Equation (5g), and the whole process is repeated iteratively until we get stable values for all three powers, as shown in Algorithm 1. ```
1. Initialize \(\mathrm{tol}=1\mathrm{e}^{-7}\) (error)
2. Initialize \(\mathrm{N\_max}=1\mathrm{e}^{7}\) (maximum number of iterations)
3. it = 1 (iteration number)
4. f=Var.*g_l/(sinr_min.\"g_kl)*(((Var.*g_l)/(\(\mathrm{Pl}\))*sinr_min*g_jl+Var. *g_l)/(l-p0))-1) (f=function)
5. \(\mathrm{Pl\_0}\)=sinr_min*(1-p0)*\(\mathrm{Pl}\)*\(\mathrm{Bl}\)/(g_l*p0)
6. Var = \(\mathrm{Pl\_0}\) (initial condition)
7. while(it<=N_max)
8. yy = Var (Var = temporary variable)
9. Var = yy -(f(Var)/df(Var))
10. if(abs(Var-\(\mathrm{Pl\_0}\))/abs(Var)) < tol
11. \(\mathrm{Pl\_max}=\mathrm{Var}\)
12. \(\mathrm{Pl\_opt}=\mathrm{Pl\_max}\)
13. \(\mathrm{Pk\_opt}=\mathrm{Pk\_max}\)
14. \(\mathrm{Pj\_opt}=(\mathrm{sinr\_th\_cue}^{*}((\mathrm{Pk\_opt}*g_{\_kj})+( \mathrm{PL\_opt}*g_{\_lj}))/g_{\_j}\mathrm{B})\)
15. break
16. end if
17. it=it+1
18. end

\[0\leq P_{j}\leq Pmax^{j} \tag{5a}\]5 Plot of \(\mathrm{Pk}\) vs. \(\mathrm{P\ell}\). ### Hypergraph-Based Matching and RB Allocation

A graph G is denoted by G = (V, E), where V is set of vertices and E is the set of edges that connect those vertices. In the interference hypergraphs, the edges denote the interference and the vertices denote the user equipment. There are two types of interferers here: independent and cumulative [6]. The independent interferers are the pairwise interference between two users connected by a simple edge, whereas cumulative interferers are connected by a hyper edge. Once the hypergraph is constructed, it is colored using different colors, where each color denotes a RB. Therefore, two neighbors with the common edge cannot have the same color in both the simple and hyper edge case.