Energy Efficiency Optimization and Dynamic Mode Selection Algorithms for D2D Communication Under HetNet in Downlink Reuse

Device-to-Device communication (D2D) is a promising technique for improving fifth-generation cellular network (5G) spectrum and energy efficiency. However, limited user power and co-channel interference make designing an energy efficient D2D communication a difficult task. In this paper, a novel framework is proposed to optimize the energy efficiency of D2D communication coexisting with a heterogeneous network (HetNet) in downlink transmission. This optimization problem is mathematically formulated in terms of mode selection, power control, and resources allocation (i.e., NP-hard problem). The optimization fraction problem is simplified based on network load and is solved using different optimization methods. An innovative dynamic mode selection based on Fuzzy clustering is introduced. Proposed scheme performance is evaluated and compared to the standard algorithm. Simulation demonstrated the advantage of the proposed framework in terms of gain performance in both energy efficiency and number of successfully connected D2D users. Moreover, D2D communication improves energy efficiency of the heterogeneous network of Downlink transmission.


I. INTRODUCTION
The number of connected devices is expected to reach 50 billion in 2020, and over the next 10 years data traffic will increase 1000 x [1], [2]. This tremendous growth presents several challenges for current fourth generation network (4G) technologies: insufficient spectrum resources and upsurge in power consumption. The impending fifth generation cellular network (5G) is proposed to address such difficulties and to improve energy and spectral efficiency. The 5G heterogeneous architecture is composed of small cells that overlay macro cells and is supported by new technologies (e.g., massive MIMO, mmWaves, full duplex, and deviceto-device communication [D2D]). Researchers [3]- [5] have investigated various solutions that can be deployed to increase energy efficiency (EE) of the 5G Network. D2D communication, in particular, has attracted a considerable amount of attention and has been proposed in Long-Term Evolution The associate editor coordinating the review of this manuscript and approving it for publication was Yuan Gao . release 12 (LTE-A). The technology has been shown to bypass base stations (BS), enabling direct communication among devices located in close proximity [6]. D2D users can utilize the uplink (UL) and downlink (DL) channels to communicate using one of three modes: 1) dedicated mode (DM), or overlay, wherein D2D users and cellular users (CUEs) are assigned orthogonal channels; 2) cellular mode (CM), wherein D2D users communicate through BSs as regular CUEs; and 3) reuse mode (RS), or underlay, wherein D2D uses CUEs channels during either UL or DL transmission. Narrowing communicating user proximity has shown to improve spectral efficiency (SE) and EE, reduce user equipment power consumption, and decrease latency. Despite these advantages, D2D communication introduces new challenges for network designers, including interference management, resource and power allocation, and mode selection coordination. Thus, to take full advantage of D2D communication in 5G network, mode selection, resource and power allocation algorithms must be carefully designed to guarantee Quality of Service (QoS) for cellular and D2D users [7].
The balance of this paper is organized as follows. Section II presents the related work of D2D communication in DL reuse. Section III summarizes contributions of this work. Section IV introduces the system model and presents the mathematical formulation. Section V develops a new scheme based on the network load. Section VI presents the simulation results used to validate the proposed model. The paper is concluded in section VIII.

II. RELATED WORK A. D2D COMMUNICATION IN DL REUSE
Many earlier investigations focused on UL reuse, this paper is investigating the DL reuse mode under heterogeneous network (HetNet). In DL reuse, D2D users are exposed to high interference generated by near BS, which depends exclusively on user location and BS transmission power. Thus, improving D2D performance is possible by controlling BS transmission power and performing an intelligent dynamic mode selection for D2D users. Furthermore, designing power and resource allocations for D2D users can mitigate interference to CUEs and enhance the overall network performance.

