# Social-Aware-Based Resource Allocation for NOMA-Enhanced D2D Communications
## 3 Social-Aware-Based Resource Allocation
### Optimization Model
#### 3.2.1 Channel Allocation
Therefore, we can obtain the utility function of the channel as  
\[\gamma_{\rm m}\geq\gamma_{m}^{th}\quad\forall m \tag{18}\]0  
It can be seen from Equation (27) that the utility of the channel is related to each D2D cluster accessing itself. Therefore, the preference list of the cellular channel can be established according to  
\[\gamma_{\rm m}\geq\gamma_{m}^{th}\quad\forall m \tag{18}\]1  
where \(\Omega(SC_{m})\) represents the set of D2D clusters reusing \(SC_{m}\) in the matching \(\Omega\). \(U_{m}(\Omega(SC_{m}),\Omega)\) represents the utility of \(SC_{m}\) when being reused by multiple D2D clusters in the matching \(\Omega\). The utility of the D2D cluster can be calculated according to Equation (25) and sorted in descending order to obtain the preference list of the D2D cluster over the cellular channel. The utility of the channel can be calculated according to Equation (27) and sorted in descending order to obtain the preference list of the cellular channel. It can be seen from the two utility functions that as the matching pair changes, the decision of one D2D cluster will affect the decision of other D2D clusters, and the preference list of the cellular channel will also dynamically change. We can call this phenomenon as externality. Externality can affect the stable matching. Considering the concept of swap-matching proposed in [12], the stability of the matching game can be defined as  
**Definition 2**. : _Given a matching \(\Omega\), \((SC_{m},D_{n}),(SC_{m^{\prime}},D_{n^{\prime}})\in\Omega\) with \(SC_{m},SC_{m^{\prime}}\in SC\), \(D_{n},D_{n^{\prime}}\in D\), such that no \(\Omega_{m,m^{\prime}}^{n^{\prime},n}=\left\{\Omega/((SC_{m},D_{n}),(SC_{m^{ \prime}},D_{n^{\prime}}))\right\}\cup\left\{(SC_{m},D_{n^{\prime}}),(SC_{m^{ \prime}},D_{n})\right\}\), \(\left\{\Omega(SC_{m})\right\}_{m}^{n^{\prime},n}=\left\{\Omega(SC_{m})\right\} /D_{n^{\prime}}\cup\left\{\Omega(SC_{m})\right\}_{m}^{n^{\prime},n}=\left\{ \Omega(SC_{m})\right\}/D_{n^{\prime}}\cup\left\{\Omega(SC_{m})\right\}/D_{n^{ \prime}}\cup\left\{\Omega(SC_{m})\right\}/D_{n^{\prime}}\cup\left\{\Omega(SC _{m})\right\}/D_{n^{\prime}}\cup\left\{\Omega(SC_{m})\right\}/D_{n^{\prime}}\)._\(D_{n}\) exists and, \(\left|\Omega(SC_{m})\right|_{m^{\prime}}^{n^{\prime},n}=\left[\Omega(SC_{m^{\prime} })\right]/D_{n}\cup D_{n^{\prime}}\) meet \(\forall x\in\left\{SC_{m},SC_{m^{\prime}},\Omega(SC_{m})_{m}^{n^{\prime},n}, \Omega(SC_{m^{\prime}})_{m^{\prime}}^{n^{\prime},n}\right\}\), \(U_{x}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n}\right)\geq U_{x}\!\left( \Omega\right)\), and \(\exists x\in\left\{SC_{m},SC_{m^{\prime}},\Omega(SC_{m})_{m}^{n^{\prime},n}, \Omega(SC_{m^{\prime}})_{m^{\prime}}^{n^{\prime},n}\right\}\), \(U_{x}\!\left(\Omega_{m,m^{\prime}}^{n^{\prime},n}\right)>U_{x}\!\left(\Omega \right)\). During the matching process, the D2D cluster can be a vacant position, so that the D2D cluster can access the cellular channel that still has vacancies. Definition 2 states that two conditions must be met during the swapping process: (1) the utility of all players involved in the swapping process cannot be reduced and (2) there must be a player whose utility will increase after swapping. A matching \(\Omega\) is a stable matching if it meets Definition 2. In order to find the stable matching, we should first initialize the channel allocation. The D2D cluster access the cellular channel which provides it with the highest data rate. If the cellular channel has been reused by \(w\) D2D clusters, \(w+1\) cluster rate should be compared and the cluster with the lowest data rate should find the other channel. When a user accesses the cellular channel and makes someone else on this channel unable to meet the QoS, the suboptimal cellular channel should be searched until all D2D clusters are matched to form an initial match \(\Omega^{0}\). Then we swap the matching pair according to the utility function of all players until the matching is stable. The proposed channel allocation based on many-to-one matching game is described in Algorithm 2.