Design of a Dynamic Demand Response Model Through Intelligent Clustering Algorithm Based on Load Forecasting in Smart Grid

1 Abstract —The development of smart metering technology empowers power reforms, which allows effective implementation of demand response programs to effectively operate the power grid. The systematic analysis of smart meter data plays a vital role for both consumers and utilities to reduce their costs and improve the efficiency of power management. In this paper, a machine learning algorithm is proposed to recommend the appropriate Demand Response (DR) program for the consumer in a real-time environment, tailored with dynamic pricing. The systematic recommendation can be made by integrating time series forecasting, consumer clustering, and DR analysis. The smart meter data of the 28 consumers for 108 weeks are recorded and applied to the ARIMA time series forecast algorithm. The smart meter data and ARIMA time series forecast data are combined and fed to the Agglomerative Hierarchical clustering algorithm to cluster consumers based on their usage and demand pattern. Clusters are analysed to identify a suitable DR program for the consumer. The results show that the proposed machine learning method effectively clusters consumers and implements the DR program in the smart grid environment.


I. INTRODUCTION
The smart grid is an emerging infrastructure of the power industry that incorporates advanced digital technologies to overcome the issues of the conventional power grid. To operate the power grid in a reliable way, an impeccable balance between supply and demand is predominantly essential. In 1980s, the Electric Power Research Institute (EPRI) launched Demand-Side Management (DSM), which includes energy saving, energy efficiency, and load management. Low operating reserves are classified as shortterm problems, whereas environmental problems that arise from the burning of coal to produce electricity can be classified as long-term problems [1]. Energy efficiency schemes are potential inhibitors for long-term problems, whereas DR programs can tackle short-term problems. According to Federal Energy Regulatory Commission, Demand Response (DR) is defined as: "Changes in electric usage by end-use cons from their normal consumption Manuscript received 26 January, 2022; accepted 1 March, 2022. patterns in response to changes in the price of electricity over time, or to incentive payments designed to induce lower electricity use at times of high wholesale market prices or when system reliability is jeopardized" [2]. The main aim of the DR scheme is to motivate consumers through incentives offered by the utility companies and increase the awareness of consumers about the welfare of changing their usage of electricity. The various factors involved in motivating consumers to participate in the DR scheme are blackout prevention, responsibility sensing, or cost efficiency [2]. Demand response programs are broadly categorized on two dimensions, such as shedding the load and motivating consumers to participate in DR. Participants in DR programs can be put into action for reliability conditions or for economic purposes. Reliability conditions offer payment to consumers to decrease their electricity requirements at the time of system contingencies. Economic programs provide incentives to consumers for reducing their load during non-emergency periods when the cost of utility service goes beyond a certain definite limit. The classification of DR programs [2], as shown in Fig. 1, includes direct load, curtailable load, real-time pricing, dayahead pricing, and time-of-use pricing.

Design of a Dynamic Demand Response Model Through Intelligent Clustering Algorithm Based on Load Forecasting in Smart Grid
Based on the DR programs mentioned above, the load used by the consumer changes based on incentive offers, tariff, or contingency situation that would put the grid operation at risk [3]. However, the expansion of DR to cover the residential sector apart from industrial and commercial sites poses to various challenges [4].
The offer-mentioned challenges encompass establishment of an optimal DR system that exists over the present issues of the prevailing DR schemes with a strategy that is win-win for the consumers and the utility, and scheduling of load for balancing the consumption of energy with the supply that is prevalent. The cost differences provided for electricity supply at varied time periods in a day encourage consumers to move their load to periods with low prices. As a result, it helps reduce demand during peak times, as well as energy costs, thereby decreasing the utility bill of consumers. However, it can be seen that some consumers are not willing to relinquish their comfort for the sake of economic prices. Another important factor is that if many consumers shift their usage in the lower price period, it also leads to peak demand at a particular period, which defeats the purpose of the demand response program. So, clarity in understanding the consumption behaviour of consumers could help consumers in their load management. On the other hand, on the supply side, it would support the utility providers in the efficient management of the load balance. Analysing the consumer usage pattern and applying the demand response program is a challenging task in implementing demand response in the smart grid.