1) POWER CONTROL (PC)
controlling transmission power is an approach to improve EE and to restrict interference among various network tiers in HetNet. In [8], the authors proposed an adaptive and cooperative reinforcement learning algorithm for D2D power allocation to maximize conventional cellular network (CN) and D2D throughput. The performance of the proposed algorithm outperformed the performance of distributed reinforcement learning and random power allocation at a communication range of 20 m.
2) RESOURCES ALLOCATION (RA) efficient D2D resource allocation plays a crucial role in reducing CUEs interference levels in DL reuse. Authors in [9], [10] utilized game theory for RA. A sequential second price auction was introduced in [9], and a reverse iterative combinatorial auction was proposed in [10] for D2D RA to maximize the sum-rate. The allocation schemes allowed multiple D2D to share a resource block. However, system performance was evaluated at D2D separation distances limited only to 25m in [9] and 5m in [10]. A power optimization scheme was formulated via RA and mode selection [11] to minimize DL transmission power. The optimization solution consists of two steps: First, a heuristic algorithm was used to select transmission mode either a cellular or direct mode; second resource block allocation was performed. The proposed algorithm conserved the total DL transmission power. An auction based distributed algorithm was proposed in [12] to implement resources allocation for small cell and D2D users in HetNet, while limiting interference to macro cell users. In [13], the Interference Limited Area (ILA) control method was implemented around D2D transmitters to reduce interference to CUEs, where a D2D transmitter is not allowed to share the resources of CUEs located insides its ILA.
The joint resource and power allocation have been studied with an aim to improve throughput and EE in [14]- [19]. An interference management algorithm was proposed for D2D in UL and DL transmission in [14]. First, authors performed D2D admission control and power allocation to prohibit harmful interference to CUEs. Then, D2D channel assignment was designated to maximize throughput. In [15], an iterative algorithm was proposed to maximize the D2D sum rate, where multiple D2D pairs can share the same resource with CUEs. However, the QoS requirement of D2D users was not considered. In [16], authors presented interference Graph-Based resource allocation (InGRA) for maximizing CN throughput, where interference relationships between CUEs and D2D links were modeled using a graph. Each vertex of the graph characterizes a cellular or D2D link, while the edge connecting two vertices wighted the mutual interference. In [17], researchers formulated a nominal optimization problem to improve the sum rate of the D2D users taking the uncertainty of the channel state information into consideration.
In [18] and [19], the joint resources and power allocation approach have been used to improve the EE of D2D communication. Researchers utilized Dinkebach algorithm in [18] and Charnes-Cooper transform in [19] to decouple the numerator and denominator of the fraction optimization function. The simplified form of the fraction function was solved by convex optimization methods to achieve a near optimal solution. It is important to note that in [19] authors considered only dedicated mode for D2D users.
Although ongoing research efforts address D2D in DL reuse, D2D underlaying HetNet has yet to be comprehensively studied. The EE maximization of HetNet supported D2D communication and relay was investigated in [20]. EE optimization was formulated as function in power and user association. Charnes-Cooper transformation is used to covert the fraction optimization to concave optimization. Then, an outer approximation algorithm (OAA) was then applied to determine optimal power and user association. However, researchers assumed an interference-free network. In [21], the authors presented an energy-efficient self-organized cross-layer optimization scheme. The authors solved RA and PC of D2D communication independently using a non-cooperative game. This work, however, did not consider the power control of BSs, which is the major factor to degrade D2D performance in DL reuse.
The most relevant study for our proposed work was presented in [22]. Researchers introduced a centralized decision-making framework at the macro base station (MB) to maximize overall throughput of HetNet. Mode selection, resource allocation for CM and DM users, and power control for RS mode users were implemented. An adaptive distance mode selection considered the separation distance of D2D pair and the interference from MB. The power control solution in RS mode assumed that the sum of signal-to-interference-plus-noise ratio (SINR) is quasiconvex to support the analysis. Then, the vertex search approach was applied for power allocation. However, this solution is impractical, because complexity increases exponentially with the number of users. Moreover, the researchers assumed a guard zone around MB. No D2D pairs are considered within the zone.

