An E ﬃ cient Resource Allocation Algorithm for Device-To-Device Communications

: In order to solve the problem of interference and spectrum optimization caused by D2D (device-to-device) communication multiplexing uplink channel of heterogeneous cellular networks, the allocation algorithm based on the many-to-one Gale-Shapley (M21GS) algorithm proposed in this paper can e ﬀ ectively solve the resource allocation problem of D2D users multiplexed cellular user channels in heterogeneous cellular network environments. In order to improve the utilization of the wireless spectrum, the algorithm allows multiple D2D users to share the channel resources of one cellular user and maintains the communication service quality of the cellular users and D2D users by setting the signal to interference and noise ratio (SINR) threshold. A D2D user and channel preference list are established based on the implemented system’s capacity to maximize the system total capacity objective function. Finally, we use the Kuhn–Munkres (KM) algorithm to achieve the optimal matching between D2D clusters and cellular channel to maximize the total capacity of D2D users. The MATLAB simulation is used to compare and analyze the total system capacity of the proposed algorithm, the resource allocation algorithm based on the delay acceptance algorithm, the random resource allocation algorithm and the optimal exhaustive search algorithm, and the maximum allowable access for D2D users. The simulation results show that the proposed algorithm has fast convergence and low complexity, and the total capacity is close to the optimal algorithm.

(a) Establishing a user's preference list based on distance is not the best option; (b) It does not take into account the limitations of cellular subscriber quality when assigning resources to cellular users at one time; (c) Only one D2D pair is allowed to share the spectrum resources of one cellular user, so as the number of D2D users increases, the spectrum utilization cannot be improved; (d) The simulation environment only considers a single-cell cellular network and does not consider the case of heterogeneous cellular networks.
In this paper, the algorithm in reference [20] is improved for these four shortcomings, and a resource allocation scheme based on the many-to-one Gale-Shapley algorithm in a heterogeneous cellular network environment is proposed. The contributions of the proposed algorithm are enumerated as follow: • It effectively solves the resource allocation shortcomings of D2D users multiplexed with cellular user channels in heterogeneous cellular network environments.

•
The algorithm allows multiple D2D users to share the channel resources of one cellular user and ensures the quality of service (QoS) of the cellular users and D2D users by setting the signal to interference and noise ratio (SINR) threshold, in order to improve the utilization of the wireless spectrum. • A D2D user and channel preference list are established based on the implemented system capacity to maximize the system total capacity objective function.

•
The KM algorithm is used to allocate channels for D2D clusters to maximize the total capacity of D2D users [21].
The simulation results show that the scheme can increase the number of connections of D2D users and increase the total system capacity under the premise of ensuring the communication service quality of cellular users.
The following content of this paper is arranged as follows: Section 2 gives the channel allocation problem discussed in this paper according to the system model of D2D communication. Section 3 introduces the QoS-based clustering channel allocation algorithm in a D2D communication system in detail. Section 4 gives the simulation results and analysis. Section 5 provides the discussion of the comparative analysis, while Section 6 is the conclusion.