II. LITERATURE REVIEW
Few researchers have proposed a forecast model for utilities to balance demand and supply. But to ensure the success of DR, utilities target consumers who voluntarily participate or encourage consumers to reduce their consumption by curtailment. In return, participating consumers are provided incentives in the form of reduced tariff. Many mathematical models, namely dynamic programming, game theory, convex optimization, stochastic programming, particle swarm optimization, and Markov decision process, have been proposed by many authors to successfully implement the DR program in a smart grid environment [5]. Mohsenian-Rad, Wong, Jatskevich, Schober, and Leon-Garcia [6] have proposed a gametheoretic energy consumption scheduling for residential consumers to minimize electricity bills. However, the interaction strategies between the utility and consumers are static games. Jin, Feng, Marnay, and Spanos [7] explored a dynamic pricing strategy with DR for a microgrid retailer in an integrated energy system. They formulated retail rates and microgrid dispatch as a mixed integer quadratic programming problem to increase retailer profits. However, the policies concerning dynamic pricing organized by the retailer are programmed by the static model, which does not have a logical process to determine. So, most mathematical models are deterministic and too complex, which will not encourage consumers to participate in the DR program. Since these models do not encompass user consumption behaviour to maximize the pay-off for the utilities and consumers, machine learning models effectively understand user consumption behaviour and utility generation capacity. Lu, Hong, and Zhang [8] have proposed a reinforcement learning approach using a dynamic pricing algorithm between the service provider and the consumer. This methodology considers only the existing data for reinforcement learning. A detailed study has been conducted without experimental analysis to investigate household electricity segmentation [9]. Zhou, Balandat, and Tomlin [10] have proposed a framework to forecast short-term load at individual user levels and relate non-experimental estimates of DR efficacy to user consumption variability. Since they have done non-experimental work, it is not consistent to follow the demand response program. Mahmoudi, Afsharchi, and Khodayifar [11] have proposed a comprehensive real-time price-based model for the management of residential appliances based on existing power consumption. But it cannot be applied to future demand. Chen, Yang, and Xu [12] have proposed a dynamic pricing model for fluctuation in the day-ahead market. Bintoudi et al. [13] have proposed an incentive-based demand response frame work for residential applications. Xu, Wang, Guo, Lu, Li, and Han [14] have proposed a hybrid demand response model for real-time incentives and real-time pricing. Babaei, Abazari, Soleymani, Ghafouri, Muyeen, and Beheshti [15] have proposed a data mining based optimal demand response program for the smart home using density-based spatial clustering of applications with noise (DBSCAN) method. Dadkhah, Bayati, Shafie-khah, Vandevelde, and Catalão [16] have proposed an optimal price-based and emergency demand response programs considering consumer preferences and implemented in an IEEE test system.
The existing models have only considered consumption behaviour to cluster consumers without forecasting future demand, which is more crucial to suggest a suitable DR program. Hence, in this paper, machine learning methods are used to analyse the consumption pattern of the consumers, forecast their demand, cluster the consumers and motivate them to participate in suitable DR programs. The implementation of the work is formulated in three phases as follows: 1. The first phase is to forecast the electricity demand of residential users using the ARIMA time series forecast model; 2. The second phase is to cluster the consumers using an agglomerative hierarchical clustering algorithm based on the grouping of smart meter data and ARIMA forecast data; 3. In the third phase, a DR analysis has been done based on clustering, and an appropriate demand response program is recommended to consumers.

