## 3 D2D-Based Resource Allocation Algorithms
### Power and Delay Optimization Based Uplink Resource Allocation Algorithm
The proposed algorithm, named optimal power allocation and delay minimization conflict graph (OP-DMCG), combines the resource allocation method described in Section 3.2 with a power allocation method described in Section 4.2. The OP-DMCG algorithm aims to minimize the estimated delay for each user, respect mutual interference constraints, and optimize power allocation to maximize the total throughput and total D2D throughput. ### Resource Allocation

A key part of maximizing the efficiency of a wireless network system is the resource allocation [31]. Resource allocation methods are responsible for allocating the appropriate spectrum of resources from cellular and D2D users. Furthermore, through an optimized resource allocation, interference problems can be minimized. The proposed resource allocation uses the PDO-URA method described in Section 3.3. ### Power Allocation

Power control involves managing interference while protecting the quality of service. In this section, we present a method to calculate the vector of power allocation that optimizes the total throughput of D2D users and cellular users subject to quality-of-service requirements in relation to SINR. As it can be seen in [32], it is necessary to consider the distance between all involved devices. The Rayleigh channel [33] coefficients are found from these distances and the gains are calculated using these coefficients. The instantaneous SINR in BS (\(\gamma_{b_{k}}\)) and \(DR_{i}\) (\(\gamma_{i}\)), i = 1, 2, \(\ldots\), N, can be written, respectively, as:

\[\gamma_{b_{k}}=\frac{p_{c}g_{b_{c_{k}}}}{\sum_{i=1}^{K}p_{i}g_{b_{i},i}+\sum_{j =1,j\
eq i}^{K}p_{c_{k}}g_{b_{c_{j}}}+N_{0}} \tag{9}\]

\[\gamma_{i}=\frac{p_{i}g_{i,i}}{\sum_{j=1,j\
eq i}^{N}p_{j}g_{i,j}+\sum_{i=1}^{ N}P_{c_{k}}g_{i,c_{k}}+N_{0}}, \tag{10}\]

where \(p\) is the transmitted powers, \(g\) represents the gains and \(N_{0}\) is the variance of the independent circularly symmetric complex Gaussian noise with zero mean. A quality-of-service-driven power allocation scheme is subsequently devised for all users, incorporating constraints to ensure the desired signal-to-interference-plus-noise ratio and adhering to prescribed limitations on transmit power within the network. The task of power allocation can be succinctly expressed in scalar form through the introduction of the following vectors:

\[G\triangleq \begin{bmatrix}g_{1,1}&-\gamma_{1}g_{1,2}&\cdots&-\gamma_{1}g_{1,N }&-\gamma_{1}g_{1,c_{1}}&-\gamma_{1}g_{1,c_{2}}&\cdots&-\gamma_{1}g_{1,c_{K}} \\ -\gamma_{2}g_{2,1}&g_{2,2}&\cdots&-\gamma_{2}g_{2,N}&-\gamma_{2}g_{2,c_{1}}&- \gamma_{2}g_{2,c_{2}}&\cdots&-\gamma_{2}g_{2,c_{K}}\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\ddots&\vdots\\ -\gamma_{N}g_{N,1}&-\gamma_{N}g_{N,2}&\cdots&g_{N,N}&-\gamma_{N}g_{N,c_{1}}&- \gamma_{N}g_{N,c_{2}}&\cdots&-\gamma_{N}g_{N,c_{K}}\\ -\gamma_{b_{1}}g_{b_{1}}&-\gamma_{b_{1}}g_{b_{2}}&\cdots&-\gamma_{b_{1}}g_{b_ {N}}&g_{b_{c_{1}}}&-\gamma_{b_{1}}g_{b_{1},c_{2}}&\cdots&-\gamma_{b_{1}}g_{1,c _{K}}\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\ddots&\vdots\\ -\gamma_{b_{k}}g_{b_{1}}&-\gamma_{b_{k}}g_{b_{2}}&\cdots&-\gamma_{b_{k}}g_{b, N}&-\gamma_{b_{k}}g_{1,c_{2}}&g_{b,c_{K}}&\cdots&-\gamma_{b_{k}}g_{b,c_{K}} \\ \end{bmatrix}  \tag{11}\]

\[\rho\triangleq \begin{bmatrix}p_{1}&p_{2}&\cdots&p_{N}&p_{c_{1}}&p_{c_{2}}& \cdots&p_{c_{K}}\end{bmatrix} ^{T} \tag{12}\]

\[\rho\triangleq \begin{bmatrix}N_{0}\gamma_{1}&N_{0}\gamma_{2}&\cdots&N_{0} \gamma_{N}\,N_{0}\gamma_{b_{1}}&N_{0}\gamma_{b_{2}}&\cdots&N_{0}\gamma_{b_{K}} \end{bmatrix} ^{T} \tag{13}\]

\[\rho_{max}\triangleq \begin{bmatrix}p_{1}^{max}&p_{2}^{max}&\cdots&p_{N}^{max} p_{c_{1}}^{max}&p_{c_{2}}^{max}&\cdots&p_{c_{K}}^{max}\end{bmatrix} ^{T}, \tag{14}\]

where \(G\) is called a Z-matrix [12; 13] because all of its off-diagonal elements are non-positive, \(p\) is the vector of powers, \(n\) is the vector that relates the instantaneous SINR with the variance, and \(p_{max}\) is the maximum power.