An Optimized Algorithm for Resource Allocation for D2D in Heterogeneous Networks

: With the emergence of 5G mobile multimedia services, end users’ demand for high-speed, low-latency mobile communication network access is increasing. Among them, the device-to-device (D2D) communication is one of the considerable technology. In D2D communication, the data does not need to be relayed and forwarded by the base station, but under the control of the base station, a direct local link is allowed between two adjacent mobile devices. This flexible communication mode reduces the processing bottlenecks and coverage blind spots of the base station, and can be widely used in dense user communication scenarios such as heterogeneous ultra-dense wireless networks. One of the important factors which affects the quality-of-service (QoS) of D2D communications is co-channel interference. In order to solve this problem of co-channel interference, this paper proposes a graph coloring based algorithm. The main idea is to utilize the weighted priority of spectrum resources and enables multiple D2D users to reuse the single cellular user resource. The proposed algorithm also provides simpler power control. The heterogeneous pattern of interference is determined using different types of interferences and UE and the priority of color is acquired. Simulation results show that the proposed algorithm effectively reduced the co-channel interference, power consumption and improved the system throughput as compared with existing algorithms.

(1) In the D2D heterogeneous network, a heterogeneous interference graph is established to reflect the difference in the importance of the two types of users in the network. (2) The coloring sequence is no longer the previous random coloring or sequential coloring, but a weighted priority coloring. (3) After the wireless resource allocation is determined, the introduction of simple packet power control can not only further reduce the user's transmission power and reduce the impact of interference, but also dynamically adjust the energy consumption on specific wireless resources.
Finally, combined with the algorithm simulations, we compared and analyze the advantages of the proposed algorithm over other similar algorithms.

System Model
In the D2D heterogeneous network, there are two types of users in the system: traditional pair of cellular users and short-distance D2D users. The establishment of the system model is shown in Fig. 1. There are a total of M cellular users in the system, which is C = {C 1 , C 2 , . . . , C M }; N D2D communication pairs, denoted as D = {D 1 , D 2 , . . . , D N }. Among them, C i represents ith cellular user, T x i represents the sender user in the i-th D2D user pair, and R x i represents the i-th receiver user. At the same time, D2D users perform data transmission with the same initial transmission power. In addition, use L c to represent the cellular link set; L d represents the collection of all D2D links; L k represents a set of links using radio resource k. In order to improve spectrum utilization, multiple D2D users are allowed to perform data transmission on multiplexed wireless resources of the same cellular user. Since the LTE system adopts orthogonal frequency division multiplexing (OFDM) technology for downlink, there is no interference between cellular users, and D2D users multiplex the downlink channel resources of cellular users in a non-orthogonal manner, there are two main types of interference in the system: D2D user interference and D2D user-to-cell interference.
The specific interference situation is shown in Fig. 1. Here, C 1 , T x 1 , and T x 2 use the same channel resources for data transmission, and the base station will cause co-channel interference to R x 1 and R x 2 . At the same time, T x 1 will also cause co-channel interference to C 1 and R x 2 . In addition, T x 2 will also cause co-channel interference to C 1 and R x 1 . It can be seen that the interference situation in the D2D heterogeneous network is more complicated. For this reason, it is necessary to allocate spectrum resources reasonably to coordinate co-channel interference, so as to ensure the communication quality of terminal users and improve the spectrum utilization.  In addition, assuming that (ϕ i , r i ) is the polar coordinates of user i, the distance d ij between user i and user j is expressed in polar coordinates as

BS
where r i represents the distance between user i and the base station; ϕ i represents the azimuth of user i. Then the path loss model in the system is as follows. The path loss from the base station to the user is The path loss between different users is Among them, d represents the distance between the transceiver ends of the communication link.

Proposed Algorithm
According to the actual situation, in the D2D heterogeneous network, D2D communication is an auxiliary communication mode. Cellular users are primary users and D2D users are only secondary users. Therefore, the primary and secondary users should be strictly distinguished during interference analysis. In addition, in order to meet the user's normal communication quality requirements, the preset SINR threshold for normal communication of cellular users is γ 1 , and the SINR threshold for normal communication of D2D users is γ 2 . In the weighted priority allocation of resources based on graph coloring, the co-channel interference between communication links and links in the system is abstracted into "vertices" and "edges" in the graph, so as to establish a heterogeneous interference graph H. In particular, when building a heterogeneous interference graph, each communication link in the system should be abstracted as a "vertex" of the heterogeneous graph. However, whether there is an "edge" between the two "vertices", it must be combined with the user SINR The threshold is determined by the degree of co-channel interference between users.

