## 3 D2D-Based Resource Allocation Algorithms
### Power and Delay Optimization Based Uplink Resource Allocation Algorithm
In contrast, the DMCG and GTM+ algorithms exhibit \(O(n^{4})\) complexity in the worst case. Finally, the PDO-URA algorithm demonstrates a linear complexity of \(O(n)\). Table 2 illustrates the computational complexity of each algorithm employed in this study. One of the greatest problems in cellular networks today is the number of users that is growing more and more and the dynamics of changing the number of people using a cell. In this sense, in this work, the number of cellular users varied from 50 CUEs to 100 CUEs. The performance of each algorithm was tested with these numbers of CUEs. In order to have more reliable results, the algorithms were executed 100 times for each number of CUEs, and the average of the final value was used at each point of the graphs of total throughput and total D2D throughput. Another point that has to be considered in the algorithms and in the simulations is the way D2D links are initially created. To this end, in this work, after determining the locations of each device, a search is performed among all devices in the cell to decide which CUEs and DUEs will be chosen to define the D2D links. The same process is performed between the receivers and transmitters of the system. Notice that in the case of the DMCG algorithm, after defining the positions of D2D links, this approach also removes D2D pairs that cannot coexist due to high mutual interference and keeps D2D pairs that minimize system delay. Three methods of search were simulated. The random search is shown in Section 5.1, the closest search in Section 5.2, and the radius search in Section 5.3. ### Random Search

In the first method, the cellular users, the D2D receivers (DRs), and the D2D transmitters (DTs) positions are randomly generated, and the links between them are also randomly determined. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Values** \\ \hline \(BS\) & 1 \\ Ratio & 500 m \\ Initial CUEs & 50 \\ Final CUEs & 100 \\ DUEs & 160 \\ Model & Rayleigh \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameter values. \begin{table}
\begin{tabular}{c c} \hline \hline
**Algorithms** & **Complexity** \\ \hline OP-DMCG & \(O(n^{3})\) \\ GTM+ & \(O(n^{4})\) \\ PDO-URA & \(O(n)\) \\ DMCG & \(O(n^{4})\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Computational complexity. Figure 2 shows the total throughput in Mbits/s, as we can see the optimal power allocation and delay minimization based on the conflict graph algorithm for device-to-device communications provided higher total throughput than the other algorithms. A similar result is seen in Figure 3 when we analyze the total D2D throughput in Mbits/s. The OP-DMCG provided better results regarding total D2D throughput when compared to the other algorithms. Figure 4 illustrates the fairness index, revealing that the OP-DMCG fairness index increases until it reaches around 89 CUEs and subsequently decreases consistently during varying numbers of CUEs, as observed at different time intervals. The fairness index [35] is a measure used to determine if users are receiving a fair distribution of system resources. The closer the value of this parameter is to 1, the fairer the allocation of resources in the network is considered. The fairness index is calculated according to Equation (17). \[Fairness=\frac{[\sum_{k=1}^{K}r_{k}]^{2}}{K\sum_{k=1}^{K}r_{k}



Lastly, as illustrated in Figure 5, it is evident that the OP-DMCG algorithm exhibits lower delay compared to DMCG, GTM+ and PDO-URA algorithms, mainly for a number of CUEs higher than 70. ### Closest Search

The second method, namely the closest search method, randomly generates the positions of CUEs, DRs and DTs. Next, the method checks which DR is closest to each CUE and creates the link. In the same way, the links between DRs and DTs are defined; that is, there is a verification of which DT is closer to each DR, and the link between them is created.