III. PROPOSED SYSTEM MODEL
Smart grid technologies in power systems provide better control, balance of energy supply and demand, increased visibility in energy generation, and consumption patterns. On the demand side, the integration of advanced digital meters provides periodic readings that allow one to have an insight into the usage pattern of the consumers. Finding the usage pattern of consumers helps to make the clustering for identifying the appropriate demand response program for each cluster. The block diagram shown in Fig. 2 represents the dynamic DR program model.
The data recorded on the smart meter is a single variable against the time of user power consumption. To forecast future demand, a time series forecast model is developed based on the usage pattern. Time series modelling, as one of its chief objectives, helps in collecting and studying previous observations of power consumption of the consumers for the development of an appropriate model that elaborates the inherent structure of the consumption pattern In the first phase of the proposed model, periodic recordings of smart meter data of 28 houses are considered for the ARIMA time series forecast model. The dataset is sliced into 70 % and 30 % sets, namely the training and testing sets. The training set is utilized to prepare the ARIMA forecast model, which is validated against the test set. Based on the accuracy of the validation, the forecast model is used to predict the future demand of the consumer for a certain period. The smart meter consumer data and the ARIMA forecast data are merged and fed into the clustering algorithm in the second phase. The bottom-up approach of clustering would successively merge until all consumers were brought under the cluster. As the ARIMA time series forecast pattern is so consistent [17], the resultant forecast data can be used to cluster the consumers using the hierarchical agglomerative clustering algorithm. Each cluster has its characteristics for consumption patterns and forecast demand. Based on the characteristics of the cluster, a demand response analysis is carried out and a suitable DR program is dynamically suggested to the consumer.