Generating Heterogeneous Interference Graph
The "vertex" in the heterogeneous interference graph consists of cellular links and D2D links. Among them, all cellular links constitute vertex set V 1 , and all D2D communication links constitute vertex set V 2 . V 1 and V 2 together form the set V of all vertices in the graph. According to the inter-vertex interference and the user's communication quality requirements, the set of edges E is formed, and the heterogeneous interference graph H (V (V 1 , V 2 ) , E) can be obtained. Combining the characteristics of the D2D heterogeneous network, the edges in H are mainly divided into two types: single-type interference edges and mixed-type interference edges. Among them, the single-type interference edge is the edge established for the cellular link that only receives single interference from the D2D link. The mixed interference edge is an edge created by the mixed interference from the cellular link and other D2D links for the interference suffered by the D2D link.
When multiple D2D user pairs use the same radio resource k with the same cellular user in a non-orthogonal manner. The SINR of the cellular user C i is The SINR of the receiving end of the D2D link such as R x j is where: SINR C i represents the SINR of C i ; P i,k represents the transmit power of the base station to C i on channel k; G B,C i indicates the link gain from the base station to C i ; P T x j,k represents represents the power of Gaussian white noise; B represents the channel bandwidth.
In addition, the interference generated by the sending end of link i to the receiving end of link j is defined as I ij , which is specifically expressed as (6) where P i represents the transmit power of the transmitting end of link i; G ij represents the link gain from the sending end of link i to the receiving end of vertex j.
To establish a single-type interference edge, the steps (pseudo code) are as follows in Algorithm 1.

Algorithm 1: Edge establishment
and j ∈ ϕ i then 8: Establish heterogeneous interference edge j → i between vertex j and i 9: Determine the edge weight value as w ji = I ji 10: end if 11: While (SINR ij > γ 1 ) 12: end for 13: end The steps and methods for establishing heterogeneous-type interference edges are similar to those of single-type interference edges. The difference is that in step 3, the SINR is calculated using Eq. (5), and the judgment condition in step 11 is changed to SINR ij > γ 2 . Therefore, it will not be repeated here.
After the single-type and heterogeneous-type interference edges are established, a heterogeneous interference graph is finally obtained. At this time, the i saturation S(i) of the vertex is defined as

Weighted Priority Resource Allocation
Assuming that there are two buffer queues at the base station, which store the cellular users and D2D users that initiate resource requests, respectively, and each user corresponds to a data queue to buffer the data to be sent. Without loss of generality, the factors that define the priority of obtaining resources include: (1) Channel quality; (2) Delay of waiting in line for users; (3) The amount of data to be sent by the user; (4) The maximum time delay the user can tolerate. Generally, the higher the priority of the user to obtain resources, the better the channel quality, the longer the user's queuing delay, the more data to be sent, and the lower the user's tolerable waiting delay. Assuming that the time when user i initiates a resource request is recorded as t i,arr_time , and the time when wireless resources are obtained is recorded as t i,leave_time , then the waiting delay T i of user i in the queue is When the waiting delay exceeds the maximum tolerable delay, the user will discard the data packet to be sent. In order to prevent users with poor channel quality from being unable to allocate resources for a long time and reduce the fairness of the system, here the delay is taken as an important factor that affects the priority of users obtaining resources, and the delay weight of user i is defined as where T i,max of user i is allowed to accept the maximum delay.
Assuming that the user expects to send the data size as Q i , the maximum amount of data that can be buffered in the data queue is Q i,max , so the actual size of data to be sent in the corresponding data queue Q i is expressed as At the same time, the signal-to-noise ratio is used to measure the channel quality. The larger the signal-to-noise ratio, the better the channel quality. The signal-to-noise ratio at the receiving end of link i is specifically expressed as Based on the above analysis, the priority for user i to obtain wireless resources is defined as where D (i) represents the priority of user i to obtain resources. The corresponding vertices i and i belong to the vertices of the same set.
When coloring vertices, the user priority and the saturation of the corresponding vertices are considered to determine the coloring order. According to Eqs. (7) and (12), the coloring level F (i) of vertex i in the graph is defined as The current layer color vertex color * needs to meet the conditions as At the same time, the colored vertices are deleted from the corresponding vertex set, and the uncolored vertices are updated.
Consider that D2D communication is only an auxiliary communication mode. Therefore, when performing coloring resource allocation based on the heterogeneous weighting of graph coloring, it is necessary to color the vertices in the vertex set V 1 first, and then color the vertices in the set V 2 . The specific coloring steps (pseudo code) are described as follows in Algorithm 2.
In order to evaluate the fairness among D2D users in the system, jains fairness evaluation standards are used such as where Fair (·) represents the fairness of the system; n represents the number of D2D users requesting resources; x i represents the transmission rate of D2D user i.
The D2D system user loss rate is defined as the ratio of the number of users who abandon the queue waiting for resource allocation due to exceeding the maximum time delay to the total number of requested users, which is specifically defined as where n represents the number of D2D users whose waiting delay exceeds the maximum delay; N represents the number of D2D users requesting resources.