System Model
This paper studies the resource allocation problem of D2D users multiplexing the uplink channel of heterogeneous cellular networks. Assuming that the total number of channels is N, the macro cellular user channel can only be multiplexed by one micro cell user, but can be reused by multiple D2D users, assuming users of one Microcell or D2D users can only multiplex one channel resource. In the heterogeneous cellular network shown in Figure 1, there are three communication mode users and two base stations, and the macro base station is located in the cell center, and the micro cell base station is randomly distributed in the cell by the Poisson point process with density λ s , and the cellular user and   According to the reference [17,18], the path loss model is shown in Equation (1).
where represents the distance between the transmitter and the receiver (in m), while is the carrier frequency.
The channel gain is composed of path loss and small-scale fading, so the channel gain can be expressed as Equation (2).
where , and ℎ , represent the path loss and small-scale fading coefficient between and , respectively.
In order to study the most severe interference, it is assumed that all channel resources are occupied by macro cell users [22][23][24][25][26]. If a macro cell user can only occupy one channel, then = . microcell users and D2D users respectively multiplex these channel resources. When the binary variables , and are 1, the macro cell user , the micro cell user and the D2D user use channel , otherwise 0.
The macrocell user has a SINR on channel which is given by: According to the reference [17,18], the path loss model is shown in Equation (1).
where d represents the distance between the transmitter and the receiver (in m), while f c is the carrier frequency. The channel gain is composed of path loss and small-scale fading, so the channel gain can be expressed as Equation (2).
where P a,b L and h a,b represent the path loss and small-scale fading coefficient between a and b, respectively. In order to study the most severe interference, it is assumed that all N channel resources are occupied by P macro cell users [22][23][24][25][26]. If a macro cell user can only occupy one channel, then N = C. J microcell users and D D2D users respectively multiplex these N channel resources. When the binary variables X n c , X n j and X n d are 1, the macro cell user c, the micro cell user j and the D2D user d use channel n, otherwise 0.
The macrocell user c has a SINR on channel n which is given by: where P c is the transmit power of the macro cell user c; P d and P j are the transmit power of the D2D user d and the microcell user j; G c,B is the channel gain of the macro cell user c to the macro base station B; G j,B is the channel gain of the microcell user j to the macro base station B; G d,B is the channel gain of the D2D user d to the macro base station B; N 0 is the noise power. The SINR of the microcell user j on channel n is: where b j is a microcell base station to which the microcell user j accesses; G j,b j is the channel gain of the microcell user j to the microcell base station b j ; G c,b j is the channel gain of the macro cell user c to the micro cell base station b j ; G d,b j is the channel gain between the D2D user d and the microcell base station b j . When multiple D2D users multiplex the same channel resource, D2D users are not only interfered with by macro cell users and micro cell users but also interfered with by other D2D users on this channel, so D2D users d are on channel n. Therefore, its SINR is expressed as follows: where G d t ,d r is the channel gain between the D2D user d transmitter d t and the receiver d r ; G c,d r is the channel gain of the macro cell user c to the D2D receiver d r ; G j,d r is the channel gain of the microcell user j to the D2D receiver d r ; G i,d r is the channel gain of the D2D user i to the D2D receiver d r .

Problem Planning
In this paper, the macrocell user and microcell channel resource allocation have been determined, and the macrocell user and microcell user communication service quality is guaranteed, and the D2D user is allocated a channel by maximizing the total capacity of the system. Assuming that two D2D users can be multiplexed on each channel, according to the Shannon formula, the objective function and constraints for the optimization problem can be obtained as Equations (6)- (11).
SINR n j ≥ SINR n j, threshold , ∀ j ∈ W (8) Equations (7)-(9) ensure that the macrocell users, microcell users, and D2D users have signal-to-noise ratios greater than the threshold. Equation (10) ensures that one microcell user multiplexes up to one channel resource and allows up to one microcell user to communicate on one channel. Equation (11) ensures that one D2D user multiplexes at most one channel resource and one channel resource can be multiplexed by at most two D2D users.