IV. TIME SERIES FORECAST USING ARIMA MODEL
The power consumption pattern, as shown in Fig. 3, was observed from the dataset consisting of 28 residential consumers for two years. The analysis of mean, variance, and autocorrelation of the power conx.
The selection of a time series predictive model is a stochastic model, which is extremely essential as it reveals the fundamental structure of the user's power consumption, and this fitted model, in turn, is used to satisfy the prospective demand of a user. In this paper, the Auto-Regressive (AR) and Moving Average (MA) models are combined to forecast the power consumption of the user. The differencing of raw observations of the power consumption is done to make the time series stationary. The Augmented Dickey-Fuller (ADF) test is used to test the stationarity of the data. From the ADF testing, the data fall under the weak stationarity in which Type II has a constant mean, variance, and autocovariance, which does not change with time. The third-order time series shown in Table I fluctuates around the deterministic trend. The decomposition of the time series data represented in Fig. 4 for House-1 has been done. Similarly, the analysis is done for all the houses to check the trend and seasonality. The ARIMA method has been extensively used to forecast electricity prices compared to other time series forecasting models. Mathematically, the AR(p) model can be stated as where y t and ɛ t are the actual value and the random error, respectively, in the power consumption time period, φ i (i = 1, 2, …, p) are the model parameters, and c is the constant. The integer constant p is called the "order of the model".
The graphical representation of Fig. 5 shows the AR model for House-1 and the same has been applied for all the houses. The MA(q) model uses past errors as explanatory variables. The MA(q) model is written as As represented in (2), μ is the mean of the series of power consumption, ( 1, 2, 3, ..., ) j jq   are the parameters of the model, and q is the order of the model. The process is given by an average of the noise, but not an average from time zero to the present power consumption time t. Instead, an average moving with t is taken, using only the last q + 1 times. Autoregressive (AR) and moving average (MA) models can be efficiently combined as ARMA models 11 .
In the expression above, the order of the model p, q refers to the autoregressive and moving averages, respectively. ARMA models are operated using the lag operator notation. The lag operator is described as 1 .
The important characteristic feature of the AR(p) process is invertibility, i.e., an AR(p) process can frequently be written in terms of the MA(  ) process. However, for an MA(q) process to be invertible, all the roots of the equation (  outside the unit circle, then the ARMA (p, q) process is invertible and can be mentioned as a pure AR process. Nevertheless, ARMA (p, q) can be applied only to strictly stationary time series data. However, in the predictive model of electric power consumption, strict stationary may not always be possible. The data collected and processed for this model are also not strictly stationary. So, based on forecasting of electricity power consumption application, Integration (I) is added, which is referred to the reverse process of differencing to produce the forecast, which is the degree of differencing (d). In the ARIMA model, a nonstationary time series is made stationary through the application of finite differencing of the consumer data.
Using the lag polynomials, the ARIMA (p, d, q) is expressed as follows.
The time series ARIMA model is used to forecast the power consumption for the next 12 weeks from the existing power consumption of 108 weeks of smart meter data. The existing data are combined with 12 week forecast data, which are used for the second phase of the clustering algorithm. The forecast data of 5 houses for 12 weeks is shown in Fig. 6 along with consumption data of 108 weeks. The same procedure is followed for the remaining 23 houses to forecast the demand  The dataset, prepared based on consumption (108 weeks) and future demand (12 weeks), is fed into the hierarchical clustering algorithm. Hierarchical clustering produces the nested clustering and reflects the similarity pattern between consumers. In the Hierarchical Clustering method, the agglomerative clustering approach is followed to cluster the consumer based on their consumption pattern, and it would form the cluster based on the bottom-up approach.

V. AGGLOMERATIVE HIERARCHICAL CLUSTERING OF CONSUMERS
DR primarily leads to economic innovation and consumers play an active role in the operation of the electric grid by decreasing or shifting their use of electricity in the peak period. Consumers have to adopt an appropriate DR program that can help electricity providers conserve costs by reducing peak demand and the ability to accept the construction of new power transmission systems and power plants. The recommendation of a customized DR program to the consumer is a challenging task. The recommendation of the DR program is based on its consumption pattern and future prediction. To identify a suitable DR program, it is necessary to cluster the consumer according to their consumption behaviour. The agglomerative hierarchical clustering algorithm [18] is relevant and will give a holistic view of consumers based on their respective clusters.
Agglomerative clustering is a bottom-up approach that starts with similar consumption pattern clusters and moves ahead by gradually amalgamating the clusters that are mostly similar untill a stopping criterion is attained. In certain cases, the process is completed merely when all clusters are combined into a single cluster. In agglomerative clustering, the hierarchical strategy is defined by measuring similarity or dissimilarity, related to the distance and the procedure to generalize the measure to be employed to the pair of clusters rather than the pair of consumers. The linkage metrics are elementary to determine the connectivity between the clusters. The hierarchical agglomerative clustering algorithm to cluster consumers based on their power consumption is shown in Algorithm 1.
Average linkage metrics are followed, which is midway between nearest and farthest neighbour. The distance between two clusters CC i and CC j explained in (6) is measured as the arithmetic average of the distances between all possible pairs of consumer data objects that belong to various groups 11 ( , ) , .
The dendrogram result from the agglomerative does not indicate a specific number of clusters. It is evaluated based on the formation of cluster with respect to the height at which the major transformation in difference occurs, subsequently cutting the dendrogram at the height that is aforementioned and removing the clusters that are formed. The dendrogram of Fig. 7 shows the clusters which are grouped based on the demand criteria and Table II   Among the 28 houses, Cluster-1 formed as C1 with seven houses, Cluster-2 with 11 houses, Cluster-3 with eight houses, and Cluster-4 with two houses.

VI. ANALYSIS OF DR PROGRAMS BASED ON THE DYNAMIC CLUSTERING ALGORITHM
DR program (DRP) analysis has been performed to identify the appropriate DR program for each cluster. On the basis of the existing load profile and future demand, the selection of DRP will vary between the clusters. To analyse demand response programs (DRPs), the responsive load economic model has been devised. In view of the spot price of electricity, consumers can adjust their demand by increasing or decreasing it. Researchers proposed economic models for TOU, CPP, RTP, I/C, and DLC [19].
Responsive load economic model. The load economic model representing the behaviour of the consumer with respect to the change in electricity price, the incentives and penalties levied on the consumer is used in this model analysis.

Price elasticity of electrical demand
The need for most commodities diminishes as the price surges. Price elasticity is described as the sensitivity of load demand to fluctuations in price [20] 0 0 , p d E dp where E is the price elasticity of the demand and p 0 is the initial spot electricity price and d 0 is the initial demand of the consumer. Based on (7), the price elasticity of the t th period with respect to the i th period is defined as If the prices of electricity vary for different periods, then the consumption of electricity by the consumer responds to one of the following.
 The loads such as illuminating load cannot be shifted from one-time period to another, and they could be only in ON or OFF state. Such loads are sensitive to a single period only and their elasticity is defined as "selfelasticity". The common value of self-elasticity is always negative, as shown by the following equation.
 Some loads, such as process loads, are flexible and can be shifted from peak periods to off-peak periods or low periods. This behaviour of loads that have sensitivity to multi-periods is called "multi-period sensitivity" and they are measured by "cross elasticity", which constantly has a positive value as shown below ( ),

Modelling of elastic loads for a single period
The implementation of DRPs motivates consumers to change their initial load demand from d 0 (t) to a new load demand d(t) based on the incentive and penalty payments stated in the contract as Let the incentive paid to the consumer in the t th hour for each kWh load reduction be defined as A(t). Then the total incentive for consumers to participate in DLC, I/C, and CAP programs can be calculated as follows If registered consumers in the mentioned DRPs do not fulfill their commitment according to the contract, they will be penalized. Let the contract level for t th hour be IC(t) and pen(t) be the penalty for the same period, then the total penalty ( ( )) PEN d t  is calculated as follows If B(d(t)) is the revenue of the consumer at the t th hour for the use of d(t) kWh of electric energy, then the benefit of the consumer S for the the t th hour can be calculated ( ( )) ( ) ( ) ( ( )) ( ( )).

S B d t d t p t P d t PEN d t
To maximize the benefit of consumers, (8) has to be differentiated with respect to d(t) and equated to zero by using (11) and (12) in (15) ( ( )) ( ) ( ) ( ). ()

B d t p t A t pen t dt
The consumer benefit function is calculated as The consumer's demand considering incentive and penalty is obtained by differentiating (17) and equating to (16)

t p t A t pen t d t d t E t t pt
In the aforementioned equation, d(t) = d 0 (t) if the same electricity price is presumed before and after the implementation of DRPs.

Modelling of elastic loads for multi-period
In multi-period modelling, according to the definition of (8), the cross elasticity is assumed to be constant [21], that is, , 1, 2, ..., 24, . () t const for t i t i pi Implying the linear relationship between prices and demands, the model can be defined as The multi-period model considering the incentive and penalty can be stated as Hence, (21) can be used to calculate the new load demand of the consumer for the multi-period with DRPs.

Load economic model
The responsive load economic model explains the impact of consumer participation in DRPs and their effect on the load profile. It is formed by combining (18) and (21) with the participation coefficient (η) of the consumers as follows 24 00 0 1 00

t p t A t pen t p i p i A i pen i d t d t E t t E t i p t p t
Implementing DRPs, (22) shows how much the consumption of the consumers should be to achieve maximum gain.

VII. RESULTS AND DISCUSSION
Totally 28 houses have been considered to cluster consumers based on their demand. The load data for each consumer is forecasted for 12 weeks using the existing load data of 108 weeks. The forecast data are fed into the clustering algorithm, and four clusters were identified, as shown in Table II. The price and incentive-based DR programs were analysed for each cluster. Each consumer is assigned to reduce up to 10 % of their load and the elasticity of all the demand are assumed to be equal. In the analysis, load demand is classified into three periods, i.e., valley period (01:00 to 04:00 hrs and 23:00 to 24:00 hrs), off-peak period (05:00 to 08:00 hrs, 14:00 to 19:00 hrs and 22:00 hr) and peak period (08:00 to 14:00 hrs and 19:00 to 21:00 hrs) for TOU program. The spot price for peak, off-peak and valley periods are Rs.2.5/kW, Rs.1.5/kW and Rs.1.3/kW. In the DLC program, to motivate the consumers, an incentive of Rs.1/kW is given for the peak load reduction. Interruptible / Curtailable is a mandatory program where an incentive of Rs.1/kW and a penalty of Rs1.5/kW are included. In the CPP program, 13 th and 19 th hr are considered critical peak hours and charged at a rate of Rs.3.0/kW. RTP changes continuously for different time periods of the day, reflecting the electricity supply cost.
Based on the economic analysis of the DR programs as shown in Tables III-VI and Fig. 8 the consumption cost is much lower for the TOU program in all clusters. But considering the load reduction and economic analysis as shown in Tables III-VI and Fig. 9, different DR programs are recommended for each cluster.

A. Cluster-1
The average demand of the first cluster is 2059 W. Consumers having a load demand in the range of 1151 W to 3746 W come under Cluster-1. From the results of Table III, it is observed that the TOU program is most suitable for this cluster as the tariff is less. But, based on economic analysis and percentage load reduction, the I/C program is recommended for Cluster-1, where consumers and utilities benefit. DLC, CPP, and RTP can be of the following order of preference. Since the consumers in this cluster have very low consumption, the selection of DRPs can be of any choice, as this does not make much difference in the total consumption cost.
I/C-I is the case where η is 10 %, while in I/C-II η is 9 %.

B. Cluster-2
In this cluster, the average demand for consumers is 5505 W. The load demand of Cluster-2 varies from 2722 W to 9855 W. Considering the benefits of the consumers and utilities, the results from Table IV reveals that the TOU is the most recommended DRP for the Cluster-2, then DLC, I/C, CPP, and RTP, respectively. The total consumption cost is less for TOU compared to other DRPs.

C. Cluster-3
From the results of the DRP analysis, the DLC program is the most suitable program for Cluster-3. The load reduction of 3.5 % is achieved and the total cost of Rs. 254.87 as shown in Table V is optimal compared to other programs. Therefore, consumers and utilities were benefitted through the DLC program. The next order of recommended programs is TOU, CPP, RTP, and I/C program.

D. Cluster-4
In this cluster, the consumer demand ranges from 7263 W to 21349 W. As shown in Table VI, the consumption varies from low demand to a very high range compared to the other clusters. From the analysis, RTP is considered to be the most suitable program for the utilities and consumers of Cluster-4. Subsequently recommended programs are then TOU, CPP, DLC, and I/C. So, based on the economic analysis and percentage of load reduction as shown in Fig. 8 and Fig. 9, each cluster has a different order of priority on DRPs where the suggested DRP would benefit the consumer and utility.

VIII. CONCLUSIONS AND FUTURE WORK
In this paper, a dynamic demand response model has been developed through a three-phase approach as forecasting, clustering, and economic analysis of DR. Twenty-eight residential users load data for 108 weeks were considered for forecasting the demand for 12 weeks using the ARIMA model. Based on the forecasting results, an agglomerative hierarchical clustering algorithm is used to cluster the consumer based on the demand. Economic analysis and percentage of load reduction were carried out for pricebased and incentive-based DR programs to suggest the order of preference of DRPs for the consumers. For each cluster, a load reduction of 3.65 %, 2.6 %, 3.5 %, and 3.2 % is achieved through IC-I, TOU, DLC, and RTP, respectively. The proposed method provides an overall load reduction of 12.95 % and the efficiency of the system has been improved to 93.08 %. The preferred DR program of each cluster benefits both the consumer and utilities. The results show that the preference varies between the clusters, which leads to the reduction of consumption cost for the participated consumers in the DRP. Thus, the higher the incentive offered to the consumer, the higher load reductions can be obtained. It is also verified through the economic analysis that the proposed novel method suggests the best DR program for the participating consumers with the average reduction of 38.32 % consumption cost, which also profits the utilities.
The dynamic demand response model can be extended using different clustering techniques and comparison may be done in the future. The same model can be extended for industrial and commercial consumers and an economic analysis can be carried out to recommend the suitable DRPs to benefit both the consumers and utilities.

CONFLICTS OF INTEREST
The authors declare that they have no conflicts of interest.