B. MODE SELECTION
Mode Selection (MS) determines whether users should estabilish a cellular mode or switch to a direct mode which could be either dedicated or reuse. Generally, mode selection can be either dynamic or static based on its time scale. Dynamic mode selection can be performed adapting to network and wireless channel changes at the cost of increasing computation and communication overhead. In contrast, static mode selection is permanent over time (e.g., distance-based mode selection) [5].
The theoretical analysis of D2D mode selection with user mobility was explored in [24], [25]. Researchers considered the Received Signal Strength (RSS) as a decision metric of MS. In [24], RSSs of the D2D and cellular DL links were considered, while in [25] RSSs of D2D link and both UL and DL were considered in choosing the mode. In [26], the authors formulated the mode selection of HetNet's users via linear integer optimization aimed to maximizing RSS in DL transmission. A dynamic Stackelberg game framework was proposed for joint mode selection and spectrum allocation in [27]. In [28], the authors proposed a solution based on a coalitional game among D2D links for selecting mode to ensure total transmission power was minimized.

III. CONTRIBUTIONS
To the best of our knowledge, researchers have yet to study D2D EE for mode selection, and resource and power allocation in HetNet DL reuse (See Table.1). A review of the literature suggests that most existing research considers only a short separation distance (i.e., communication range), in spite of the fact that D2D is targeted to use at a separation distance of up to 500 m [29]. Moreover, some studies assumed a guard distance to reduce harmful BS interference. This work addresses previous research limitations and contributions of this work can be stated as follows: 1) Detailed framework proposing and developing novel schemes that are used individually or combined to determine D2D mode selection, resource allocation, and power control to optimally improve the operation (EE) of a multi-tier heterogenous network under various network load conditions: low, medium, and high traffic. A diagram of the proposed framework is depicted in Fig.1. 2) D2D mode selection based on the Fuzzy C mean (FCM) clustering algorithm is developed. It allows the dynamic and real-time (with a TTI) switching of D2D users between dedicated (DM) and/or reuse (RS) mode based on network resource block (RB) availability. The algorithm uses two attributes (received signal power and interference) to identify D2D users suitable for DM and RS operations. Changes in the state of the RB availability will be immediately reflected by switching modes of users that most likely maintain the optimality of the network performance. 3) Under high network traffic (RS mode only), a resource allocation and power control algorithms are performed in sequence to optimize network EE using genetic algorithm.  BSs and transmitters were equipped with an omnidirectional antenna. U pairs of transmitters and receivers are uniformly distributed inside the coverage area. During DL, users are associated with either the MB or an SB j based on maximum RSRP and marked as CUEs, or connected directly to an associated receiver through direct link and marked as a D2D pair. D2D pair selection approach is shown in Fig. 3. Selection is based on (UL and DL) RSRP, and the minimum association RSRP of D2D link (β min ), as defined in [30]. A pair must satisfy the following two conditions to use direct link: 1) Transmitter to receiver (RSRP Dr ) is greater than the minimum association RSRP (RSRP Dr ≥ β min ). 2) RSRP Dr is higher than minimum RSRP UL and RSRP DL . More specifically, RSRP Dr ≥ min{RSRP DL , RSRP UL }.

