Demand Flexibility Estimation Based on Habitual Behaviour and Motif Detection

,


Introduction
In the period from 2005 to 2018, the share of renewable energy in Europe has doubled from 9.02% in 2005 to 18.09% in 2018 and the goal of the European Union (EU) is to achieve 20% in its gross final consumption of energy by 2020 [2] and at least 45% and 75% by 2030 2050 respectively [5,26]. These percentages are even higher in some of the Member State countries. This change, of course, has many positive effects in various areas such as the environment [24] or economics [8], but at the same time the integration of RES in the electric power grid drastically increases, the problem of balancing power, which is necessary for leveling fluctuations in demand/supply mismatches. The establishment of technologies of Smart Grid enabled the development of programs such as Demand Response [28] which takes advantage of consumers' flexibility during high demand periods to reduce or shift this demand. The residential and commercial electricity consumption account for a significant part of total demand, for example, according to a study in this field [30] in the U.S these two sectors account for 73% of the national consumption. By properly managing the demand flexibility, it is possible to reduce the supply/demand mismatch [21] in the grid due to volatility and unpredictability renewable energy sources (RES).
In order to fully understand the energy flexibility's untapped potential, it is necessary to provide a clear definition of demand flexibility. There are many definitions in bibliography such as flexibility is the capacity to adapt across time, circumstances, intention and focus [12]. However, the best way to describe demand flexibility in the case of residential demand is as an indicator of how much load can be shifted or reduced within user-specified limits [9]. In other words, how much energy can be saved at a specific time-frame without sacrificing the consumers' comfort. There are many attempts to study and predict demand flexibility in previous and current research, with all methods and technologies proposed can be divided into two major categories depending on how they obtain the needed information about the consumption. The methods for determining the flexibility of the first category require measurements to be taken directly from the devices, while the methods of the second category, the nonintrusive, collect only the total house's consumption [17]. The advantage of the first category approach is the fact that there is accurate knowledge about the consumption of each appliance separately, which allows estimating the flexibility through scheduling of home appliances. There are plenty of studies whose aim is to categorize appliances into flexible and non-flexible and measure the flexibility of each of them [13,9,17]. Using this information it is possible to estimate the demand flexibility with sufficient accuracy. Nevertheless, this approach is not desirable in many cases, since many smart metering devices need to be installed and, at the same, time, this infringes on consumer privacy by monitoring each device 24/7 [17].
Because the installation costs and the privacy of customers are of great importance, disaggregation methods can be used, installing high-frequency meters to read the household's total consumption and then detect the individual signatures and consumption patterns of each device [17]. This approach is-called non-intrusive load monitoring (NILM) [10]. There are several successful attempts of applying this method [22,25]. In order to properly apply NILM techniques, the minimum required sample rate should be about 1.2 -2kHz [10], which is a fairly high rate that in many cases is difficult to achieve. Of course, there are other attempts that exploit lower frequencies, however even these there are examples that convert low frequencies to high ones using Deep Learning [15], but still, the sample rate needed for that remains high. In most cases, sampling is usually done once per minute or even less frequently due to the large amount of data that would have to be transferred and stored. Moreover, training the disaggregation algorithm is a rather difficult task, since in many cases the same devices from different manufacturers may have different signatures, so a large amount of data from different devices is required to achieve decent results. Finally, the Flexibility of each separate house is usually very low and it should be combined with the flexibility of multiple houses in order to perform Demand Response, this is why many researchers try to calculate it directly from the aggregate load of residential buildings [6,27].
The aim of this paper is to estimate residential demand flexibility without knowledge of the specific household appliances available in the home, by monitoring only total consumption, trying to identify patterns or events that can be characterized as flexible, thus avoiding problems which occurs when observing the flexibility of each appliance. As previous studies have shown [3], it is possible to conclude the habits of occupants by observing only their current consumption. Similar efforts have been made in the past in the industrial sector [18], where the consumption patterns are much clearer and the daily load is almost the same, as the same machines run at the same pace every day. In addition, the variety of different devices is much smaller compared to the residential and commercial sector. The document is structured as follows: Section 2 presents the data used for implementing, evaluating and validating the presented work. Section 3 introduces the novel methodology proposed, followed by the evaluation results in Section 4. Finally, Section 5 concludes the manuscript.

