# Enhanced Integrated Satellite-Terrestrial NOMA with Cooperative Device-to-Device Communication
## 3 Satellite-Aided NOMA with Cooperative D2D Communication
### SANOCO-D2D Operation
As a result, the total sum rate will be equal to \(R_{i,j}=B_{c}^{NOMA}\log_{2}\left(1+\alpha_{j}P_{\rm S}\Gamma_{j}\right)+B_{c} ^{NOMA}\log_{2}\left(1+\frac{(1-\alpha_{j})P_{\rm S}\Gamma_{j}}{\alpha_{j}P_{ \rm S}\Gamma_{j}+1}\right)\implies R_{i,j}=B_{c}^{NOMA}\log_{2}\left(1+P_{\rm S }\Gamma_{j}\right)\), as all quantities will be positive. Thus, in the proposed scheme, the total sum rate is bounded as \(R_{j}^{NOMA_{(i,j)}}+R_{i}^{OMA}\leq R_{i,j}\leq B_{c}^{NOMA}\log_{2}\left(1+P_ {\rm S}\Gamma_{j}\right)\). In conclusion, the maximum sum rate will be equal to the case where only the strong user is connected to the satellite, while the upper bound for the rate of the weak user \(\text{UE}_{i}\) will be equal to \(R_{i}^{DECODED_{(i,j)}}\) and the lower bound will be equal to \(R_{i}^{OMA}\)._  
So far, we have analyzed the proposed technique for an arbitrary UE pair. Since the network consists of \(N=2K\) users, the main goal is to maximize the total sum rate of the system. Therefore, a matching scheme between terrestrial users must take place in order to identify those user pairs that maximize the total sum rate of the system. Towards this end, SANOCO-D2D considers both the channel between the satellite and each user of the system and the terrestrial D2D channel among the possible user pairs. For this purpose, it is necessary to define a binary matrix \(\mathbf{U}\) that presents the pairing relationship between the users:  
\[u_{i,j}= \begin{cases}1&\text{UE}_{i}\ \mathbf{pairs}\ \text{UE}_{j},\\ 0&\mathbf{otherwise}.\end{cases}  \tag{16}\]  
The diagonal elements of the pairing matrix \(\mathbf{U}\) are equal to zero because one user cannot pair itself. Furthermore, it can be easily observed that that \(u_{i,j}=u_{j,i}\), because if user \(\text{UE}_{i}\) forms a pair with \(\text{UE}_{j}\), then \(u_{i,j}=1\), and of course, the pair of \(\text{UE}_{j}\) is user \(\text{UE}_{i}\); thus, \(u_{j,i}=1\). The following maximization problem describes the proposed scheme for the whole network:\[ \begin{split}\max_{u_{i,j}}&\sum_{i=1}^{N}\sum_{j=i+1}^{N }u_{i,j}R_{i,j},\\ \text{s.t.}&\sum_{j=1}^{i-1}u_{j,i}+\sum_{j=i+1}^{N }u_{i,j}=1,\quad\forall i\in\{1,\dots,N\},\\ & u_{i,j}\in\{0,1\},\quad 1\leq i,j\leq N.\end{split}  \tag{17}\]  
Practically, the value of the objective function at the optimal solution of the maximization problem (17) is the maximum sum rate, denoted as \(R_{\max}\), of the system. The first constraint of the maximization problem states that each user can pair with exactly one other user. The maximization problem (17) is an integer programming problem which is hard to solve. In order to solve this problem efficiently, a weighted matching graph \(G=(V,E)\) is created, where the total number of vertices is equal to the total number of users \(|V|=N\). Thus, each vertex \(v_{i}\in V\) represents the corresponding user UE\({}_{i}\). Moreover, each vertex \(v_{i}\) with \(i=\{1,\dots,N\}\) is connected to all the other vertices that is not already connected \(v_{j}\in V\) with \(i\
eq j\) and \(j=\{1,\dots,N\}\), forming the edge \(e_{i,j}\in E\) with weight \(w_{i,j}\) that represents a possible pairing of UE\({}_{i}\) and UE\({}_{j}\). \(G\) is an undirected graph in which edge \(e_{i,j}\) exists and there is no existence of the backward edge \(e_{i,j}\), so the total number of edges equals \(|E|=\binom{N}{2}=N\left(N-1\right)/2\), which is the choice of two users by \(N\) total users. For each edge of the graph, the connection of the corresponding vertices are defined as:  
\[e_{i,j}= \begin{cases}1&v_{i}\text{\bf is connected to }v_{j}\\ 0&v_{i}\text{\bf is not connected to }v_{j}\end{cases}  \tag{18}\]  
Regarding the proposed technique, the \(w_{i,j}=R_{i,j}\), which is the total sum rate that pair of users UE\({}_{i}\) and UE\({}_{j}\) can achieve and is always positive.