IV. SYSTEM MODEL AND PROBLEM FORMULATION
Total network users in DL are denoted by is defined for SB j users. For simplicity, the matrices Y K M and Y K SB j are assumed to be determined by the BSs. 1 Elements of the allocation matrices are an indicator function, which is 1 if the k th RB is allocated to a user and 0 otherwise. An allocation matrix Y K W of dimension (|W | × |K |) represents D2D user allocation in RS mode. Also, we assume that one RB is assigned exclusively to no more than one user in each tier, and only one D2D pair can share an RB with preassigned CUEs. Co-channel interference is considered among different network tiers {MB tier , SB tier }, {MB tier , D2D tier }, and In DM mode, orthogonal resources are assigned to D2D users so no co-channel interference occurs. Consequently, user Signal-to-Noise ratio (SNR) and throughput (T DM i ) in DM mode are expressed by where p i is power of D2D tx of pair i th and G k i channel gain from D2D tx to D2D rx on k th RB . 2) Reuse Mode (RS).
In RS mode, D2D users share the CUEs channel, which results in a complicated interference situation for users 1 Celluar users allocation is not considered in this work in each tier, as shown in Fig. 2. One frequency reuse is considered between MB and SB j cells. Consequently, users in each tier are impacted by co-channel interference from the other two tiers. The SINRs of the users {m, s, i} under macro, small, and D2D tier communicating in the same k th RB are given by.
where {G k MB,m ,G k SB j ,s ,G k i } represent the channel gains from MB to m th user, from SB j to s th user, and from D2D tx to D2D rx of the i th pair, respectively. The {h MB,i , h MB,s } are channel gains from MB to D2D rx and s th user, respectively, and {h SB j,i , h SB j,m } are channel gains from SB j to D2D rx and m th user, respectively. The {h i,m , h i,s } are channel gains from D2D tx to users {m, s}, respectively. Channel gains are calculated using VOLUME 8, 2020 log-normal shadowing model and pathloss. Based on the SINR given in (4), the achieved throughput of the i th pair in the RS mode is expressed We aim to maximize D2D EE by mode selection: DM or RS, as well as power and resources allocation while guaranteeing user minimum rate requirements. Theoretically, EE is defined as the ratio of user achieved throughput to power consumption. D2D user throughput was determined in each mode as in (1b) and (5). Power consumption was composed of average circuit power p 0 plus power consumed during transmission p i . The EE optimization in terms of joint mode selection and power and resources allocation is formulated as (5) and detailed in (5a), where (η DM i ) and (η RS i ) are the EE of i th pair in DM and RS modes, respectively. With regard to the above conditions, constraint (5c) indicates a D2D pair will choose no more than one mode DM or RS. Constraint (5d) indicates only one RB will be assigned to each D2D pair. Constraint (5e) indicates an RB can be used by only one D2D pair. Constraints (5f) to (5h) represent the upper and lower bounds of D2D tx and BSs transmission powers. Constraints (5i) to (5k) denote minimum rate requirements per tier users.
The optimization formulation given in (5) is the sum of fraction optimization functions and a mixture of binary and continuous variables, making it an NP-hard problem that requires exponential computation efforts to obtain an optimal solution. To address this problem, we simplified the optimization problem based on network load. In each TTI, the number of free resources in both MB and SB j tiers is represented by RB free , and various algorithms are utilized for maximizing EE. Three load scenarios are considered: 1) Low Load Network: number of available resources RB free is greater than the number of D2D users. 2) Medium Load Network: number of available resources RB free is less than D2D users. 3) High Load Network: all channels are occupied by CUEs and RB free equals zero.

V. PROPOSED EE OPTIMIZATION BASED ON THE NETWORK LOAD A. EE MAXIMIZATION IN LOW LOAD NETWORK
Under a low load, all D2D users operate in DM mode, 2 and selection variable Z DM i equals 1 for ∀i ∈ W . Therefore, optimization problem (5) is reduced into (6). EE maximization is achieved by optimizing D2D user transmit power while observing D2D user minimum rate and transmission power requirement.
Equation (6) is the sum of ratio functions (SoRPs). A Dinkelbach-like algorithm was proposed for solving SoRPs in [31]. The algorithm converts the sum of ratio functions into a sequence of parametric function. Given that the numerator is non negative and concave function in p i ∀i ∈ W , and the denominator is positive and an affine function, and constraints R i are concave function in p i ∀i ∈ W . The fraction problem (6) was reformulated into the sum of a parametric problem in (7). Function η DM i (λ i ) is the sum of quasiconcave functions and continuous strictly monotonic decreased in λ i with unique root [31]. The optimal solution P * W of fraction problem (6) is equivalent to finding the root λ i of the parametric function (7). Dinkelbach-like implementation is given in algorithm (1). We applied an interior-point method to solve the problem (η DM (λ i )) and find the optimal power that maximizes (6). Algorithm (1) shows that in each iteration (line 2), the optimization function (7) was solved for a given parameter vector {λ i } d i=1 to the point at which the value of parametric function was less than the tolerance ( ).
Algorithm 1 EE Optimization in Low Load Network (Dinkelbach-Like Algorithm ) Solve optimization problem (7) using Interior point algorithm and find (P n * W ). 3: Find the value of equation (7) at