Packet Power Control
In order to reduce the power consumption of the user terminal, on the premise of ensuring the user's minimum SINR requirement, simple power regulation is adopted to minimize the transmission power of the corresponding user. Color the wireless resource allocation results according to the graph, treat all users occupying the same wireless resources as a group, and perform power control on all users in each group, thereby optimizing the user's transmission power.
According to the resource allocation result, calculate the actual SINR of cellular users and D2D users. Combining the SINR threshold γ 1 of C m and the transmit power of D2D users in the same group of G m , the lowest transmit power can be obtained as where P m represents the transmission power of the base station to C m after power regulation.
Update the transmission power of the base station to C m according to Eq. (17), and calculate the SINR of all D2D users in combination with Eq. (5). Then, update the transmission power of D2D users one by one according to the SINR from descending order. According to the threshold requirement γ 2 , the transmit power of the corresponding T x n of the R x n with the largest current SINR of the updated G m is expressed as where P T n represents the transmit power of T n after power control; If T i transmission power has been updated, P T i is the updated transmission power, otherwise it is the original power.
For D2D users whose power has not been updated, according to the order of SINR from large to small, continue to use Eq. (18) to update the transmission power, thereby reducing system power consumption.

Simulation Results
In order to evaluate the impact of the D2D wireless resource allocation algorithm proposed in this paper on system performance, MATLAB simulation is used for verification and analysis. Users are uniformly distributed in the cell, cellular users are distributed within 200 m of the center of the base station, and D2D users reuse cellular user downlink resources. The waiting time delay of each user is randomly generated during simulation, and the other simulation parameter settings are shown in Tab. 1. Since the location of all users in the cell has a certain randomness, the number of simulations is 500 times and the average is taken so that the data obtained has more reference value. At the same time, the random coloring resource allocation algorithm (RCA), the coloring resource allocation algorithm (DCA) that only considers the delay and the traditional graph coloring resource allocation algorithm (TGCA) are used as references to compare with the proposed resource allocation algorithm, focusing on D2D Performance in terms of system fairness, system throughput, and system power consumption.  Fig. 2 that as the number of D2D user's increases, the fairness of the D2D system begins to decrease. Among them, TGCA aims at maximum throughput, and relatively sacrifices more fairness. When there are 80 pairs of D2D users in the system, using the DGCA algorithm can improve scheduling fairness by 5% compared to the DCA algorithm. This is because the DCA algorithm only considers the delay and does not consider the vertex saturation, and DGCA not only considers the vertex saturation, but also takes the delay as a factor of coloring, which can improve those who are delayed due to poor channel quality to a certain extent. D2D users who cannot get the resources get the priority of the resources, so the fairness of the system is improved.  Fig. 3 that the average system delay of different algorithms increases as the D2D logarithm of the resource request increases. Among them, compared with the DCA algorithm, the average system delay of the DGCA algorithm is slightly higher by 0.1 ms when the number of D2D users reaches 50 pairs. However, D2D communication is mainly used for data transmission rather than real-time services, so the 0.1 ms delay is not perceptible to the user. In addition, combined with the analysis of Figs. 2 and 3, it can be seen that the DCA algorithm preferentially allocates colored resources to vertices with larger delays, so that the overall system delay is minimized, but the fairness of resource scheduling is seriously sacrificed. Compared with the other two algorithms, the proposed algorithm shows obvious advantages in reducing system delay.  Fig. 4 that as the number of D2D users in the system increases, the system throughput also gradually increases. Since the TGCA algorithm only allocates coloring resources based on the vertex saturation, the maximum system throughput is obtained. The proposed algorithm not only considers the vertex saturation, but also improves the coloring priority of the vertices with longer delay, so that fewer packets are discarded. Although the throughput obtained is reduced by an average of 1.5% compared with TGCA, it is combined with Figs. 2-4 for comprehensive analysis, the premise of TGCA to obtain higher throughput is to seriously sacrifice the fairness of user scheduling and to a large extent increase the system delay.  The results show that as the D2D user's increases, the system throughput increases, and the larger the threshold, the smaller the system throughput. This is because when the user SINR threshold is not reached, the system access D2D logarithm increases as the requested D2D logarithm increases, thus the system throughput also increases, and the larger the SINR threshold, the less interference the user can bear, allowing access The less the D2D logarithm of, the smaller the system throughput. Fig. 6 compares the total power consumption of the system with and without power control. When there is no power control, both the base station and the user transmit at a fixed power, and when there is power control, it is based on the minimum user SINR requirement. As can be seen from Fig. 6 that the total power consumption of the system is lower when using the power control as compared with no power control. Total system power consumption (W) No power control With power control Figure 6: Impact of power control on the system power consumption

Conclusions
In the TD-LTE system, suitable downlink radio resources of cellular users are selected for multiplexing for D2D users. First, establish a heterogeneous interference graph according to the degree of interference between users with different communication types. The weighted priority coloring order is calculated by further combining the vertex saturation, waiting delay, channel quality, and data volume. Finally, the wireless resource is allocated according to the graph coloring algorithm. Theoretically, the deficiencies of the existing graph coloring resource allocation algorithm are improved, and the maximum throughput performance of the system is achieved. In fact, the factors that affect the allocation of wireless resources are fully considered, which has strong practical application value. Simulation shows that the proposed algorithm has the best overall performance in terms of system average delay, packet loss rate and system throughput, and it also reduces the total power consumption of the system. Further research as an extension to this research study is to consider the cache-throughput analysis and deploy the proposed algorithm in UDNs scenarios.