Multiband Spectrum Sensing and Power Allocation for aCognitive Radio-Enabled Smart Grid

As part of an Internet of Things (IoT) framework, the Smart Grid (SG) relies on advanced communication technologies for efficient energy management and utilization. Cognitive Radio (CR), which allows Secondary Users (SUs) to opportunistically access and use the spectrum bands owned by Primary Users (PUs), is regarded as the key technology of the next-generation wireless communication. With the assistance of CR technology, the quality of communication in the SG could be improved. In this paper, based on a hybrid CR-enabled SG communication network, a new system architecture for multiband-CR-enabled SG communication is proposed. Then, some optimization mathematical models are also proposed to jointly find the optimal sensing time and the optimal power allocation strategy. By using convex optimization techniques, several optimal methods are proposed to maximize the data rate of multiband-CR-enabled SG while considering the minimum detection probabilities to the active PUs. Finally, simulations are presented to show the validity of the proposed methods.


Introduction
The Internet of Things (IoT) has the power to reshape the world as we know it. The Smart Grid (SG), as part of an IoT framework, adopts advanced Information and Communication Technologies (ICTs) [1,2] to constantly optimize electrical power generation, delivery, consumption, and storage of electricity. In order to achieve this goal, SG applications need to transmit a huge amount of data, such as meter readings, sensor data, surveillance data, multimedia data, automation data, and services [3], so effective communication is very important for SG applications.
Wireless communication technologies are strongly recommended for SG applications [4,5], because of their flexibility, wide coverages, wall-penetration capabilities, and ease of installation. However, as mentioned before, considering a huge amount of data is needed to be shared within the SG information network and the spectrum limitations of existing wireless communication technologies, advanced communication technologies are extremely needed for SG applications.
Cognitive Radio (CR) is a wireless communication paradigm in which the unlicensed users or Secondary Users (SUs) who have no spectrum licenses can opportunistically access and use the unused spectrum of licensed users or Primary Users (PUs) who have spectrum licenses without causing interference to the PUs. In a typical CR system, SUs first perform spectrum sensing to find the unused bands and then adjust their transmission parameters such as coding schemes, modulation schemes, and transmitting power to access the unused bands. There are three types of spectrum-sharing techniques in CR systems: interweave, spectrum sensing and power allocation method for interweave-CR-enabled SG. Section 4 gives the joint spectrum sensing and power allocation method for underlay-CR-enabled SG. Section 5 presents the simulation results, and conclusions are made in Section 6.

Energy Detection
Energy detection is the most often considered spectrum sensing method in the CR literature because of its simplicity and adequate performance. The received signal y(n) of energy detection is [16]: where x(n) is the PU's signal, w(n) is the additive white Gaussian noise with zero mean and variance σ 2 w , h is the channel gain and assumed to vary with time, but remains invariant during one frame, and n denotes the n-th sample of N total samples. The test statistic of energy detection is: In CR, the main concern is that the presences of PUs should be detected properly and the transmission of PUs should not be interfered by SUs. Thus, the detection probability should be considered first. The false alarm probability means the loss of access opportunities and will cause no harm to PUs so that it can be considered second. Based on this premise, in this paper, we chose the detection probability as the target detection probability. Therefore, given the target detection probability P d0 , the threshold λ and the false alarm probability P f a can be obtained as: where er f c(.) or er f c −1 (.) is the complementary error function or inverse complementary error function, respectively, and γ is the Signal-to-Noise Ratio (SNR).