B. EE MAXIMIZATION IN MEDIUM LOAD NETWORK
Under a medium load, some D2D users remain in DM, while others operate in RS mode. The optimization problem is expressed as formulated in (5) subject to constraints (5b) to (5k) which carried out in the following expression.
To solve equation (8), mode selection assignment is developed based on FCM clustering. Unlike other mode selection approaches that considered only one attribute (e.g., pathloss, distance, or SNR), this study considers two attributes (RSRP Dr , γ RS i ) for determining D2D pair mode. FCM algorithm seeks to minimize the objective function (9) that made up of cluster memberships and distance.
where y i defines the feature vector for i th D2D pair, and cj the cluster centroid. FCM clustering is assigned a D2D pair to multiple clusters with membership coefficients u ij . A fuzzy membership matrix U u ij is generated, where u ij represents membership coefficient of the i th D2D pair to the j th cluster. The membership coefficient u ij has the following properties.
• u ij ∀i = 1, 2, . . . d, j = 1, 2 (two clusters) where d number of D2D pairs. FCM, described in algorithm (2), clusters D2D users into DM and RS clusters. For each D2D user, two attribute (features) are considered for the FCM algorithm y i = {RSRP Dr , γ RS i }. The first feature RSRP Dr is received power at D2D rx , which takes into account large scale fading (i.e., pathloss and shadowing). The second feature γ RS i is the SINR of D2D pairs operating in reuse mode. γ RS i accounts for the worst case interference scenario caused by MB and SB j tiers. Outcomes of the FCM algorithm divides D2D users into two clusters: DM user cluster (DUE DM ) and RS user cluster (DUE RS ) with their corresponding membership coefficients u ij .
Following to algorithm (2), algorithm(3) was used to modify user assignment based on membership coefficient and number of free resource blocks in each TTI. Users in RS cluster with high DM membership coefficient will be shifted into DM mode, when free RBs become available. However, when a greater number of CUEs are scheduled, DUE DM users with high RS membership coefficient will be shifted into RS mode to free up resources. Using mode selection indicator vectors {Z DM , Z RS } for D2D pairs obtained from algorithm (3), algorithm (1) is applied to calculate power allocations for users in DUE DM ; while algorithm (4) is performed to allocate resources followed by (5) to calculate power allocation for users in DUE RS .

C. EE MAXIMIZATION IN HIGH LOAD NETWORK
When the network is fully loaded and all RBs are allocated to CUEs under different tiers, D2D users operate in RS mode. Therefore, mode selection indicators are set to Z DM i = 0 and Z RS i = 1, ∀i ∈ W , and the optimization problem can be expressed as (10).
By setting Z RS i = 1, ∀i ∈ W , the problem becomes a joint RA and PC optimization. Equation (10) remains an NP-hard problem, given that the objective function is fractional and non-convex, and the optimization variables are integer and continuous variables. The problem is solved by two steps. First, D2D user resource allocation uses SMS algorithm in [32]. Second, power control is performed using a genetic algorithm.  the search space for each pair, the set ψ * RBs (i) is defined for each pair.

Algorithm 3 Dynamic Mode Selection
3) Allocate RB for D2D pairs. Following step (2), each D2D pair would have access to with a set of candidate RBs (ψ * RBs (i)). Also, an RB can be a candidate for more than one D2D pair. Hence, sequential search is performed to match a D2D pair to an RB. Given throughput matrix [T (ψ * RBs )] where its elements are composed of total throughput from CUEs and D2D pairs at the set of candidates resources (ψ * RBs ). The SMS allocates an RB to D2D pair that achieving the highest gain in the throughput compared to other D2D pairs. Thus, accumulated throughput is maximized in each RB.

2) GENETIC ALGORITHM (GA) POWER CONTROL
Maximizing EE in terms of number of varying powers is a challenging task because fraction function is neither concave nor convex. The presence of interference powers (P MB , P SB j ) in SINR causes throughput of D2D link become not jointly concave in the (P MB , P SB j ). Hence, fractional programming algorithms can not directly be employed [33]. Graphic visualization of EE versus that of various interference levels is depicted in Fig. 4. Notably, the graph is non-smooth and contains many saddle and local maximum points, which result from the summation term in the optimization function (10). Genetic algorithm can overcome this and determine global maximum. Hence, we utilized the GA [34] algorithm for controlling BSs and D2D transmitters power. GA is populationbased method adapting its concepts from the field of biology. At each iteration of the GA algorithm, a new population of points based on an older iteration is generated. The function then assesses each point until a point in the population reaches an optimal solution. Since GA follows random initialization, it avoids local maximums and evolves toward global maximum by searching different areas of space. A pseudo code of GA is provided in algorithm (5).