Proposed Algorithm
In Section 2.2, the objective function and constraints defined by Equations (6)-(10) belong to the mixed-integer nonlinear optimization problem. The optimal solution needs to traverse all possible assignments with high complexity. Therefore, the complexity of this study is adopted to a lower, suboptimal approach to the optimal solution. This scheme first establishes a preference list of D2D users and channels, respectively. Each D2D user builds a preference list Due_list based on system capacity on different channels, with the first value of each row in the preference list having the highest preference value. Table 1 shows a list of preferences for three D2D users. The preference list of the second D2D user is Due_list (2) = (3,5,2,4,1), indicating that the channel resource that the second D2D user most wants to multiplex is 3. In a similar manner, each channel establishes a channel preference list Channel_list based on the total system capacity achievable by different D2D user communications. The program also needs to define the following parameters: (a) A collection Association of channels and D2D users, the Association(k) indicates that channel k contains already matched D2D users; (b) D list of channels that D2D users most want to multiplex, Pre = [δ 1 , δ 2 , . . . , δ k , . . . , δ D ], the user preference list shows that δ k is the first element of the Due_list(k) list; (c) Define Cluster(k) as the set of D2D user pairs that currently want to multiplex channel k. The pseudo-code of the algorithm is shown in Algorithm 1. Calculate the objective function of the macrocell, microcell and D2D users using Equation (6) 10: Determine the SINRs of the macrocell user, microcell and D2D user using Equation (7) End 32: Use the KM algorithm to achieve the optimal matching between D2D clusters and cellular users' channels [21].
The steps of Algorithm 1 are as follows: (a) First initialize the D2D user and channel preference list, set Association, unmatched D2D pair set UNMATCH, transmit power, and other parameters. (b) Lines 3-27 are the core part of the algorithm, and the loop will only terminate if the maximum number of iterations is reached. Lines 7-17 of the algorithm indicate that for each subchannel k, first find a D2D user pair d that currently wants to multiplex channel k from the set Cluster(k), and then check if the user pair satisfies Equations (7)-(11) constraints. If the condition is met, continue to add to the Association(k) according to the preference list of channel k D2D users until there are two D2D pairs and channel k share resources, otherwise update the D2D user preference list, Cluster(k) and Pre.
(c) Lines 18-20 of the algorithm indicate that there are already two D2D pairs on channel k. If there is a D2D pair r in the set Cluster(k) that wants to multiplex channel k, then channel k refuses to allocate resources to the D2D pair r, updating the D2D pair r preference list. (d) Lines 22~24 of the algorithm indicate that in the final stage of the algorithm, some D2D users cannot find suitable channel resources due to the limitation of the signal-to-noise ratio threshold. This article also assumes that such users have found the right resources to remove these D2D users from the collection UNMATCH.

Simulation Environment Establishment
In this section, simulation experiments were carried out in a heterogeneous cellular network environment. The macro cell radius is set to 1000 m, and the cellular users and D2D users are distributed in the cell as independent Poisson point processes. The specific system simulation parameter settings are shown in Table 2. The Monte Carlo method is used to randomly generate 2000 distribution scenarios each time. Finally, the system performance results obtained by the algorithm are averaged. It is assumed that each macro cell user occupies a single independent channel, and each microchannel user has a multiplex resource with the macro cell user, and the accessed D2D user needs to select an appropriate channel to communicate according to the current channel state. Since this paper assumes that there can be up to two pairs of D2D user communications on a single channel resource, the number of D2D user pairs accessed on each channel is set to two.

Complexity and Performance Analysis
The D2D communication resource allocation algorithm of the proposed M21GS algorithm is simulated by MATLAB simulation software, and the complexity and performance comparison is based on delay acceptance random resource allocation (DARA) algorithm [16] and optimal algorithm [19]. Since the resource allocation scheme based on the delay acceptance algorithm in reference [16] is established in the macro cellular network environment, in order to adapt the algorithm of the document [16] to the heterogeneous cellular network composed of macro cells and micro cells, this paper will match the D2D user and channel. The D2D user establishes a preference list based on the system capacity implemented on the channel. The channel establishes a list of preferences based on the size of the total system capacity achieved by different D2D communications. In addition, when the channel is first assigned to a D2D user, it is also necessary to check the communication service quality of the macro cell user and the micro cell user. This scheme enables the D2D user to find a suitable channel and obtain a stable match between the D2D user and the channel but only one channel is allowed to share resources with at most one D2D user. The random resource allocation algorithm only needs to satisfy the conditions of Equations (7)- (11) to obtain an allocation scheme.

Complexity Analysis
The complexity analysis of the five resource allocation algorithms is as follows: (a) The complexity of the random resource allocation algorithm increases linearly with the increase of the number of cellular users, that is,

Complexity Analysis
The complexity analysis of the five resource allocation algorithms is as follows: a) The complexity of the random resource allocation algorithm increases linearly with the increase of the number of cellular users, that is, ( ) (where is the number of macro cellular users), and the algorithm calculates the lowest amount. b) The worst-case complexity of the DARA scheme [16] is ( ), and the average complexity is ( ).
c) The optimal algorithm is an exhaustive search algorithm that satisfies the constraints, and needs to traverse all possible allocation methods with the highest computational amount. d) The complexity of the CG algorithm [20] is ( ) where is the number of channels. e) The complexity of the proposed scheme is ( − ), therefore, the calculation amount is significantly lower than the random allocation algorithm, and the optimal algorithm and the algorithms in references [16,20].

