## 3 Joint Cooperative Spectrum-Sharing Scheme
### Matching Game for EUs and D2D Pairs
\begin{table}
\begin{tabular}{l} \hline \hline
**Require** \\ \hline \(\quad\) & Let \(EU_{m}\) and \(DT_{n}\) exchange their profile information. \\ \(\quad\) & \(DT_{n}\)’s Strategy in Stage \(II\): \\ \(\quad\) & \(\triangleright\) Given the time allocation coefficient \(\tau^{*}_{nm}\) offered by the \(EUI_{m}\) in Stage \(I\). \\ \(\quad\) & \(\triangleright\)\(DT_{n}\) calculates the optimal power allocation coefficient \(\alpha^{*}_{nm}\) according Equation (18) \\ \(\quad\) & \(\boldsymbol{EU_{m}}\)’s strategy in Stage \(I\): \\ \(\quad\) & \(\triangleright\) Given the optimal power allocation coefficient \(\alpha^{*}_{nm}(\tau^{*}_{nm})\) which is shown in Equation (18) \\ \(\quad\) & \(\triangleright\)\(EU_{m}\) calculates the optimal power allocation coefficient \(\tau^{*}_{nm}\) which is the solution of Equation (24) \\ \(\boldsymbol{(\tau^{*}_{nm},\alpha^{*}_{nm})}\) is the Nash Equilibrium of the proposed two-stage Stackelberg game. \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The proposed two-stage Stackelberg game algorithm. may accept the proposal from \(EUL_{m}\), when lower transmit power is required for forwarding \(EUL_{m}\)'s data. Based on the proposed RSWW-OSSS, each DT only has a single cooperative partner. Hence, \(DT_{n}\) has to divorce its current cooperative pair \(\Phi(EUL_{\bar{m}},DT_{n})\) and proceeds to form the new pair \(\Phi(EUL_{m},DT_{n})\). If the \(DT_{n}\) rejects the proposal from \(EUL_{m}\), the \(EUL_{m}\) sends the optimal time allocation coefficient \(\tau_{mi}^{*}\) to the next favourable cooperative partner, namely \(DT_{i}\) in the preference list. Then \(EUL_{m}\) repeats the above discovery procedure either until it finds an appropriate partner or is rejected by all potential D2D transmission pairs. The complexity of the proposed matching algorithm is \(O(MN)\) when each EU was rejected by \(N-1\) D2D pairs of its preference list and cooperates with the final D2D pair of its preference list. However, when each EU receives the cooperation from the first D2D of its preference list, the complexity of the proposed matching algorithm is \(O(M)\). For example, \(M=20\) and \(N=30\). The worst case performance is \(O(600)\) and the best case performance is \(O(20)\). A common and realistic assumption in a cooperative communication network is that both the EUs and D2D pairs are selfish. It implies that both EUs and D2D pairs intend to maximize their own utilities when they are seeking for an appropriate cooperative partner. Hence, bearing in mind the selfish behaviour of the EUs and D2D pairs, it is necessary to analyse the stability of the proposed matching algorithm. Let us first introduce the definition of'stable matching'. Let \(m\succ_{n}\bar{m}\) denote \(DT_{n}\) prefers \(EUL_{m}\) to \(EUL_{\bar{m}}\). **Definition 3**. : _A stable matching is not blocked by the \(EUL_{m}\) and \(D2D_{n}\) pair \(\Phi(m,n)\), such that \(n\succ_{m}\Omega(m),m\succ_{n}\Omega(n)\) and \(\Omega(m)\in N,\Omega(n)\in M\), for \(\forall m\in M,\forall n\in N\)._  
See proof in Appendix B. Definition 3 illustrates that the specific EU and D2D pair, which constitute a cooperative pair according to our RSWW-OSSS can not simultaneously change their strategies for pursing higher utilities, if they select another D2D pair or EU as their cooperative partner. \begin{table}
\begin{tabular}{l} \hline \hline
**Initialization:** \\ \hline \(\quad\) Let \(L_{m}^{EUL}\) and \(L_{n}^{D2D}\) be the preference list of \(EUL_{m}\) and \(DT_{n}\) respectively. \\
**Repeat:** \\ \(\quad\) **for all \(\forall m\in\{1,\dots,M\}\)\(EUL_{m}\)** do \\ \(\quad\) **for all \(E