Datasets
In order to have more reliable results, many different datasets have been used for this paper. In all of them, the sampling is done once a minute and there are historical data for at least one year. Also, all datasets provide electrical consumption at the aggregate and appliance level. This fact is very useful in order to evaluate the results, since for flexibility evaluation the sum of consumption of appliances which are described as flexible in the bibliography [13,9,17] was used as ground truth. The first dataset contains data of house electric power consumption for almost 4 years [1], the second is the the Almanac of Minutely Power dataset (AMPds2) [19] which provides 2-year consumption data based on home monitoring from over 20 electricity meters, as well as weather conditions for the same period of time. For both datasets, a washing machine, clothes dryer, dishwasher, and lighting were used as flexible appliances for the evaluation. Finally, experiments were performed with real consumption scenarios in a smart home [4].

Method
In this section, the proposed method is introduced. The main idea of this approach is to identify flexibility based on consumption routines of residents and possible patterns of flexible events. The calculation of flexibility is performed in 3 main steps (see also Figure 1 and Algorithm 1). The first (Sec 3.1) is to categorize the days of the year into clusters in order to establish some baselines of consumption, since it is reasonable to expect different consumption on a working day and on the weekend, as well as in summer and winter. The second step (Sec 3.2) is to analyze all days of the past year to find similar motifs and patterns of flexible consumption. And after that the third step (See also Algorithm 3) is to observe if in the course of a day the consumption deviates from the normal levels of the category in which this day belongs, an analysis is made to find a known pattern of flexibility and in case it is identified as such then this consumption is considered flexible. In this way, flexibility can be achieved without compromising customer comfort and habits. For example, if a consumer has a habit of using a specific con-sumption motif (e.g. a washer) in the afternoon, and one day this motif is identified during midday, this will be considered as a flexible event that can be shifted to afternoon.

Routine detection
Clustering is one of the most important steps (Step 1) of the introduced methodology since all subsequent processes are based on it. The first thing that needs to be done in order to optimize the results of clustering is to simplify the original time series of each day's power consumption. By using Fast Fourier Transformation the simplification shown in Figure 2 is achieved. After this transformation, it is easier to group time series into more generalized clusters. The next step is to perform clustering on this simplified time series using Heretical Clustering with Ward variance minimization algorithm [29] for distance calculation. To evaluate the results and determine the appropriate number of clusters, the elbow method was used, which showed a clear presence of 3 to 8 clusters depending on the dataset (Figure 3). The final step after the establishment of the clusters is to determine which deviation level is considered normal. In this paper, after a process of trial and error the upper and lower bounds was defined as the mean of cluster plus minus standard deviation (Equation 1).
where N is the total number of days in a particular cluster and x i is the time series of days of this category. Thus, anything higher or lower than these boundaries is considered abnormal consumption and should be analyzed for flexibility.

Flexibility detection
The aim of this sub-step (Step 2) is to detect motifs and extract hidden patterns in consumption. Once the system has the ability to recognize specific patterns, these patterns can then be correlated with some known events and decide if it is flexible or not. However, the biggest problem is that most known methods for pattern recognition are supervised methods, but because in many cases there is no available information about appliances and their flexibility, these algorithms are difficult to be applied. For this reason, two pattern detection methods were used, one supervised and the other unsupervised. Each of them has advantages and disadvantages, for example, supervised has better accuracy on known data, but low generalization in unknown data, when unsupervised, has lower accuracy, but works better with unknown data. We call the supervised one flexibility prediction and the unsupervised one we call motif detection.