Performance Analysis
The simulation in Figure 2 compares the total system capacity of the five resource allocation algorithms. As can be seen from the figure, the total system capacity becomes larger as the number of channels increases. When the number of channels is constant, the total system capacity of the proposed algorithm is better than that of references [16,20] and the random resource allocation algorithm that approximates the optimal solution. Because the proposed algorithm allows multiple D2D users to multiplex the same cellular user channel resource, the total system capacity obtained is better than the algorithm in references [16,20], and the random resource allocation algorithm is only (C) (where C is the number of macro cellular users), and the algorithm calculates the lowest amount. (b) The worst-case complexity of the DARA scheme [16] is algorithm only needs to satisfy the conditions of Equations (7)-(11) to obtain an allocation scheme.

Complexity Analysis
The complexity analysis of the five resource allocation algorithms is as follows: a) The complexity of the random resource allocation algorithm increases linearly with the increase of the number of cellular users, that is, ( ) (where is the number of macro cellular users), and the algorithm calculates the lowest amount. b) The worst-case complexity of the DARA scheme [16] is ( ), and the average complexity is ( ).
c) The optimal algorithm is an exhaustive search algorithm that satisfies the constraints, and needs to traverse all possible allocation methods with the highest computational amount. d) The complexity of the CG algorithm [20] is ( ) where is the number of channels. e) The complexity of the proposed scheme is ( − ), therefore, the calculation amount is significantly lower than the random allocation algorithm, and the optimal algorithm and the algorithms in references [16,20].

Performance Analysis
The simulation in Figure 2 compares the total system capacity of the five resource allocation algorithms. As can be seen from the figure, the total system capacity becomes larger as the number of channels increases. When the number of channels is constant, the total system capacity of the proposed algorithm is better than that of references [16,20] and the random resource allocation algorithm that approximates the optimal solution. Because the proposed algorithm allows multiple D2D users to multiplex the same cellular user channel resource, the total system capacity obtained is better than the algorithm in references [16,20], and the random resource allocation algorithm is only C 2 , and the average complexity is Clog(C). (c) The optimal algorithm is an exhaustive search algorithm that satisfies the constraints, and needs to traverse all possible allocation methods with the highest computational amount. (d) The complexity of the CG algorithm [20] is the channel is first assigned to a D2D user, it is also necessary to check the communication service quality of the macro cell user and the micro cell user. This scheme enables the D2D user to find a suitable channel and obtain a stable match between the D2D user and the channel but only one channel is allowed to share resources with at most one D2D user. The random resource allocation algorithm only needs to satisfy the conditions of Equations (7)-(11) to obtain an allocation scheme.

Complexity Analysis
The complexity analysis of the five resource allocation algorithms is as follows: a) The complexity of the random resource allocation algorithm increases linearly with the increase of the number of cellular users, that is, ( ) (where is the number of macro cellular users), and the algorithm calculates the lowest amount. b) The worst-case complexity of the DARA scheme [16] is ( ), and the average complexity is ( ).
c) The optimal algorithm is an exhaustive search algorithm that satisfies the constraints, and needs to traverse all possible allocation methods with the highest computational amount. d) The complexity of the CG algorithm [20] is ( ) where is the number of channels. e) The complexity of the proposed scheme is ( − ), therefore, the calculation amount is significantly lower than the random allocation algorithm, and the optimal algorithm and the algorithms in references [16,20].

Performance Analysis
The simulation in Figure 2 compares the total system capacity of the five resource allocation algorithms. As can be seen from the figure, the total system capacity becomes larger as the number of channels increases. When the number of channels is constant, the total system capacity of the proposed algorithm is better than that of references [16,20] and the random resource allocation algorithm that approximates the optimal solution. Because the proposed algorithm allows multiple D2D users to multiplex the same cellular user channel resource, the total system capacity obtained is better than the algorithm in references [16,20], and the random resource allocation algorithm is only (N) where N is the number of channels. (e) The complexity of the proposed scheme is the size of the total system capacity achieved by different D2D communications. In addition, when the channel is first assigned to a D2D user, it is also necessary to check the communication service quality of the macro cell user and the micro cell user. This scheme enables the D2D user to find a suitable channel and obtain a stable match between the D2D user and the channel but only one channel is allowed to share resources with at most one D2D user. The random resource allocation algorithm only needs to satisfy the conditions of Equations (7)- (11) to obtain an allocation scheme.

