# Spectrum and Energy Efficiency of Uplink Massive MIMO System with D2D Underlay
## 4 Energy Efficiency Optimization  
From the last section, we can see that the power management plays a critical role in the SE of the D2D link, while the number of antennas severely influence the SE of the CUEs. The EE with the unit \(\mathrm{bps}/\mathrm{Hz}/\mathrm{W}\) is another important metric that should be considered for the green communications. In this section, we aim to maximize the EE \(\Xi\) constrained by the SEs of the CUEs and the D2 Dlink. To make the optimization problem trackable, we maximized the lower bound of the EE that is \(\tilde{\Xi}=\sum_{k=1}^{K}\tilde{\mathcal{R}}_{ck}/E\). The optimization problem can be formulated as  
\[\mathrm{P1}: \max_{P_{\mathrm{c}},N} \tilde{\Xi}\] \[\mathrm{s.\ t.} \mathrm{C1}:\mathcal{R}_{d}\geq r\] \[\mathrm{C2}: NP_{\mathrm{c}}\beta_{ck}/\vartheta_{ck}\geq\tilde{\gamma}_{ \mathrm{th}},\ k=1,\cdots,K\] \[\mathrm{C3}: N\geq N_{\mathrm{th}}. \tag{17}\]  
C1 specifies the outage probability and the minimum data rate requirements of the D2D link. C2 specifies the SINR constraints of the CUEs. \(N_{\mathrm{th}}\) is a predefined threshold that can guarantee the system operates in the massive MIMO scenario.  
To guarantee the performance of the D2D link, the transmit power of CUEs \(P_{\mathrm{c}}\) should be limited to less than \(P_{\mathrm{c}}^{\mathrm{max}}\), where \(P_{\mathrm{c}}^{\mathrm{max}}\) is the solution of the equation \(\mathcal{R}_{d}\left(P_{\mathrm{c}}\right)=r\). So, the constraint C1 can be transformed into \(P_{\mathrm{c}}\leq P_{\mathrm{c}}^{\mathrm{max}}\). Owing to \(\tilde{\gamma}_{\mathrm{th}}\gg 1\), given a value of \(P_{\mathrm{c}}\in\left(0,P_{\mathrm{c}}^{\mathrm{max}}\right]\), the optimization problem P1 can be reformulated as P2.  
\[\mathrm{P2}: \max_{N}\ \tilde{\Xi}=\frac{\sum_{k=1}^{K}\log_{2}\left(P_{\mathrm{c}} \beta_{ck}N/\vartheta_{ck}\right)}{NP_{\mathrm{cir}}+K(P_{\mathrm{c}}+P_{ \mathrm{cir}})+P_{0}}\] \[\mathrm{s.\ t.}\ N\geq N^{\dagger}. \tag{18}\]  
where \(N^{\dagger}=\max\left\{\frac{\tilde{\gamma}_{\mathrm{th}}\vartheta_{ck}}{P_{ \mathrm{c}}\beta_{ck}},N_{\mathrm{th}}\right\},\ k=1,\cdots,K\).  
**Theorem 3**.: _The optimal number of antennas for the optimization problem P2 is obtained as_  
\[N^{\mathrm{opt}}=\max\left\{N^{\dagger},\lfloor N^{\tilde{\mathfrak{S}}} \rceil\right\}. \tag{19}\]  
\(N^{\tilde{\mathfrak{S}}}\) _is given as_  
\[N^{\tilde{\mathfrak{S}}}=\frac{1}{\delta}\mathrm{exp}\left[W\left(\frac{\kappa (KP_{\mathrm{c}}+KP_{\mathrm{cir}}+P_{0})}{P_{\mathrm{cir}}e}\right)+1\right], \tag{20}\]  
_where \(W\) is the Lambert \(W\) function defined as \(t=W(t)e^{W(t)}\), \(\delta=P_{\mathrm{c}}\sqrt[k]{\prod_{k=1}^{K}\beta_{ck}/\vartheta_{ck}}\), and \(\lfloor N^{\tilde{\mathfrak{S}}}\rceil\) is the one of the two closest integer around \(N^{\tilde{\mathfrak{S}}}\) that can maximize \(\tilde{\Xi}\)._  
Proof.: The objective function can be written as  
\[\tilde{\Xi}=\frac{\log_{2}\left(\delta N\right)}{NP_{\mathrm{cir}}+(KP_{ \mathrm{cir}}+KP_{\mathrm{cir}}+P_{0})}. \tag{21}\]  
We can conclude the proof according to the quasi-concavity of \(\tilde{\Xi}\) w.r.t. \(N\).  
It can be seen from Theorem 3 that the optimal \(N\) can be obtained in closed-form once \(P_{\mathrm{c}}\) is fixed. So the optimal solution of \(P_{1}\) can be obtained by a one-dimensional search w.r.t. \(P_{\mathrm{c}}\) in the interval of \(\left(0,P_{\mathrm{c}}^{\mathrm{max}}\right]\).