System Model
The CR-enabled SG network architecture can be divided into three layers, that is the Home Area Network (HAN), Neighborhood Area Network (NAN), and Wide Area Network (WAN) [17]. The HAN consists of various kinds of smart devices equipped with sensors and a smart meter used as a Home Gateway (HGW) in home energy management systems. The smart meter communicates with the smart devices to monitor, control, and manage the energy efficiently. The NAN covers the distribution and transmission domains and communicates with the service providers in the WAN and the HGWs in the HAN. In order to support SG applications such as power outage management, power quality monitoring, and distribution automation, the NAN may cover several square kilometers and needs at least 10 Mb/s to keep a good connection with a few hundred to a few thousand HGWs [7]. The WAN covers the transmission and power generation domains and communicates with multiple NANs and the control center. A very high volume of data, including the data of power generation plants, control centers, substations, transmission and distribution grids, and distributed energy resource stations, may be communicated via WAN links. Considering a vast number of heterogeneous smart devices and the different types of network traffic, it is a challenging task to guarantee the reliable communication links for the HAN, NAN, and WAN, without more advanced communication technologies.
Because of the dynamic spectrum-sharing mechanism of CR, the CR-based SG emerges as a promising technology to meet the complex communication needs of the HAN, NAN, and WAN. For example, as illustrated in Figure 1, the HGWs collect the data from the electric meters, the water meters, and the gas meters and then transmit the data to the NAN Gateway (NGW). Then, CR technology can be adopted by the HGWs and NGWs if the PUs allow spectrum sharing in the cognitive area. In Figure 1, SG users (HGWs and NGWs) are SUs and try to access the unused spectrum bands of PUs. However, due to the unpredictable activities of PUs, the communication links absolutely dependent on CR are unreliable. Thus, researchers suggest that the SG users buy some additional licensed bands from the telecommunication operators, which may be narrower than the unlicensed bands of PUs because of the expensive spectrum purchase cost, but can be used by the SG users all the time [7]. These licensed bands owned by the SG users are called original channels in this paper. The SG users can also access the unlicensed bands owned by the PUs via CR technology. These bands that are unlicensed to the SG users are called cognitive channels in this paper. These unlicensed or cognitive channels may have wide bandwidths, but can only be accessed and used before proper spectrum sensing, while the licensed or original channels may have narrow bandwidths, but can be accessed and used all the time.
According to the above, assume the CR-enabled SG communication network consists of L original channels with bandwidths B b,1 , ..., B b,L , which are bought from telecommunication operators, and M cognitive channels with bandwidths B s,1 , ..., B s,M , which are shared by PUs. The SG users can access the original channels all the time, but can only access the cognitive channels when PUs are absent or the interference limits are not exceeded. Assume that the SG users can transmit data over the L original channels and M cognitive channels simultaneously by some advanced communication technologies such as Carrier Aggregation (CA) and Orthogonal Frequency Division Multiplexing (OFDM) during the transmission period. The block diagram of the proposed single-antenna multiband system is shown in Figure 2, where A/D means an Analog-to-Digital converter and BPF means a Band-Pass Filter. Moreover, all channels share one antenna, which means they should perform transmission and reception at the same time.
The time frame with length T is divided into two slots: spectrum-sensing slot with length τ and transmission slot with length T − τ. Assume the sampling interval is T s , then the number of sensing samples N is T/T s . The frame structure is shown in Figure 3.
During the spectrum-sensing slot, the received SNRs of the PUs at the SG transmitter on the M cognitive channels are γ 1 , ..., γ M . The values of the received SNRs can be estimated by several methods and can be conducted by the HGWs and then broadcast to the NGWs via a control channel [18,19]. During the transmission slot, between the SG transmitter and the SG receiver, the channel gains of L original channels and M cognitive channels are h b,1 , ..., h b,L and h s,1 , ..., h s,M . The channel gains between the SG transmitter and the PU receiver and the channel gains between the SG receiver and the PU transmitter of the j cognitive channel are g sp,j and g ps,j (j = 1, ..., M). All channel gains were assumed to be block fading. The noise variances at the SG receiver of L original channels and M cognitive channels are σ 2 b,1 , . . . σ 2 b,L and σ 2 s,1 , ..., σ 2 s,M . The system model is shown in Figure 4, where Tx denotes the transmitter and Rx denotes the receiver, while the solid lines denote the real communication links and the dashed lines denote the interference links.
Assume the transmission power constraint of the SG transmitter is P. In interweave CR, the powers allocated to the L original channels and M cognitive channels are P bt,1 , ..., P bt,L and P st,1 , ..., P st,M . In underlay CR, the transmitted powers of the PUs are P pu,1 , . . . , P pu,M , and the interference limits for the PUs' receivers are Ψ 1 , ..., Ψ M . The powers allocated to the L original channels are still P bt,1 , ..., P bt,L . However, for the M cognitive channels, a two-level power allocation scheme is adopted. That is, under the absences of the PUs, high-level powers P h st,1 , ..., P h st,M are allocated, while under the presences of the PUs, low-level powers P l st,1 , ..., P l st,M are allocated.
Assume π 0,j and π 1,j are the probabilities that the j-th cognitive channel is unused and used by the PUs and the minimum target detection probability P d0,j is required for the j-th channel. Then, our objective is to find the optimal sensing time and power allocation strategy to maximize the data rate while satisfying all the constraints for the CR-enabled SG communication network.