VI. SIMULATION RESULTS AND ANALYSIS
The proposed framework performance was evaluated through Matlab simulation. A single cell with MB located at the center Find I max m,k ; I max s,k from (10h ) and(10i) 3: Step2: Find optimal set of RBs ψ * RBs 5: for i ← 1, L do 6: while k ≤ K do 7: ψ RBs (i) = and two SBs located within MB coverage were considered. Primary parameters are taken from 3GPP standard [35] and found in Table 3. System bandwidth is 10MHz, and the channel corresponded to a resource block is 180KHz bandwidth. Moreover, the proposed algorithms were compared with the following baseline algorithms.

1) SMS Resource Allocation Algorithm
• Random Allocation. Resource blocks are assigned randomly to D2D pairs.
• Brute Force Search. Brute force search is applied to find the optimal resource for each D2D pair.

2) Mode Selection Algorithm
• Random mode selection. In random mode selection each D2D pair randomly determines its mode with 0.5 probability.
• Static mode selection. In static mode selection D2D pair chooses its mode based on predefined threshold distance d th . As in [22], threshold sets d th = 50m. If the distance between D2D tx and D2D rx is less than d th , DM mode is selected; otherwise, RS mode is selected. VOLUME 8, 2020 Solution: X = {PW * , P * MB , P * SB } 1: Generate |P| sets from S randomly; 2: Generate values of for each set in P 3: Save the sets in current solution space Pop; 4: for i = 1 to G do 5: Number of elite members in Pop num elite = E; 6: select the best num elite solutions in Pop and save them in Pop 1 ; 7: Number of crossover solutions num crossover = (|P| * num elite )/2; 8: for j = 1 to num crossover do 9: Randomly select 2 solutions X A and X B from Pop; 10: Generate X C and X D by one-point crossover to X A and X B ; 11: Save X C and X D to Pop 2 ; 12: end for 13: for j = 1 to num crossover do 14: Select a solution X j from Pop 2 ; 15: Mutate each element of X j at a rate M and generate new solutionX j ; 16: ifX j is non-feasible then State UpdateX j with a feasible solution by repairingX j ; 17: end if 18: Update X j withX j in Pop 2 ; 19: end for 20: Update Pop = Pop 1 + Pop 2 ; 21: end for Return the best solution P * W , P * MB , P * SB which gives the best value of η * RS in Pop; Power allocation was performed using algorithm (1) for DM mode users. RA and PC were calculated by algorithms (4) and (5), respectively, for RS mode users. D2D pair locations for one of simulated topologies is displayed in Fig. 5. D2D user selection based on {RSRP, β min } does not restrict separation distance to a specific distance. This variable separation distance demonstrates the practicality of D2D communication without any limitations. Also, the guard zone surrounding BSs was not assumed in the proposed scheme; this represents the worst case scenario for D2D users. D2D pairs could be located any where with the cell. Fig. 6 shows the distribution of D2D distances between paired devices. When devices operate under DM mode, D2D pairs with separation distances of up to 400 m are able to communicate and maintain the required QoS. However, once  devices operate under RS mode, the maximum distance for communicating pairs is reduced to 160 m due to interference and signal attenuation.

B. D2D THROUGHPUT
Although the primary focus of this study is D2D EE, SMS allocation algorithm performance in the RS mode was also examined. Fig. 7 illustrates overall D2D throughput as a function of the number of D2D pairs for three different allocation  algorithms: 1) brute force (red line), 2) SMS (blue line), and 3) random (green line). Overall, SMS and brute force performed better than random allocation. SMS throughput achieved nearly the same results with less time as brute force, albeit giving priority to users with high throughput. Generally, throughput rate increases consistently as the number of D2D users increases. However, the rate of the increase vary based on distance separation between D2D tx and D2D rx .

