## 3 Joint Cooperative Spectrum-Sharing Scheme
### Matching Game for EUs and D2D Pairs  
As seen in Figure 1, there are multiple EUs and multiple D2D transmission pairs in the considered system model. In order to maximizing the utility given by Equation (11), \(EU_{m}\) intends to share its spectrum resource with a best D2D transmission pair \((DT_{n},DR_{n})\). On the other hand, a D2D transmission pair \((DT_{n},DR_{n})\) intends to provide cooperative assistance for an appropriate EU in order to win a transmission opportunity within the licensed band for its own traffic, while simultaneously maximizing its utility formulated by Equation (12). Hence, based on the matching theory, both the EUs and the DTs in our system are considered as a pair of disjoint sets. Each EU intends to be matched with an appropriate DT who can provide a higher transmit rate. On the other hand, a DT is matched to an appropriate EU for the sake of pursuing higher utility. Hence, the spectrum-sharing problem can be formulated as a matching game, which is capable of producing a cooperative matching between an EU and a D2D transmission pair. Based on matching theory, we define a cooperative matching as follow:  
Definition 2: A one-to-one matching between \(M\) and \(N\) can be represented by a one-to-one correspondence \(\Omega(*)\), where \(\Omega(m)=n\) if and only if \(\Omega(n)=m\) and \(\Omega(m)\in N,\Omega(n)\in M\), for \(\forall m\in M,\forall n\in N\). According to Definition 2, in the two-sided matching market, each EU selects one D2D pair namely \(\Omega(m)=n\), while each D2D pair selects one EU, namely \(\Omega(n)=m\) for \(\forall m\in M,\forall n\in N\). Based on the Definition 2, a matching algorithm is developed for the sake of producing cooperative matchings between multiple EUs and multiple D2D pairs in the considered system, as shown in Table 3.  
Before any offer is made to the D2D transmission pairs, each EU first calculates the optimal time allocation coefficients \(\{\tau^{*}_{m1},\tau^{*}_{m2},\ldots,\tau^{*}_{nm}\}\) for \(0<m\leq M\) and \(0<n\leq N\), by playing the proposed two-stage Stackelberg Game with different D2D transmission pairs. Then, each EU constructs a preference list of potential D2D transmission pairs, which can satisfy the EU's rate requirement, namely \(R^{C}_{mn}\geq\xi R^{dir}_{m}\). More explicitly, the \(EU_{m}\) constructs a preference list \(L^{EU_{m}}\), which orders the potential D2D pairs according to the optimal time allocation coefficients. Thus, the preference list for \(EU_{m}\) is given by: \(L^{EU_{m}}=\tau_{m1}<\tau_{m2}<\ldots<\tau_{mn}\) for \(0<n\leq N\). Based on the optimal power allocation coefficients \(\{\alpha^{*}_{1n},\alpha^{*}_{2n},\ldots,\alpha^{*}_{nm}\}\) for \(0<m\leq M\) and \(0<n\leq N\), generated by the proposed two-stage Stackelberg Game in Section 3.3, \(DT_{n}\) constructs a preference list of potential EUs which may share the licensed spectrum with it. More explicitly, the \(DT_{n}\) constructs a preference list \(L^{D2D}_{n}\), according to the transmit power consumed by forwarding data for different potential EUs. Hence, the preference list for \(DT_{n}\) is given by: \(L^{D2D_{n}}=\alpha_{1n}<\alpha_{2n}<\ldots<\alpha_{mn}\) for \(0<m\leq M\). According to the preference list, the \(EU_{m}\) first offers the optimal time allocation coefficient \(\tau^{*}_{mn}\) to the first D2D of its preference list, namely \(DT_{n}\), which requires the shortest time slot for D2D transmission, as shown in Table 3. If \(DT_{n}\) receives a proposal from \(EU_{m}\) which is in its preference list, \(DT_{n}\) and \(EU_{m}\) form a cooperative matching, provided that \(DT_{n}\) has not been matched. However, if the \(DT_{n}\) is already matched with \(EU_{m}\), the