Proposed Method for the Interweave-Cognitive-Radio-Enabled Smart Grid Network
In the interweave-CR-enabled SG, the SG user can only access the cognitive channels when the PUs are absent. Thus, the effective transmissions over the M cognitive channels occur only if the SG user can properly detect the absences of the PUs when the PUs are really absent. Hence, the data rate of the M cognitive channels is: The data rate should be averaged over time. According to Figure 2, the original channels and cognitive channels share one antenna so that all channels can only perform transmission processing during the transmission slot. Hence, R s becomes: The data rate of the L original channels can also be obtained: As a result, the total data rate R is: Considering the transmission power constraint P, the problem can be formulated as: where P bt = [P bt,1 , ..., P bt,L ], P st = [P st,1 , ..., P st,M ]. The objective function is −R in (9), because finding the maximum of R is finding the minimum of −R.
Taking the second derivatives of −R with respect to the variables P bt,i and P st,j , we have: As a result, −R is convex with respect to P bt,i and P st,j , but it is not convex with respect to the sensing time τ. Thus, (9) cannot be solved directly by using convex optimization methods. However, taking into account that the optimal sensing time τ is within the range of 0-T, so that it can be obtained by exhaustive search, therefore, assuming τ is fixed, by using the Lagrange multiplier method, we can obtain: Taking the first derivatives of L(P bt , P st , µ) with respect to P bt,i and P st,j and then setting them to zero, we have: Taking the first derivative of L(P bt , P st , µ) with respect to µ and setting it to zero yields: Applying (13) and (14) in (15), we can obtain: Finally, substituting (16) into (13) and (14), the optimal power allocation scheme for a fixed τ can be obtained: where the symbol x + denotes max(0, x). Finally, we propose the optimal multiband spectrum sensing and power allocation method for interweave-CR-enabled SG in the following table (Algorithm 1).

Algorithm 1
Optimal multiband spectrum sensing and power allocation method for interweave-CR-enabled SG communication. 1: for each τ in 0 to T do -According to the given target detection probability P d0,j (j = 1, ..., M), compute the false alarm probability P f a0,j for each channel in terms of (4). -ComputeP bt,i (i = 1, ..., L) for each original channel according to (17). -ComputeP st,j (j = 1, ..., M) for each cognitive channel according to (18). -Compute the data rate R according to (8) for the given τ.
2: end for 3: Find the maximum data rate R, and the optimal sensing time and power allocation are the corresponding parameters of the maximum R, that is: τ * , P * bt , P * st = arg max τ,P bt ,P st R(τ, P bt , P st ).

