Adaptive Demand Response Management System using Polymorphic Bayesian Inference Supported Multilayer Analytics

The most significant limitation of stand-alone microgrid systems is the challenge of meeting unexpected additional demands. If demand exceeds the capacity of a standalone system, the system may be unable to satisfy demand. This issue is alleviated in grid-connected technology since the utility system will provide more power if it is demanded. As a result, load scheduling is an integral element of the demand response of a standalone system. There are two components to this problem. If the capacity of a battery-supported power system is restricted, for the period of time that the source is available, it will not be able to meet the entire demand. Appropriately the demand is dispersed across a period of time until the next charge becomes available. Some demands may be disregarded in order to accomplish peak load trimming or if the system is incapable of meeting demand without compromising other important technical and consumer objectives. This is a challenging assignment. This article aims to develop an Adaptive Demand Response Management System (ADRMS) capable of load scheduling and load shedding using an interwoven multidimensional Bayesian inference supported by multiple mathematical models. A two-stage hardware architecture is being developed, with the first hardware measuring demand and source capacity before sending the data to the second hardware via LPWAN for mathematical analysis. In the first phase, two approaches are used to forecast demand: Gaussian Naive Bayes Model (GNBM) and Bayesian Structural Time Series analysis. GNBM is rapid but fails to properly forecast the output when there is zero frequency error whereas BSTS can offer more precise results than GNBM but is slower. Hence two approaches are employed in tandem. The next stage is to assign demand source integration. This is accomplished using Bayesian Reinforcement Learning (BRL), which is based on a number of incentives, including anomaly, cost factors, usefulness, reliability, and size. All Bayesian models are subjected to much of the common Bayes rule, resulting in the formulation of a blended polymorphism model that reduces computing time and memory allocation, and improves processing reliability. The Isolation Forest (IF) method is used to identify and avoid vulnerable loads by determining demand anomalies. The last step employs a Dynamic Preemptive Priority Round Robin (DPPRR) algorithm for preemptive priority based load scheduling based on forecasted data to allocate the next loads to be added. Keywords—Adaptive control; Bayesian; demand response; energy management system; load scheduling


A. Background
Increased Solar Photovoltaic Generation System (SPVGS) installations have enabled many residential, commercial, and industrial facilities to operate as stand-alone microgrids [1] [2]. In such systems, SPVGS will deliver energy to demand throughout the day, with a portion of it being stored in battery systems [3]. When solar energy is in short supply, especially at night, the stored energy from the Battery Energy Storage System (BESS) is used to satisfy demand [4]. Because of limited power capacity, demand response management is a key challenge in standalone solar-powered battery systems [5]. If demand rises in a grid-connected system, additional power can be pulled from the utility grid [6]. However, the capacity of the standalone system is constrained [7]. If the load exceeds supply limit, the system will have to drop certain loads in order to maintain the demand-supply balance [8]. The watt hour capacity of a BESS limits the amount of power it can supply [9]. Consequently, if several loads are connected and the total watt hour demand exceeds the watt hour capacity of the entire storage system, some of the loads must be bypassed. The BESS is charged from the additional supply from the SPVGS [10]. As a result, if the load is close enough to the SPVGS supply, the BESS will be drained because there will not be enough power to charge it. A portion of the load is evacuated in these circumstances to free up energy to charge the BESS [11]. It is a significant challenge to develop demand response models that satisfy all of the above characteristics while remaining efficient, cost-effective, and consumer-friendly [12]. Thereupon, numerous researches on load scheduling and intelligent demand management for stand-alone systems are now being undertaken.

