## 3 D2D-Based Resource Allocation Algorithms
### Power and Delay Optimization Based Uplink Resource Allocation Algorithm  
In this subsection, we briefly describe the approach presented in [28] for resource allocation in multi-sharing uplink scenarios of mmWave cyclic prefix-orthogonal frequency division multiplexing (CP-OFDM) wireless networks [29], incorporating device-to-device communications. The power and delay optimization based uplink resource allocation algorithm comprises two distinct steps [28]. Initially, network resources are allocated to cellular user equipment in terms of both power and transmission rate. This allocation is carried out through a method designed to maximize throughput. Subsequently, unused resources are allocated with a focus on minimizing delay. To achieve this objective, Algorithm 1, called the delay minimization conflict graph, is used. This algorithm facilitates the allocation of idle resources to D2D user equipment within the network by taking into account conflict graphs and estimated delay information. The estimation of delay is conducted using network calculus concepts such as envelope process and service curve, as it can be verified in Algorithm 2, ensuring efficient resource allocation in the system. ```
/* DUE \(n\) and set \(C\) */ /* Initialize */ Delay\({}^{*}\)\(\leftarrow\) 1000; \(m^{*}\)\(\leftarrow\) 0; /* Calculates \(m^{*}\) */ for\(m\in C\)do /* Check the constraint */ if\(P_{n}G_{nB}\leq I_{m}\)then /* Estimates the delay limit */ \(\hat{d}=\inf\{d\geq 0|\forall t\geq 0:A^{*}(t-d)\leq S(t)\}\); /* Optimize delay */ if\(\hat{d}(m)\leq Delay^{*}\)then \(Delay^{*}\leftarrow\hat{d}(m)\); \(m^{*}\gets m\);  end if  end for  end for /* Find the optimal group: \(m^{*}\) */
```  
**Algorithm 2**Optimize Delay  
To encapsulate the PDO-URA algorithm, which addresses communications between cellular user equipments and device-to-device user equipments within a cyclic prefix-orthogonal frequency division multiplexing (CP-OFDM) network [29], a pseudo-code is presented in Algorithm 3. This algorithm delineates solutions aimed at maximizing throughput and minimizing user delay by breaking down the problem into distinct optimization challenges. Initially, power allocation is performed to minimize bit error rate (BER) in transmission links. Subsequently, the allocation of resource blocks (transmission rate) for CUEs is determined, taking delay minimization into account. Finally, the unallocated resource blocks designated for CUEs are optimally distributed to DUEs, also considering delay minimization, utilizing the conflict graph algorithm. ```
\(M\) CUEs, \(N\) DUE pairs, \(K\) idle RBs and \(M-K\) real CUEs; /*Initialize */  For computing the rate to CUE users in order to minimize delay and optimize power efficiency: /* Run Algorithm 1 */  For allocating idle resources to DUE users considering delay minimization: /* Run Algorithm 2 */
```  
**Algorithm 3**PDO-URA  
The part of power allocation of the PDO-URA is related to the approach presented in [26]. The algorithm proposed in [26] aims to optimize power allocation for users in a wireless network. With the knowledge of the channel at the eNodeB, a power allocation vector is computed to minimize the bit error rate in a cyclic prefix-orthogonal frequency division multiplexing (CP-OFDM) transmission link. The algorithm adaptively selects the coding rate, the best modulation format, and the power allocation vector for multiple CUEs to maximize the goodput function [30] represented by Equation (8). The algorithm uses selection optimization to find the best average delay of the CUEs in a CP-OFDM wireless network. The parameters used in the algorithm are defined to achieve the best results, where \(N_{FFT}\) is the Inverse fast Fourier transform size, \(L\) is the filter size, \(L_{CH}\) is the channel impulse response size, \(N_{p}\) is the number of information bits, \(N_{u}\) is the total number of bits transmitted, and \(r\) is the convolutional coding rate.