Proposed Method for the Underlay-Cognitive-Radio-Enabled Smart Grid Network
In the underlay-CR-enabled SG, cognitive channels owned by the PUs can be shared with the SUs under certain interference limits. When the PU of a cognitive channel is absent and the SG user can properly detect the absence of the PU, the SG user could access this channel and transmit data with a high-level power P h st,j . In this case, the effective data rate of the M cognitive channels is: When the PU of a cognitive channel is absent and the SG user cannot properly detect the absence of the PU, the SG user could access and transmit data with a low-level power P l st,j . In this case, the effective data rate of the M cognitive channels is: When the PU of a cognitive channel is present and the SG user can properly detect the presence of the PU, the SG user could access and transmit data with power P l st,j . In this case, the effective data rate of the M cognitive channels is: When the PUs are present and the SG user failed to detect the presences of the PUs, then the SG user would transmit data with the high-level power P h st,j , and unfortunately, a collision would occur. The effective data rate is zero in this case.
Therefore, for the M cognitive channels, the total averaged effective data rate in time is: For the L original channels, since they can be used without spectrum sensing, the effective data rate R b is the same as (7). As a result, the total effective data rate R is: Since a two-level power allocation scheme is adopted, the transmission power constraint P should be statistically averaged: st,j π 0,j 1 − P f a0,j + P h st,j π 1,j 1 − P d0,j + P l st,j π 0,j P f a0,j + P l st,j π 1,j P d0,j Besides, the interference limit for the j-th PU receiver is: st,j π 0,j 1 − P f a0,j + P h st,j π 1,j 1 − P d0,j + P l st,j π 0,j P f a0,j + P l st,j π 1,j P d0,j = P g 2 sp,j P h st,j π 1,j 1 − P d0,j + g 2 sp,j P l st,j π 1,j P d0,j ≤ Ψ j (j = 1, ..., M) 0 ≤ τ ≤ T Taking the second derivatives of −R with respect to the variables P bt,i , P h st,j and P l st,j (i = 1, ..., L, j = 1, ..., M) the same as in Section 3, we can also have: T ln 2 g 2 ps,j P pu,j + σ 2 s,j + P l st,j h 2 Hence, −R is convex with respect to P bt,i , P h st,j , and P l st,j , but it is still not convex with respect to τ. In order to solve this problem, we still use the exhaustive search method. Assuming that τ is fixed, by using the Lagrange multiplier method, we have: P h st,j π 0,j 1 − P f a0,j + P h st,j π 1,j 1 − P d0,j + P l st,j π 0,j P f a0,j + P l st,j π 1,j P d0,j − P + M ∑ j=1 κ j × g 2 sp,j P h st,j π 1,j 1 − P d0,j + g 2 sp,j P l st,j π 1,j P d0,j − Ψ j where L(P bt , P h st , P l st , µ, K|µ, K) denotes L(P bt , P h st , P l st , µ, K) with fixed µ and K. Then, the problem becomes: Hence, when µ and K are fixed, by first taking the first derivatives of L(P bt , P h st , P l st , µ, K|µ, K) with respect to P bt,i , P h st,j and P l st,j and then setting them to zero, the optimal P bt,i , P h st,j and P l st,j can be obtained as follows: where C 0,j and C 1,j are: T ln 2 µ π 0,j P f a0,j + π 1,j P d0,j + κ j g 2 sp,j π 1,j P d0,j − 2σ 2 s,j + g 2 ps,j P pu,j h 2 s,j (36) C 1,j = σ 2 s,j g 2 ps,j P pu,j + σ 4 s,j h 4 s,j − (T − τ) π 0,j P f a0,j g 2 ps,j P pu,j + π 0,j P f a0,j σ 2 s,j + π 1,j P d0,j σ 2 s,j B s,j T ln 2 µ π 0,j P f a0,j + π 1,j P d0,j + κ j g 2 sp,j π 1,j P d0,j h 2 s,j Then, in the next step, the optimal values of µ and K should be found to maximize g(µ, K). However, it is difficult to obtain the analytical solutions by common mathematical manipulations. Here, the gradient descent method is used to solve this problem. According to the principles of the gradient descent method, the Lagrange multipliers µ and K can be updated as: where ∂g ∂µ and ∂g ∂K = ∂g ∂κ 1 , ..., ∂g ∂κ M are the partial derivatives of g(µ, K) with respect to µ and K, which are shown as follows: P h st,j π 0,j 1 − P f a0,j + P h st,j π 1,j 1 − P d0,j +P l st,j π 0,j P f a0,j + P l st,j π 1,j P d0,j ∂g ∂κ j = Ψ j − g 2 sp,j P h st,j π 1,j 1 − P d0,j − g 2 sp,j P l st,j π 1,j P d0,j (j = 1, ..., M) and α is the step size and can be determined via a line search of the following approach (Chapter 9 of [20]): In summary, the optimal multiband spectrum sensing and power allocation method for underlay-CR-enabled SG is proposed in the following table (Algorithm 2). Algorithm 2 Optimal multiband spectrum sensing and power allocation method for underlay-CR-enabled SG communication. 1: for each τ in 0 to T do 2: Initialize µ and K. 3: According to the given target detection probability P d0,j (j = 1, ..., M), compute the false alarm probability P f a0,j for each channel in terms of (4). until µ and K converge. Obtain the optimalP bt,i ,P h st,j , andP l st,j , and then, calculate the data rate R according to (23) for the given τ. 6: end for 7: Find the maximum data rate R, and the optimal sensing time and power allocation are the corresponding parameters of the maximum R, that is: (τ * ,P * bt , P h * st , P l * st ) = arg max τ, P bt , P h st , P l st R(τ,P bt , P h st , P l st )