C. LOW AND HIGH NETWORK LOAD ENERGY EFFICIENCY
In this section, the EE in low and high load circumstances is investigated for a various number of D2D users. Fig. 8a details EE maximization results when applying algorithm (1) in low load. Fig. 8b details EE maximization when applying algorithm (4) for RA and (5) for PC in a high load scenario. Results were averaged over multiple typologies for each D2D count. Fig. 8. demonstrates that EE increases as the number of D2D users increases in both low and high load scenarios. At low load network, there is a significant difference in the level of EE obtained using the proposed scheme as opposed to the EE level obtained using the two testing mode selection schemes. The proposed scheme forced D2D users to operate in DM mode when ever free RBs were available. This results in an essential increase in EE. In fact, achieved EE is nearly twice that obtained when using random and static mode selection.
In high load networks, and despite the fact that all D2D users operated in RS mode, D2D EE outperformed the other two testing mode selection schemes. Due to the proposed dynamic mode selection, D2D users are not permanently assigned to a mode. In static mode selection, users are unable to switch from DM to RS mode when orthogonal resources become not available even if switched users were able to maintain QoS requirements in RS mode. Consequently, more users were blocked, and EE performance was significantly degraded.

D. MEDIUM LOAD NETWORK RESULT
This section illustrates performance of the proposed dynamic mode selection scheme based on clustering and FCM membership coefficient calculations. Number of D2D users was fixed at 25 pairs, and minimum rate requirement was set to 56kbps. Number of RBs occupied by CUEs was changed to represent variation in network load. Appropriate algorithms were chosen to perform EE maximization. Fig. 9 illustrates the two-dimensional feature space of attributes for a typology. One can see that some data points are sufficiently close to each other, while others are distant apart. The distant points (i.e., referred to as isolated points in algorithm [2]) influence cluster centroids and membership coefficients. Thus, they may not be as representative. To overcome the bias due to the presence of isolated points, post-processing steps were implemented to correct cluster centroids and accordingly adjust membership coefficients of D2D users. Isolated points were assigned to one cluster with membership equal to 1, eliminating any potential mode switching. Following, FCM algorithm was applied to the set of remaining users to update centroid clusters and to calculate membership coefficients.   Users grouped in the blue cluster are with low RSRP and low SINR measurements and assigned DM mode, while the users grouped in the red cluster are high RSRP and high SINR and assigned RS mode. User location in each cluster of a topology is shown in Fig. 10 b. The FCM algorithm groups users with small separation distance in the RS cluster regardless of their location with respect to MB. Gain achieved using proximity of the pairs was shown to overcome high interference, while users maintain the required QoS. Algorithm (3) was applied for D2D mode selection at various load scenarios. Operation mode of each user was based on its membership coefficient to each cluster. Fig. 11a depicts the scenario of selecting users from RS cluster to DM cluster when network load decreases and additional RBs become available. Fig. 11b. illustrates switching users from DM cluster to RS cluster when CUEs requested additional RBs.

2) D2D Energy Efficiency versus Load
This section demonstrates the advantage of switching user mode based on FCM membership coefficient adapting to network load changes. The proposed scheme shows improvements over other testing selection modes for most network load conditions. It also maximizes the number of connected pairs (as fewer connections were blocked), as shown in Fig. 12.a. As more RBs occupied and more DM users change to RS mode, results of static mode selection outperform the proposed scheme in a number of cases. High EE leverages static mode selection when users with separation distance less than 50m, as defined earlier, are chosen as DM mode. While the proposed scheme assigned users with small separation distance to RS mode. Static mode selection out-performance comes at the expense of increasing the number of blocked D2D, as shown in Fig. 12. b Random mode selection does not follow any trend and depends on DM and RS user selection for each case. Although the proposed scheme presents less EE values in some load cases, it maximizes the number of successful D2D communication in all load cases, as shown in Fig. 12.a and Fig. 12. b. FCM membership coefficient, as mode selection indicator, intelligently switches users from DM to RS while minimizing the number of blocked D2D.   Fig. 13 illustrates power consumption and number of D2D users in DM and RS mode versus network load. Power consumption gradually increased as more users shifted from DM to RS mode. At the beginning, power increment rate was nearly constant, since switched users belonged to an RS mode cluster with a high degree of membership and small separation distance. As network load increased, rate of power consumption increased, as well, since switched DM cluster users required more power due to increase separation distance. Finally, when switching users were blocked, power consumption decreased. Generally, average power consumption per pair was approximately 11.61 dBm in dedicated mode and 14.84 dBm in reuse mode