Complexity Analysis
The complexity analysis of the five resource allocation algorithms is as follows: a) The complexity of the random resource allocation algorithm increases linearly with the increase of the number of cellular users, that is, ( ) (where is the number of macro cellular users), and the algorithm calculates the lowest amount. b) The worst-case complexity of the DARA scheme [16] is ( ), and the average complexity is ( ).
c) The optimal algorithm is an exhaustive search algorithm that satisfies the constraints, and needs to traverse all possible allocation methods with the highest computational amount. d) The complexity of the CG algorithm [20] is ( ) where is the number of channels. e) The complexity of the proposed scheme is ( − ), therefore, the calculation amount is significantly lower than the random allocation algorithm, and the optimal algorithm and the algorithms in references [16,20].

Performance Analysis
The simulation in Figure 2 compares the total system capacity of the five resource allocation algorithms. As can be seen from the figure, the total system capacity becomes larger as the number of channels increases. When the number of channels is constant, the total system capacity of the proposed algorithm is better than that of references [16,20] and the random resource allocation algorithm that approximates the optimal solution. Because the proposed algorithm allows multiple D2D users to multiplex the same cellular user channel resource, the total system capacity obtained is better than the algorithm in references [16,20], and the random resource allocation algorithm is only (N − 12), therefore, the calculation amount is significantly lower than the random allocation algorithm, and the optimal algorithm and the algorithms in references [16,20].