Simulation Results
In this section, we present some simulation results to prove the validity of the proposed methods. We assumed the CR-enabled SG communication network consists of one original channel named B b,1 with bandwidth 100 kHz and two cognitive channels named B s,1 and B s,2 , with equal bandwidths of 8 MHz. In many real systems, the total bandwidth is usually divided into several narrowband sub-channels, such as Global System for Mobile communication (GSM) systems with 25 MHz bandwidth and 125 sub-channels, Narrowband Internet of Things (NB-IoT) systems with 180 kHz bandwidth and 12 sub-channels, and IEEE 802.11g systems with 16.25 MHz and 52 sub-channels, so the bandwidth of a single sub-channel usually ranges from tens of kHz to hundreds of kHz, and it is reasonable to assume the bandwidth of the original channel bought from the telecommunication operator is 100 kHz here. In addition, 6-8 MHz is the typical bandwidth of Television White Spaces (TVWS) [21] for CR usage. The PUs' signals in B s,1 and B s,2 are assumed to be Gaussian distributed, and the probabilities that the cognitive channels are used by PUs, which are denoted by π 1,1 , π 1,2 , are assumed to be equal. According to [22], the activities of the primary users over TVWS can be measured and modeled in advance. Therefore, π 1,1 and π 1,2 can also be measured and assumed to be known in advance. During the spectrum-sensing process, the received SNRs of the PUs at the SG user on the two cognitive channels γ 1 and γ 2 are assumed to be identical. The noise variances of B b,1 , B s,1 , and B s,2 , which are denoted by σ 2 b,1 , σ 2 s,1 , and σ 2 s,2 , are 1 W. The minimum target detection probabilities for the two cognitive channels P d0,1 and P d0,2 are also assumed to be identical. All the channel gains were assumed to be Rayleigh distributed with variance one. In the underlay-CR-enabled SG, the PUs' transmitted powers P pu,1 ,P pu,2 are 1 W and the interference limits Ψ 1 , Ψ 2 are 15 W.
In Figures 5 and 6, we make some comparisons between the proposed methods and the method without multiband CR technology and use "Non-MCR" to denote the data rate of the traditional method without multiband CR technology. In Figures 7 and 8, we make some comparisons between the proposed methods and the method based on conventional CR network [14]. Note that, in Figures 5 and 6, we assume π 1,1 = π 1,2 = 0.5, P d0,1 = P d0,2 = 0.90. Because no multiband CR technology was adopted, the SG user in such a communication network can only access the original channel B b,1 , and its data rate can be determined by B b,1 , σ 2 b,1 and the total transmission power constraint P. In Figures 7 and 8, "conventional" denotes the method in [14] and :proposed: denotes our proposed methods. The communication network in [14] only has cognitive channels B s,1 and B s,2 and does not have the original channel B b,1 . Except for the original channel, all parameters of the conventional methods were set to be the same as the proposed methods. Figure 5 shows the curves of sensing time τ versus data rate R of the proposed methods in multiband-CR-enabled SG. We set the time frame length T = 1 s, the sampling interval T s = 0.001 s, the transmission power constraint P = 10 W, 15 W, and the received SNRs of the PUs at the SG user on the two cognitive channels γ 1 = γ 2 = −5 dB. From Figure 5, for a given time frame length T, it can been seen that the data rate varies with the sensing time τ. Hence, it is necessary to find the optimal τ to maximize the data rate R. By using the exhaustive search method, the optimal sensing time τ is around 0.2 s for both interweave-and underlay-CR-enabled SG according to Figure 5. This is because the sensing time around 0.2 s is large enough to keep the target detection probability under the given conditions. Moreover, it can be seen that the data rate in underlay CR is usually higher than the data rate in interweave CR. This is because in underlay CR, the SG user can transmit data over the two cognitive channels under the interference limits even when the PUs are present, whereas it is strictly prohibited in interweave CR. Besides, for both interweave and underlay CR, when the total transmission power constraint P is increasing, the data rate is increasing. Figure 5 also shows that the multiband-CR-based method (either interweave CR or underlay CR) is far better than the method without multiband CR technology and thus proves the superiority of the proposed method. Therefore, it is very meaningful to adopt multiband CR technology in the SG communication network.   Figure 6 depicts the curves of the received PUs' SNR versus data rate R of the proposed methods in multiband-CR-enabled SG. We set T = 1 s, T s = 0.001 s, P = 10 W, 15 W. As mentioned before, we assumed γ 1 = γ 2 . According to Figure 6, for both interweave and underlay CR, the data rates R are increasing while γ 1 and γ 2 are increasing, and they are all superior to the non-multiband-CR-based method. This is because γ 1 and γ 2 are larger; less sensing time τ is needed to meet the target detection probability, and thus, more time can be used for transmission. However, when γ 1 and γ 2 are large enough (larger than −2 dB), the increase of R becomes slow. This is because the necessary sensing time should be guaranteed to achieve the target detection probability and cannot be decreased any more. Again, we see that the data rate in underlay CR is higher than the data rate in interweave CR, having about a 2-3 dB advantage.  Figures 7 and 8 give the comparison of the received SNR versus data rate curves for interweave and underlay CR between the conventional and proposed methods, respectively. We set the cognitive channel used probabilities to 0.85, that is π 1,1 = π 1,2 = 0.85. It can be seen from Figures 7 and 8 that the proposed methods are better than the conventional methods both for interweave and underlay CR. Besides, when the received SNR increases, the advantage becomes obvious. The main reason is similar to Figure 6. When the received SNR is higher, less sensing time is needed and more transmission time can be used.