B. Literature Review
Sharda et.al. investigate the overview, problems, and potential of Demand Management (DM) in standalone systems [13]. They also address real-world problems encountered while implementing DM with load scheduling for home energy management systems. Lu, Xinhui, et. al. investigated supply and demand side optimal load scheduling in a smart grid system, with an emphasis on economic, social, and environmental benefits for all market participants [14]. O'Shaughnessy et. al. looked into the end-user economics of BESS and DM that boost the value of SPVGS by regulating and temporally altering their output [15]. The preceding papers offer an overview of the factors that go into load scheduling for stand-alone systems. The topologies of reconfigurable battery management systems are investigated by Viswanathan et. al., with an emphasis on load interface protocols and load scheduling optimization approaches [16]. Sanjari et. al. developed an optimum control approach for battery-integrated energy systems that uses analytical rather than numerical approximation methods to account for load demand unpredictability [17]. Md Masud et. al. developed a model for a hybrid gas turbine generator, SPVGS, and Battery Energy Storage System (BESS) for isolated microgrids [18]. Jonathan T. Lee et.al. experimented with non-intrusive load control in energy-constrained microgrids under unpredictable load conditions [19]. To address load management concerns, the aforementioned articles use a wide range of methods, and many of the solutions use time-based optimization methodologies. Traditional time series analysis techniques use historical data to forecast model parameters. Because the loads are only coupled for a short period of time, in most circumstances, the load gradients comprise zero values across the curve. Standard time series approaches for load forecasting are contentious due to the difficulty in distinguishing seasonality or stationarity in the zero gradient curve. This problem can be solved using a structural model, in which the parameters are expressed as the composite of individual parameter contributions, or probabilistic prediction procedures. Bruce G. Marcot et. al., provide a great deal of information on recent advances in Bayesian network modeling and integration of Bayesian rule engine for series analysis [20]. Steven L et. al. demonstrate how to integrate a structural time series model for the target series with a regression component that takes realtime search query data inputs into account [21]. The application of a spike-and-slab prior on the regression coefficients results in sparsity, which significantly reduces the size of the regression problem. As a result, in the event of uncertainty, Bayesian modeling will be an appropriate approach for load forecasting.

C. Objectives
The ideal goal of a Demand Response Management System (DRMS) is to ensure that the load receives consistent electricity. However, if the sources' capacity is limited, especially in a freestanding grid, a portion of the load is dropped or rescheduled over time to satisfy the demand via peak load cutting. An intelligent DRMS should be capable of load scheduling and load shedding in order to achieve maximum power efficiency, optimum economic gain, and user satisfaction. In order to perform load scheduling and shedding, the system should be able to distinguish between loads and determine which loads should be maintained or discarded. The DRMS should have the potential to ascertain when and for how long each load should be scheduled and shed. This is a difficult undertaking that might be accomplished utilizing a variety of mathematical methods. Because of the non-uniform zero gradients in the load curve, utilizing time spectrum analysis alone is less successful. As a consequence, a new hybrid mathematical model for analysis that combines the properties of time series analysis, spectrum analysis, and probabilistic regression is to be established.

D. Contributions
The objective of this project is to establish a multi-layer DRMS hardware that uses a two-stage hardware architecture for energy monitoring and decision making. An edge controller transforms a Wi-Fi module into an energy monitoring circuit that monitors demand and source capacity and delivers the data to a Centralized Data Processing Unit (CDPU). CDPU will save this information in a database and analyses it using a blend of mathematical models. To begin with, the Isolation Forest (IF) algorithm will be utilized to evaluate anomalies in load data. This data is used to construct a Bayesian prior. A two-stage time-series analysis is employed in the following step, using Gaussian Naive Bayes Model (GNBM) and Bayesian Structural Time Series (BSTS). One of the weaknesses of Naive-Bayes is frequency error, which causes the probability estimate to be zero if there are null-gradients in load data. BSTS can address this issue and is more accurate than GNBM, but it is also slower. Therefore, GNBM is frequently used for load forecasting, with BSTS employed in tandem if there is a zero frequency error or a significant RMSE. A Bayesian Reinforcement Learning (BRL) algorithm is utilized to identify the optimal load-source assignment combination based on the projected values. In a preemptive priority assessments approach, a Round Robin algorithm supplemented by a Dynamic Programming model is used to select the best sources from all available sources and schedule loads.

E. Organization
The paper is split into three sections. The first part is an introduction that examines the context of the problem, conducts a thorough literature review, and formulates the problem. The described problem is used to establish the goals of the project. The following session will go over the strategies used to solve this problem in detail. The results and discussion section examine the implementation of the project in depth, and are found in the last section. The result and discussion session is split into two parts: the first looks at the data, and the second looks at the implementation approach and consequences.

