# Social-Aware-Based Resource Allocation for NOMA-Enhanced D2D Communications
## 3 Social-Aware-Based Resource Allocation
### Optimization Model
#### 3.2.1 Channel Allocation
```
1: Initialization: D2D content providers' transmit power \(P_{d^{\prime}}^{k}\) initial matching \(\Omega^{0}\). 2: While Equation (1)
3: For I = 1:\(N\)
4: Perform swap operations according to Equations (25) and (27)
5: Update \(\Omega^{0}\)
6: End for
7: If \(\Omega^{0}\) is stable
8: Break
9: End if
10: End while
11: Output:\(\Omega^{*}\)
```  
**Algorithm 2** Channel allocation based on many-to-one matching game. **Theorem 1**. : _The sum rate of D2D content providers in the D2D cluster is increased after swap operations._  
Proof. : Suppose that the matching \(\Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}}\) becomes \(\Omega_{m,m^{\prime}}^{n^{\prime},n}\) after the swap operation, which means \(U_{m}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n}\right)\geq U_{m}\!\left( \Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}}\right)\) and \(U_{m^{\prime}}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n}\right)\geq U_{m^{ \prime}}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}}\right)\) according to Definition 2. Because the utility of the channel is related to the sum rate of D2D clusters, we have  
\[ \begin{array}{l}\Psi_{\Omega\to\Omega^{\prime}}=U_{m}\!\left(\Omega_{m,m^{ \prime}}^{n^{\prime},n}\right)+U_{m^{\prime}}\!\left(\Omega_{m,m^{\prime}}^{n^ {\prime},n}\right)-U_{m}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}} \right)-U_{m^{\prime}}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}} \right)\\ =\sum\limits_{k\in D}R_{d}^{k}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n} \right)-\sum\limits_{k\in D}R_{d}^{k}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n^{\prime}}\right)\geq 0\end{array}  \tag{29}\]  
\(\Box\)  
**Theorem 2**. : _The final matching\(\Omega^{*}\) is stable after a limited number of iterations._  
Proof. : The number of D2D clusters and cellular channels in the cell is limited, and the number of D2D clusters allowed to access a cellular channel is limited. Therefore, the number of swap operations is limited. According to Theorem 1, the sum D2D rate is increased after each swap operation. After a limited number of iterations, the matching converges because there is an upper bound on the sum D2D rate due to the limited spectrum resources. In addition, assume that there still exists a swapping pair that can improve the utility of the users when the matching is stable. According to Definition 2, the user will definitely exchange the pairing to maximize the utility, which is contradictory to the assumption. The computational complexity of the many-to-one matching game mainly depends on the number of iterations when converging. However, it is uncertain that when the matching converges. Hence, we only discuss the upper bound of the computational complexity here. According to Theorem 1, the sum rate of D2D users is increased after each swap operation. Then, we can define the rate difference between the initial match and the final match as \(\Psi_{\mathrm{f}\Omega^{0}\rightarrow\Omega^{*}}\); the minimum rate difference after each swap operation as \(\Delta\min\). Therefore, the computational complexity of the matching game is \(O\Big{(}\frac{\Psi_{\mathrm{f}\Omega^{0}\rightarrow\Omega^{*}}}{\Delta\min} \Big{)}\) in the worst case.