SNR (dB)
As for the computational complexity, in interweave mode, the proposed method needs about 2L + 3M + 3 multiplications and 2L + 3M additions to obtainP bt,i and about 2L + 3M + 5 multiplications and 2L + 3M + 1 additions to obtainP st,j . Hence, the total computational complexity of the proposed method in interweave mode is about (2L 2 + 3M 2 + 5ML + 3L + 5M)τ multiplications and 2L 2 + 3M 2 + 5ML + M additions. The computational complexity of the conventional method in interweave mode is about (3M + 5)Mτ multiplications and (3M + 1)Mτ additions; in underlay mode, assuming the number of iterations in one round is N T (T = 1, ..., τ), the proposed method needs about (8M + 1)N T multiplications and (L + 6M + 1)N T additions to obtain µ and 7MN T multiplications and 4MN T additions to obtain K, then it needs about 4L multiplications and 2L additions to obtain P bt,i , M square root operations, 2M multiplications, and 2M additions to obtain P L st,j , and 13M multiplications and 8M additions to obtain P h st,j . As a result, the total computational complexity of the proposed method in underlay mode is about Mτ square root operations, (4L + 47M)τ + ∑ τ N T =1 (15M + 1)N T multiplications, and (2L + 23M)τ + ∑ τ N T =1 (L + 10M + 1)N T additions. The computational complexity of the conventional method in underlay mode is about Mτ square root operations, 46Mτ + ∑ τ N T =1 (15M + 1)N T multiplications, and 20Mτ + ∑ τ N T =1 (10M + 1)N T additions. Therefore, the computational complexity of the proposed method is higher than that of the conventional method. The computational complexities of the two methods are listed in Table 1.

Conclusions
As part of an IoT framework, smart grid applications require effective communication links among the HANs, NANs, and WANs. In this paper, a novel multiband-CR-based SG communication network architecture was proposed. Based on this, several joint spectrum sensing and power allocation methods were further proposed. By using convex optimization techniques, the optimal parameters such as the optimal sensing time and the optimal transmission power were found to maximize the data rate of multiband-CR-enabled SG while considering the target detection probabilities to the PUs. Simulations were presented to prove the correctness and the superiority of the proposed methods compared with the conventional methods.