Motif Detection
The method of sub-step (Step 2.1) takes as input the entire consumption history divided into one-day time series in minutes i.e. 1440 points per time series. The first step is to separate each time series into subsequences. Most existing motif detection algorithms have predefined and fixed length of subsequences [23,14,16] and use algorithms such as sliding window for the segmentation. A fixed window length, however, greatly limits the correct pattern detection process, as different patterns may have different lengths, and even the same pattern may appear with different lengths or intensities. For this reason, it is applied a segmentation algorithm capable of detecting subsequences of different length. Moving average is used to create a baseline and accepted levels of noise for each time series. Whenever the consumption is higher than that, for some time, this part is stored as a subsequence. (Figure 4). The next steps to be taken are, first, to normalize these subsequences so that they can be represented at the same scale regardless of their length and intensity, and second, to perform dimension reduction to store more generalized patterns and to speed up the process of detection. For these steps the Piecewise Aggregate Approximation (PAA) [16] representation and the Symbolic Aggregate approXimation (SAX) [14] were used. The PAX helps to represent subsequences in a scaled and reduced way, and SAX mapping these representations to alphabetical symbols, so at the end, each subsequent has its signature with which it can be compared to others. The next sub-step (Step 2.2) is to create buckets of random projected signatures. First of all, random projection is performed on SAX representations in order to group signatures with small differentiations, which might occur due to accidental ups and downs. A bucket of each random projection contains all the signatures that produce this projection, which in essence represents a potential pattern. The buckets that contain small amounts of signatures are discarded as they are not repeatable enough to be considered as motifs. For the remaining buckets, a P-profile matrix is calculated. P-profile is a matrix of the probability for each symbol to appear in each position of the signature. Based on this matrix it is possible to calculate the probability that any signature belongs to this set. Table 1 shows an example of p-profile for projection ab bc d . Table 1. P-profile matrix for ab bc d . Now, if, for example, there are two segments that have the signatures ababccdb and abbbcadd respectively, and it is needed to examine if either of them belongs in the bucket ab bc d , so the probability of each is calculated. P rob(ababccdb P ) = 1.0 · 1.0 · 0.25 · 1.0 · 1.0 · 0.4 · 1.0 · 0.24 = 0.024 (2) P rob(abbbcadd P ) = 1.0 · 1.0 · 0.25 · 1.0 · 1.0 · 0.6 · 1.0 · 0.7 = 0.105 As it is seen the first signature has probability 2.4% while the second one 10.05% So from these two segments, the second one fits better in the specific bucket, thus it is possible to say that it follows the specific pattern, with some variations.
So when it is needed to determine if a new subsequence is a pattern, all that needs to be done is to create a SAX signature and then compute the probability for each bucket to belong to it. If all probabilities are small (smaller than a predefined threshold, for example 10 or 20, depending on the amount of data available), then the subsequence is not a pattern, otherwise, it is considered as a pattern of the bucket with the highest probability.

