# Energy Efficiency of D2D Multi-User Cooperation
## 2 Cooperation of D2D Multiple Users
Supposing that \(P_{b}^{1},\cdots,P_{b}^{v}\) are respective bit error rates and \(E_{d}^{1},\cdots,E_{d}^{v}\) are consumed energy by \(S\) for sending the data packet \(D(bit)\) to \(V\), we rank \(E_{d}^{1},\cdots,E_{d}^{v}\) from the smallest  
Figure 1: D2D multi-user cooperation within a heterogeneous network. to the largest and obtain the ranked sequence \(E_{1},E_{2},\cdot\cdot\cdot,E_{v}\). The former \(x\) D2D users are chosen as relaying if \(E_{x-sum}\leq B_{s}\), where \(E_{x-sum}=E_{1}+\cdot\cdot\cdot+E_{x},1\leq x\leq v\). In the second part, the chosen \(x\) relaying D2D users of \(Y_{1}\) choose \(b\) (\(K=x+b\)) or \(x\) (\(K=ax+b\), \(a>1\)) D2D users from \(N_{1}\) with a one to one match. The future chosen \(b\) D2D users do not relay the same data packet, while the future chosen \(x\) D2D users do. Hence, we will analyze the outcome in two situations:  
**A. **\(a=1,0\leq b<x\), \(Y_{1}\big{(}y_{1}^{1},y_{2}^{1},\cdot\cdot\cdot y_{x}^{1}\big{)}\) will pair with \(N_{1}\big{(}n_{1}^{1},n_{2}^{1},\cdot\cdot\cdot,n_{b}^{1}\big{)}\). It is possible for each member of \(Y_{1}\) to be chosen by multiple D2D users of \(N_{1}\) and each member of \(N_{1}\) will receive the same data packet from multiple relaying D2D users of \(Y_{1}\), which will cost large amounts of energy for D2D users. In order to save the energy of each D2D user without the deterioration of QoS, the Kuhn-Munkres algorithm is adopted to pair \(Y_{1}\) and \(N_{1}\) with a one to one match. The D2D users and their cooperation can be regarded as dots and lines in the bipartite graph. \(Y_{1}\) and \(N_{1}\) form a bipartite graph \(G_{1}(Y_{1},N_{1})\). After paired by Kuhn-Munkres algorithm, the adjacency matrix of the paired D2D users can be expressed as:  
\[A_{1}=\left[ \begin{array}{ccc}a_{1,1}&\cdots&a_{1,K-x}\\ \cdots&\cdots&\cdots\\ a_{x,1}&\cdots&a_{x,K-x}\end{array} \right]_{(x\cdot(K-x))} \tag{2}\]  
where \(a_{i,j}\in\{0,1\},1\leq i\leq x,1\leq j\leq K-x\), and \(a_{i,j}=1\) means that \(y_{i}^{1}\) is the relaying D2D user of \(n_{j}^{1}\). The SNRs of cooperation links among \(Y_{1}\) and \(N_{1}\) can be calculated according to the CSI, which can be expressed as a matrix:  
\[R=\left[ \begin{array}{ccc}\gamma_{1,1}&\cdots&\gamma_{1,K-x}\\ \cdots&\cdots&\cdots\\ \gamma_{x,1}&\cdots&\gamma_{x,K-x}\end{array} \right]_{(x\cdot(K-x))} \tag{3}\]  
Figure 2: Cooperation mode of multiple D2D users within a cluster. where \(\gamma_{i,j},1\leq i\leq x,1\leq j\leq K-x\) represents the SNR of D2D user \(U_{j}\) whose relaying D2D user is \(U_{i}\). Next, the SNRs of each row is ranked from the largest to the smallest and given labels \(K-x,\cdot\cdot\cdot,1\), which means that the larger the SNR the bigger the label is given to the respective D2D user. Thus, the corresponding label matrix can be expressed as:  
\[L=\left[ \begin{array}{ccc}l_{1,1}&\cdots&l_{1,K-x}\\ \cdots&\cdots&\cdots\\ l_{x,1}&\cdots&l_{x,K-x}\end{array} \right]_{(x\cdot(K-x))} \tag{4}\]  
where \(l_{i,j}\) represents the weight of line which connects \(U_{i}\) and \(U_{j}\) in bipartite graph \(G_{1}(Y_{1},N_{1})\). The larger weight means better communication quality. Hence, we adopt the Kuhn-Munkres algorithm to match \(Y_{1}\) and \(N_{1}\) with the maximum SNR. As the Kuhn-Munkres algorithm requires that \(Y_{1}\) and \(N_{1}\) should be equal, \(x-(K-x)\) zeros are added to each row of label matrix \(L\) to make a square matrix \(L^{\prime}\):  
\[L^{\prime}=\left[ \begin{array}{cccc}l_{1,1}&\cdots&l_{1,K-x}\\ \cdots&\cdots&\cdots\\ l_{x,1}&\cdots&l_{x,K-x}\end{array} \right.\qquad\qquad\underbrace{0\quad \cdots\quad 0}_{ \begin{array}{c}\cdots\quad 0\\ \cdots\quad\cdots\\ 0\quad\cdots\quad 0\\ \text{each column is 0 from}\\ \text{column }K-x+1\text{ to column }x\end{array} }\right]_{(x\cdot x)} \tag{5}\]  
where \(l_{i,j}\), \(1\leq i\leq x,1\leq j\leq x\), \(l_{i,j}=0\)\(K-x<j\leq x\). **B.