Performance Analysis
The simulation in Figure 2 compares the total system capacity of the five resource allocation algorithms. As can be seen from the figure, the total system capacity becomes larger as the number of channels increases. When the number of channels is constant, the total system capacity of the proposed algorithm is better than that of references [16,20] and the random resource allocation algorithm that approximates the optimal solution. Because the proposed algorithm allows multiple D2D users to multiplex the same cellular user channel resource, the total system capacity obtained is better than the algorithm in references [16,20], and the random resource allocation algorithm is only random under the premise of guaranteeing the quality of user communication service. Resource allocation is not optimized for system capacity, so performance is the worst.  The simulation in Figure 3 compares the maximum allowable number of D2D users allowed by the five allocation algorithms. It can be seen from Figure 3 that the maximum number of D2D users allowed by the proposed algorithm is better than that of the algorithm [16,20] and the random allocation algorithm, but it does not reach the theoretical (optimal) value. Because the proposed algorithm can achieve one-to-many matching between the channel and D2D users, it can enable more D2D users to communicate at the same time. However, due to the limitation of the SINR threshold, the number of allowable D2D users cannot reach the theoretical value.  The simulation in Figure 3 compares the maximum allowable number of D2D users allowed by the five allocation algorithms. It can be seen from Figure 3 that the maximum number of D2D users allowed by the proposed algorithm is better than that of the algorithm [16,20] and the random allocation algorithm, but it does not reach the theoretical (optimal) value. Because the proposed algorithm can achieve one-to-many matching between the channel and D2D users, it can enable more D2D users to communicate at the same time. However, due to the limitation of the SINR threshold, the number of allowable D2D users cannot reach the theoretical value. algorithms.
The simulation in Figure 3 compares the maximum allowable number of D2D users allowed by the five allocation algorithms. It can be seen from Figure 3 that the maximum number of D2D users allowed by the proposed algorithm is better than that of the algorithm [16,20] and the random allocation algorithm, but it does not reach the theoretical (optimal) value. Because the proposed algorithm can achieve one-to-many matching between the channel and D2D users, it can enable more D2D users to communicate at the same time. However, due to the limitation of the SINR threshold, the number of allowable D2D users cannot reach the theoretical value.   Figure 4 shows the comparison of the sum rate of the five algorithms under different number of D2D pairs. It can be seen from Figure 4 that as the number D2D pairs increases, the sum rate of all the algorithm increases. Moreover, as can be seen from the Figure, the sum rate of the proposed M21GS algorithm shows better sum-rate performance than DARA algorithm [16], CG algorithm [20] and Random Resource Allocation Algorithm under the same number of D2D pairs which makes it more suitable in D2D deployment scenarios. The results also show that the proposed algorithm has a close relation with optimal results, which also validates the analytical derivations.
Appl. Sci. 2019, 9, x FOR PEER REVIEW 9 of 15 Figure 4 shows the comparison of the sum rate of the five algorithms under different number of D2D pairs. It can be seen from Figure 4 that as the number D2D pairs increases, the sum rate of all the algorithm increases. Moreover, as can be seen from the Figure, the sum rate of the proposed M21GS algorithm shows better sum-rate performance than DARA algorithm [16], CG algorithm [20] and Random Resource Allocation Algorithm under the same number of D2D pairs which makes it more suitable in D2D deployment scenarios. The results also show that the proposed algorithm has a close relation with optimal results, which also validates the analytical derivations. The simulation results in Figure 5 show the effect of the SINR threshold on the total system capacity. As can be seen from the figure, the total system capacity becomes smaller as the SINR threshold increases. When the SINR threshold exceeds 10 dB, the total system capacity does not change and reaches a minimum. This means that in order to guarantee the communication service quality of the cellular users, it is not allowed to allocate channel resources for D2D users to communicate, and only macro cellular users and micro cellular users can communicate. Furthermore, the results also indicate that the proposed M21GS algorithm gives better total system capacity for all values of SINR than CG [20], DARA [16] and Random Resource Allocation Algorithm and also has a close relation with optimal results.
The simulation results in Figure 6 show that the proposed algorithm has faster convergence. It can be seen from Figure 6 that the total system capacity gradually increases with the number of Optimal Proposed M21GS Algorithm CG Algorithm [20] DARA Algorithm [16] Random Resource Allocation Algorithm The simulation results in Figure 5 show the effect of the SINR threshold on the total system capacity. As can be seen from the figure, the total system capacity becomes smaller as the SINR threshold increases. When the SINR threshold exceeds 10 dB, the total system capacity does not change and reaches a minimum. This means that in order to guarantee the communication service quality of the cellular users, it is not allowed to allocate channel resources for D2D users to communicate, and only macro cellular users and micro cellular users can communicate. Furthermore, the results also indicate that the proposed M21GS algorithm gives better total system capacity for all values of SINR than CG [20], DARA [16] and Random Resource Allocation Algorithm and also has a close relation with optimal results.
The simulation results in Figure 6 show that the proposed algorithm has faster convergence. It can be seen from Figure 6 that the total system capacity gradually increases with the number of iterations. When a certain number of iterations is reached, the total system capacity tends to be stable, indicating that all D2D users have been allocated. The more D2D users in the system, the more iterations are required, but in general, the number of iterations required for the algorithm to converge is small, 5~8 times can converge, and the computational complexity is low.
Appl. Sci. 2019, 9, x FOR PEER REVIEW 10 of 15 Figure 5. Impact of SINR threshold on total system capacity.   Figure 7 that the proposed M21GS algorithm has stable and fixed energy efficiency for any number of iterations, which makes it more robust and stable against interference and has less complex hardware and energy consumption requirement as compared with CG [20], DARA [16] and Random Resource Allocation Algorithm. Moreover, the proposed algorithm has a close performance with the optimal results, which also validates the theoretical analysis.    Figure 7 that the proposed M21GS algorithm has stable and fixed energy efficiency for any number of iterations, which makes it more robust and stable against interference and has less complex hardware and energy consumption requirement as compared with CG [20], DARA [16] and Random Resource Allocation Algorithm. Moreover, the proposed algorithm has a close performance with the optimal results, which also validates the theoretical analysis.   Figure 7 that the proposed M21GS algorithm has stable and fixed energy efficiency for any number of iterations, which makes it more robust and stable against interference and has less complex hardware and energy consumption requirement as compared with CG [20], DARA [16] and Random Resource Allocation Algorithm. Moreover, the proposed algorithm has a close performance with the optimal results, which also validates the theoretical analysis.  Figure 8 illustrates the system average energy efficiency comparison of the proposed algorithm with CG [20], DARA [16], random resource allocation and optimal algorithm under different number of Cellular User Equipment's (CUEs). It can be seen from Figure 8 that the average energy efficiency of the proposed M21GS algorithm is better than the other competing alternatives under a different number of CUEs. Also, the proposed algorithm has a much better performance with optimal results, validating the analytical approach.  Figure 8 illustrates the system average energy efficiency comparison of the proposed algorithm with CG [20], DARA [16], random resource allocation and optimal algorithm under different number of Cellular User Equipment's (CUEs). It can be seen from Figure 8 that the average energy efficiency of the proposed M21GS algorithm is better than the other competing alternatives under a different number of CUEs. Also, the proposed algorithm has a much better performance with optimal results, validating the analytical approach.  Figure 8 illustrates the system average energy efficiency comparison of the proposed algorithm with CG [20], DARA [16], random resource allocation and optimal algorithm under different number of Cellular User Equipment's (CUEs). It can be seen from Figure 8 that the average energy efficiency of the proposed M21GS algorithm is better than the other competing alternatives under a different number of CUEs. Also, the proposed algorithm has a much better performance with optimal results, validating the analytical approach. To evaluate the validation of the proposed algorithm further, we have compared the number of iterations required with an increasing number of D2D users under different algorithms in Figure 9. As can be clearly seen from Figure 9, the proposed algorithm requires a smaller number of iterations when the number of D2D users increases as compared with existing reference [20] and reference [16] algorithms. Moreover, the proposed algorithm has closed performance with the optimal scheme, further validating its effectiveness. To make it clearer by evaluating it when the number of D2D users is 150, the proposed scheme requires only 33 iterations to give an optimal performance whereas the schemes in reference [16] and reference [20] require 45 and 40 iterations, respectively.
Appl. Sci. 2019, 9, x FOR PEER REVIEW 12 of 15 To evaluate the validation of the proposed algorithm further, we have compared the number of iterations required with an increasing number of D2D users under different algorithms in Figure 9. As can be clearly seen from Figure 9, the proposed algorithm requires a smaller number of iterations when the number of D2D users increases as compared with existing reference [20] and reference [16] algorithms. Moreover, the proposed algorithm has closed performance with the optimal scheme, further validating its effectiveness. To make it clearer by evaluating it when the number of D2D users is 150, the proposed scheme requires only 33 iterations to give an optimal performance whereas the schemes in reference [16] and reference [20] require 45 and 40 iterations, respectively. The effectiveness and validation of the proposed algorithm are further described in Figure 10 in which the sum rate is evaluated under D2D transmission power. As can be seen from Figure 10, the sum rate of proposed M21GS algorithm is better than CG [20], DARA [16], and the random resource allocation algorithm at each particular power level of the D2D user. Furthermore, when the transmission power is above 300 mW, the sum rate of the algorithm decreases but the proposed algorithm still shows an improved sum rate and a close performance to the optimal algorithm. Thus, the results provide the clue that the proposed algorithm is more energy efficient for each D2D user than the existing algorithms. The effectiveness and validation of the proposed algorithm are further described in Figure 10 in which the sum rate is evaluated under D2D transmission power. As can be seen from Figure 10, the sum rate of proposed M21GS algorithm is better than CG [20], DARA [16], and the random resource allocation algorithm at each particular power level of the D2D user. Furthermore, when the transmission power is above 300 mW, the sum rate of the algorithm decreases but the proposed algorithm still shows an improved sum rate and a close performance to the optimal algorithm. Thus, the results provide the clue that the proposed algorithm is more energy efficient for each D2D user than the existing algorithms.