II. ADAPTIVE DEMAND RESPONSE MANAGEMENT SYSTEM (ADRMS)
As illustrated in Fig. 1, this project develops a two-stage hardware architecture for a multilayer Adaptive Demand Response Management System (ADRMS). A switching relay circuit couples the loads to the battery, allowing any load or source to be added or disengaged independently at any time. The system's operation is structured down into different phases, as follows. Stage II Data storage: The data is initially saved in a PostgreSQL database using the Node-RED development tool as it reaches the CDPU. This approach is useful for analyzing real-time data.
Stage III Data Pre-processing: A large volume of data would be captured because the system will record data every millisecond. Analyzing all of this raw data would result in longer computational costs. For faster processing, the data is resampled from milliseconds to second levels. Then the data is preprocessed which involves a number of steps, including replacing missing data with local standard deviations, normalizing the data, and converting it to categorical variables.
Stage IV Anomaly with Isolation Forest (IF): Anomalies in the load curve indicate a fault or maybe a quantitative inaccuracy. Proper spotting anomalies in the load curve might help decision-making, for identifying faults and taking remedial action during forecasting. Because historical data aids in distinguishing anomaly from normal deviation, anomaly calculation is left out of the Bayesian engine. An unsupervised outlier time series analysis based on IF is used to discover anomalies. IF uses clusters of isolation trees for a given data collection, with data higher than the Euler-Mascheroni constant being deemed anomalies. When load consumption is represented as P L = {P 1 ,.., P n } , where P LF and P RR is the load to right and left element of tree, P i consumption at i th load, t h is the threshold, the isolation tree is built again every time a new value is added using the equation 1 and 2. Isolation forest provides the added benefit of allowing points that cannot be isolated to be classified as normal or abnormal to be easily detected.
Stage V Bayesian inference and Knowledge base: The following step is to create a Bayes interference engine and knowledge base. In the comprehensive mathematical model, three distinct Bayesian oriented mathematical strategies are employed for three different applications: GNBM, BSTS, and BRL. Because the Bayes theorem governs all methods, each model undergoes numerous equivalent joint phases and processes during the operation. A polymorphism model produces a hybrid object engine that works as a centralized interference rather than adding different variables, memory assessments, and processes for each activity. Polymorphic objects are called when a common set of rules is followed, which reduces the computation cost. Independent mathematical procedures are employed in the final stages of computations. The Bayes theorem is represented as Equation 3. P(PL) is the probability of next load data and PH is the prior probability.
Stage VI Gaussian Naive Bayes Model (GNBM): The load is then scheduled relying on available source capacity. As previously stated, scheduling the load based on its temporal behavior is essential for enhanced power quality, longer load longevity, higher economic sustainability, and user satisfaction. In the following phase, load is forecasted using GNBM and Bayesian Structural Time Series Analysis (BSTS). The load is forecasted in the first stage using GNBM. The probability of the load variation is predicted using equation 4.
Stage VII Bayesian Structural Time Series: BSTS is a time series interpreter that uses Bayesian criteria to choose output parameters. BSTS is based on Bayesian model averaging ensemble learning, which uses an average number of models to do stepwise regression forecasting, with the input weighting the posterior probability of each model. If Pt is the time series to be predicted, whereas αt denotes the inherent features of the load curve, Kt is a vector of coefficients for state variables, Ht is the variance with normal distribution error term with a mean of zero ɛt , equation 5 represents time series calculations. =K +ϵ → forϵ ∈ �0,H � (5) Now the value of α is updated with equation 6 where block diagonal transitions matrix T t , the covariance matrix Q t of the rectangle block R t and each component contributes to the block with η t . t+1 =T +R → forη ∈ �0,Q � 302 | P a g e www.ijacsa.thesai.org (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 12, No. 8, 2021 Stage VIII Bayesian Reinforcement Learning (BRL): Once the load is predicted and anomalies are handled, the following step is to allocate loads to different sources depending on the forecast value. The optimum loads for the ideal sources may be found using BRL with maximum exploitation of sources. Thompson of Sampling is a strategy to explore the progressive rewards based on the rule of Bayesian control and maximize them. The cumulative reward (R) of the load (P) is decided based on Gaussian Bayesian reward function (E) for every individual reward function μ for two consecutive stages is shown in equation 7. The system always tries to maximize the reward in a greedy manner. If the source capacity exceeds the loads, a dynamic program is integrated with BRL to locate the best resources.
Stage IX Dynamic Preemptive Priority Round Robin (DPPRR): Following the identification of the most relevant combination using BRL, the next step is to include sources and assign loads to them. This issue is divided into two parts: the first is the source selection using dynamic programming, and the second is the source assignment using preemptive priority scheduling using Round Robin. To conserve energy, sources are only used when absolutely necessary. As a consequence, dynamic programming is utilized to choose the best sources from all available sources. Now depending on the load demand, sources are employed in a certain sequence in a time spectrum allocation using preemptive priority scheduling based Round Robin technique.

III. RESULTS AND ANALYSIS
As shown in Table I, 49 sources were linked as a DC microgrid with a battery capacity of 20 KWH and an SPVGS of 1200 W in order to realize the idea. Table II shows the 27 distinct loads that were investigated with a maximum load capacity of 5.7 KW. In a laboratory setting, the entire technique is implemented as HIL. Due to the typical operational characteristics of the utilities grid, no automated switching is done, thus the decision making are determined using all developed models with the last step in manual switching mode.
The initial stage of execution is the assessment of source capacity and loads. At first, all batteries are charged to their maximum capacity. The next stage is to evaluate how much energy each load consumes. The load consumption is captured every millisecond and resampled to a scale of seconds by estimating the average usage each minute. The load dataset is divided into two sections: a historical segment and an instantaneous component. Instantaneous data is taken as test data, while historical data is used to train the model. When a new measurement appears, the previous instantaneous data becomes historical data. A day's worth of average load consumption data per minute is indicated in the Fig. 2. This data is used for training the model. As a result, at each point on the load curve, the data on the left is utilized for prior training and the data on the right is used for posterior learning.
Once the load statistics and source capacity have been identified, the following stage is to identify any anomalies. The system's anomalies are discovered for each load utilizing IF, and each load is graded based on the anomaly. In the last stage, this information is used as a reward during reinforcement learning as well as in priority-based queuing. Fig. 3 illustrates an anomaly over the whole training data set. Table III depicts an anomaly for a sample subset of data. Any count that is less than zero is deemed an anomaly in the table. It may be identified that even if the rate of change exceeds a particular level, it is not always deemed an anomaly because an anomaly is a function of time-dependent deviations. As such, an anomaly is defined as anything that deviates from the confidence interval, which may fluctuate over time owing to load variations.   Furthermore, a time series analysis of the load has been presented. As previously indicated, in the short term, GNBM is used to forecast load. Two instances of GNBM based load forecasting are shown in Fig. 4 and 5. The first scenario illustrates a more accurate system, whereas the second case depicts a system with a greater RMSE. This is primarily due to the fact that GNBM is frequency dependent. In such circumstances, BSTS will be used.
BSTS is used to forecast the load with more precision, although it takes more computational cost. Fig. 6 demonstrates the load forecasting of the test data using BSTS, which is based on consecutive train-test splits. Now, each load is awarded five reward points based on anomaly, economic criteria, need, timing and magnitude, depending on the forecasted data. Based on these data, BRL is used to estimate the time allocation for each load. Table IV shows a sample of reward data for four different loads, along with the output selection time period in the last column.   The next step is to add sources and allocate loads to them. Dynamic programming is used to select the best sources from a large number of options. Using a Priority-based Round Robin method, sources are now employed in a certain order in a time spectrum allocation depending on load demand. The sole criterion employed to select sources is State of Capacity.

IV. CONCLUSION
This work developed an Adaptive Demand Response Management System (ADRMS) capable of load scheduling and load shedding using an interwoven multidimensional Bayesian inference backed by various mathematical models. The system was designed with a two-stage hardware architecture, with the first stage measuring demand and source capacity before sending the data to the second stage CDPU through LPWAN for mathematical analysis. Gaussian Naive Bayes Model (GNBM) and Bayesian Structural Time Series Analysis were employed to forecast demand. To ensure maximum precision, the two methods were used in conjunction. Bayesian Reinforcement Learning (BRL) was used to integrate demand sources based on a variety of incentives, including anomalies, cost considerations, usefulness, dependability, and size. A blended polymorphism model was developed, which decreased computation time and memory allocation while also improving operational efficiency. The Isolation Forest (IF) approach was used to 304 | P a g e www.ijacsa.thesai.org