Algorithm 2: Motif Detection based on Buckets
1. Create subsequences of day's time series 2. Normalize and reduce dimensionality of subsequences using PAA 3. SAX representation of subsequences 4. Apply random projection of SAX representations 5. Group SAX representations to buckets based on random projection 6. Remove small buckets 7. Create P-profiles for each bucket Flexibility Prediction For the supervised machine learning method for flexibility estimation, a Recurrent Neural Network (RNN) was used, more specifically an LSTM (Long Short-Term Memory) which has shown great results in time series analysis and prediction. This choice was made as this type of neural networks have been proved to be very effective in sequence-to-sequence problems [20,11,7], and the goal in this approach is to give to the model a subsequence of total consumption as input, and take a subsequence of potential flexible consumption as a result for the same period of time. This approach can have remarkably accurate results but a low level of generalization, which means that in a different house it will need to be retrained. However, to train such a model, it is necessary to have some prior knowledge of real flexibility, which in many cases may not be available (or well defined). In our experiments, the sum consumption of devices that are considered flexible according to bibliography is used, as actual flexibility. This limitation can be overcome by combining it with the previously presented motif detection approach. If the first method is applied beforehand, then knowledge of real flexibility is gathered, by collecting each time the proposed flexibility is accepted or rejected by the consumer, and then, based on the accepted flexibility, train the LSTM.
Once the neural network returns a time series of potential flexibility, the next step is to check, at a certain point in time, if there is indeed flexibility, which affects the overall consumption. To do so, both total and potential flexible consumption are converted into PAA/SAX representation and compare their signatures. If they have a sufficient degree of similarity then this point in time is considered flexible. Finally, if a whole day need to be analyzed for flexibility, the sliding window algorithm are applied and do this check for each subsequence. {Sliding Window } 3.
if subsequence is outlier then { 4.
{Motif is detected based on bucket's P-profile probability} 11.
if segment is outlier then { 12.

Results
In this section, the results of the application of this method on different datasets and different ways of its application is presented. Specifically, the difference between the two motif detection methods that were observed in the experiments, the results of evaluation metrics for each dataset, the clusters analysis, and the estimation per hour and case study at the smart house are presented. In order to be able to quantify the results and compare them, some metrics (MSE, RMSE, MAE) were calculated using the sum of the consumption of flexible devices as a target flexibility. When analyzing metrics, you need to keep in mind that they show half the truth, since they cannot completely approach zero. Because when a pattern of flexible consumption is identified, this does not directly mean that it will be characterized as flexibility because if it did not exceed the limits of the day class, it is an acceptable consumption that can not be used, for example, in a possible DR request. Thus, in order to have a more complete and comprehensive view of the results, it is also necessary to observe the results in the form of a diagram. The metrics are presented in Table 2 and visual results are shown in Figures 5. In data from AMPds2 dataset the flexibility prediction was applied in two different ways, and the results of both ways are presented.The first, as described previously, takes a segment of total consumption as input, and returns a segment of potential flexible consumption for the same period of time. The second one uses a forecast of total consumption as well, it takes the last four hours of total consumption and the next four hours of forecasted total consumption as input and returns potential flexible consumption for the next hour.
More details on how a time series is analysed to detect flexibility can be seen in Figure 5. As you can see, if only a supervised method is used to identify flexibility, it can find exactly the point in time at which there is flexibility. However, if both methods are used, it was noticed that there are other points of abnormal consumption that could be considered flexible, therefore, there is a greater likelihood of spotting flexible points than those the model has been trained to detect. Another worth mentioning point is around 900th minute of the day, where there is flexible consumption which was detected. Nevertheless, it was not considered as flexibility because it did not exceed the upper level of consumption of the specific day.
In a DR request, it is necessary to know the available flexibility in realtime in order to make the right decision at the right moment. For this reason, the application of proposed method in near real-time conditions was tested, determining flexibility throughout the day. More specifically, the determination is performed every hour. For these tests, a version that is also forecast based was used, so it will be possible to have an estimation of future flexibility. It is expected that the results of these tests will differ from the classical application of the method in only two cases. The first case of differentiation is during the day, the cluster of this day can be incorrectly defined, as there is no information about the whole day, and as a result, segments are considered outliers while in fact, they are not. The second reason, which can lead to different results, is that different Random Projections can be performed throughout the day, which can change which segments are considered part of a particular bucket (motif) and which are not. Although in practice, no big differences are expected.
As it is shown in Figure 6 the hypotheses that had been made were verified. In this figure is is seen the evolution during the day. In each instance, it is shown the consumption until the time of estimation and the forecast of consumption from the moment of estimation until the end of the day. Moreover, the figure shows the cluster of the day, and the cluster's upper bound, the prediction given by the neural network and the final flexibility. There are differences in estimates due to the different categorization, however, the differences are not significant. Moreover, the prediction given by the neural network can be a satisfactory estimation of the next hour. So, it could be said that the proposed method can be applied just as well in real-time.
By analyzing the clusters it is also possible to draw conclusions about the flexibility of the next day. If a simple demand forecast for the next day is available, it won't be detailed enough to be able to detect flexibility, but it will be enough to estimate the cluster of this day. It is possible to draw conclusions about flexibility, as the experiments showed there is a variation in flexibility depending on the cluster (Figure 7). In the available house where additional tests were performed, there is no information about flexible consumption, which means that it is not possible to calculate metrics such as MSE or MAE, as there are no actual values to compare with the results. In this house there are three sub-meters in three sub-

Conclusion
The rapid growth of RES and the increased energy demand have led to new technologies and practices in the field of energy management. An example of such practices, the application of residential DR programs, whose goal is to optimize the balance between energy demand and supply, depends directly on the assessment of residential demand flexibility. In this paper, a new method of residential flexibility estimation is presented, based on analysis of habitual behaviour and identification of repeatable consumption patterns. This method consists of a combination of technologies such as clustering, motif detection and neural networks. It was shown that this method has the ability to identify flexibility with satisfactory accuracy both in a new environment and in an already familiar environment, improving its results as it learns and adapts to new conditions. Moreover, the method has the ability not only to work with historical data but also to combine forecast data with historical. In this way, one of its most important features is achieved, i.e. the ability to adapt to each case and improve the results over time.
For the validation of this method different datasets of residential consumption were used, including also real home experiments. The tests were performed both on a daily basis and per hour, thus approaching the real-time scenario. Despite the fact that the experimental results have been encouraging, it is necessary to conduct additional tests. Ideally, tests should be conducted using the final cost as a benchmark, that can be saved by applying this flexibility assessment method. Such a method of unsupervised flexibility identification is very hard to be evaluated properly, as there is no specific expected result with which the resulted estimation can be compared. So in such cases, the best way to evaluate is to apply it in real conditions and to measure the final goal.
Finally, there is significant room for improvements in this methodology. Example of such enhancements is the deeper analysis of identified patterns so that there is a better understanding of what causes the specific patterns. Additionally, better clustering can be achieved by using additional information such as weather data, daylight hours for each day, the day of the week, the day of the month, etc.