E. OVERALL ENERGY EFFICIENCY
Network EE is defined as the ratio of achieved throughput to total power consumption of HetNet. BSs power consumption model is given in [36]. The overall power P HN consumed by HetNet with D2D communication is given by (12).
Parameters MB and SB represent the slope of the loaddependent power consumption of MB and SB j , respectively. Finally, P 0 MB and P 0 SB denote static power of MB and SB j , respectively. HetNet EE with D2D capability was compared to HetNet EE without D2D capability. Fig. 14 shows that D2D improves HetNet EE. When network load is light, there is a significant improvement in EE, since D2D users operate in DM mode. However, as network load increases, EE gains and losses are due to D2D mode switching to RS or DM. As more users switch to RS mode, they are required to increase transmission power to accommodate the minimum required QoS. Furthermore, users may become blocked due to high interference and/or increased separation distance.

VII. COMPUTATIONAL COMPLEXITY ANALYSIS OF THE PROPOSED FRAMEWORK
• SMS Algorithm SMS algorithm complexity results from the need to calculate the optimal set of resources for each pair. Hence, D2D pair interference threshold should be compared to maximum interference threshold at each RB line 5-12 to yield a computational complexity of O(KL). For line 17 in algorithm (4), we applied a search to determine maximum values in a vector. The worst case scenario for finding the maximum in each iteration is O(KL). Consequently, total computational complexity of the SMS algorithm is polynomial O(KL + KL + K ) O(KL), where L is the number of D2D users working in RS mode, and K total number of RBs in system.

• Dinkelbach Link Algorithm
Dinkelbach-link algorithm [33] converged the optimal solution at a linear rate. The algorithm converts the original fractional problem into a sequence of parametric functions so that algorithm complexity depends on solving the parametric function and finding its roots.
In each iteration, Newton method was used to update the value of auxiliary variables λ i . Then, optimal PW * was obtained for a given λ i using a convex optimization method; if η DM ({λ n i } d i=1 ) ≤ , iteration is terminated and optimal P * W is obtained. Otherwise, a new λ i is calculated, followed by the next iteration. The time complexity of algorithm (1) was linearly increased with the number of the D2D pair.

• Mode Selection Algorithms
FCM complexity is given by O(WC 2 FI )), where W is the number of data point (D2D pairs); C is number of cluster (2 clusters); F is the dimension of the feature space (in our proposed model 2-D is {RSRP d , γ RS i }); I is the number of iterations required for the FCM objective function to converge in [37].

• Genetic Algorithm
Time complexity of GA algorithms cannot be determined since it depends on many factors: population size, objective function complexity, and iteration number. The execution time of the proposed algorithms was calculated based on laptop with following specifications (Intel core TM i7 @2.4 GHz, RAM 8.00GB) and presented in Table 4.

VIII. CONCLUSION
In this paper, we proposed a comprehensive framework for optimizing D2D communication EE in downlink by leveraging dynamic mode selection, power allocation, and resource allocation. The framework presents a novel dynamic mode selection based on a fuzzy clustering algorithm, which identified similarities between users based on two metrics (RSRP Dr , γ RS i ), and then identified them as a DM or RS user. Dynamic mode selection can be extended to include additional features for adapting network changes and user mobility. Based on network load, algorithms were implemented to maximize EE via power and resources allocation. The proposed framework achieved higher energy efficiency when compared to baseline schemes, and maximized the number of connected D2D users. Moreover, results demonstrated that D2D deployment under HetNet improved network EE of downlink transmission.