Discussion
This section discusses the findings of the proposed study. As can be seen from the simulation results in Figure 2 to Figure, the proposed allocation algorithm gives better performance in terms of the mentioned parameters in those Figures as compared with the existing competing alternatives. As can be seen from Figure 2, when the number of channel allocations increases, the total system capacity of the existing algorithms in references [16,20] and RRA is much lower than the proposed algorithm. The capacity gap gets wider with an increasing number of channels which makes the proposed

Discussion
This section discusses the findings of the proposed study. As can be seen from the simulation results in Figures 2-10, the proposed allocation algorithm gives better performance in terms of the mentioned parameters in those Figures as compared with the existing competing alternatives. As can be seen from Figure 2, when the number of channel allocations increases, the total system capacity of the existing algorithms in references [16,20] and RRA is much lower than the proposed algorithm. The capacity gap gets wider with an increasing number of channels which makes the proposed algorithm superior than them. It is also worth notable that the proposed scheme has closed performance with the optimal allocation scheme and this validates with the analytical formulation. In Figure 3, the access allocation to the number of D2D users versus the number of channels is compared for all the algorithms. It can be clearly seen from Figure 3 that as the number of channels allocation increases, the D2D users' access of the proposed algorithm shows better performance than the existing reference algorithms and it also has close relation with the optimal scheme, verifying its effectiveness. The impact of the number of D2D user pairs on the capacity is illustrated in Figure 4. As can be seen from Figure 4 that as the number of D2D user pairs increase, the capacity of the proposed scheme shows a better increase than the existing algorithm, which makes it suitable for a large number of D2D users pairs scenarios. To elaborate on the effectiveness of the proposed allocation algorithm further, the total system capacity is analyzed against the SINR threshold in Figure 5. The results indicate that the capacity of the proposed M21GS scheme is better than reference [16,20] and random resource allocation schemes for any SINR threshold value. This means the proposed scheme gives stable and improved QoS under different SINR conditions. The impact of the number of iterations on the total system capacity and the average energy efficiency is assessed in Figures 6 and 7. In Figure 6, when the number of channels is 10, the proposed algorithm converges at Iteration = 4 and gives 0.6 × 10 8 bps capacity. When the number of channels is 20, the proposed algorithm reaches its peak capacity of 1.25 × 10 8 bps at Iteration = 7. Finally, when the number of channels is 30, the proposed allocation algorithm reaches the peak capacity of 1.9 × 10 8 bps at Iteration =12. Such results give us important information about the impact of the number of iterations on the total system capacity. It means that for a higher system capacity requirement when the number of channels is increased, the number of iterations should also be increased to reach the peak capacity value. On the other hand, the existing algorithms require a large number of iterations to give the same capacity, which makes them unsuitable for the D2D communications. The impact of the number of iterations on energy efficiency is illustrated in Figure 7. The results indicate the effectiveness of the proposed algorithm over the existing algorithms. The energy efficiency of the proposed algorithm is almost independent of the number of iterations and stable at 58 Mbit/J which makes it robust against hardware impairments and channel limitations. On the other hand, the scheme in reference [20] reaches an energy efficiency of 50 Mbit/J at Iteration = 13. The algorithm in reference [16] requires MAXGEN= 10 to reach its peak energy efficiency of 43 Mbit/J, whereas the random resource allocation algorithm requires MAXGEN=15 to reach its peak energy efficiency of 33Mbit/J. By comparative assessment of both results in Figures 6 and 7, the proposed scheme requires a smaller number of Iterations to provide an improved performance than the other competing alternatives. Therefore, system performance can be controlled to an optimal outcome by setting the number of Iterations to a particular required value. Figures 9 and 10 further elaborate on the effectiveness of the proposed algorithm.

Conclusions and Future Recommendations
The allocation algorithm based on the many-to-one Gale-Shapley algorithm proposed in this paper can effectively solve the resource allocation problem of D2D users using multiplexed cellular user channels in heterogeneous cellular network environments. In order to improve the utilization of the wireless spectrum, the algorithm allows multiple D2D users to share the channel resources of one cellular user and ensures the communication service quality of the cellular users and D2D users by setting the SINR threshold. A D2D user and channel preference list are established based on the implemented system capacity to maximize the system total capacity objective function. The KM algorithm is used to allocate channels for D2D clusters to maximize the total capacity of D2D users [21]. The MATLAB simulation is used to compare and analyze the total system capacity of the proposed algorithm, the resource allocation algorithm based on the delay acceptance algorithm, the random resource allocation algorithm and the optimal exhaustive search algorithm, and the maximum allowable access D2D users. The simulation results show that the proposed algorithm has fast convergence and lower complexity than the state-of-the-art schemes [16,20] and random resource allocation. The total capacity is close to the optimal algorithm. The next research area will be to extend this work to consider error margin in D2D underlaying cellular networks with a focus on power allocation and other important aspects [26].