#### Abstract

On-grid predictive energy management using machine learning is presented in this paper. A photovoltaic array considered in this study is one of the kinds of a renewable sources of energy, where the battery bank acts as a technology for energy storage, in order to optimise energy exchange with the utility grid using logistic regression. The model of prediction can accurately estimate photovoltaic energy output and load one step ahead using a training technique. The optimization problem is constrained by the maximum amount of CO_{2} produced and the maximum amount of charge stored in a battery bank. The proposed model is tested on dynamic electricity costs. Compared with existing energy systems, the proposed strategy and prediction model can handle more than half of the annual load need.

#### 1. Introduction

Due to the lower installation and operating expenses associated with them, HES (hybrid energy systems) are becoming increasingly popular among residential consumers. The household energy system (HES) is made up of renewable sources of energy including photovoltaic (PV) cells, microturbines, wind turbines, and geothermal. When utilised in combination with the HES, there are a variety of energy storage systems (ESS) available, such as the one seen in Figure 1(a), that can be used to store extra energy.

**(a)**

**(b)**

In the HESS, we are using several types like polycrystalline cells, monocrystalline cells, monocrystalline PERF, and N-Type cells which are described clearly in Figure 1(b) along with its coverage range values. The PV and battery-based high-efficiency solar energy systems (HES) are the most commonly used renewable energy options because of its simpler installation, and it requires initial capital expenditure. As long as the utility grid is connected to the PV-battery HES in grid mode, the surplus energy generated will be able to be traded with the utility grid. Hybrid energy grid systems including PV systems, not only help households decrease their environmental impact, but they also help them save money on their monthly energy bills. It is possible to increase the efficiency of these systems even further by applying energy management strategies.

Model predictive control (MPC) models are a kind of the most frequently utilised in GCHES energy management systems, and they are also one of the most complex. It is typical practice to use MPC for economic optimization in the HES since it combines feedback mechanisms to account for model uncertainty and employs forecasting algorithms to account for future demand and power generation.

The inefficiency of grid-connected HES energy trading, as a result of the inefficiency of HES without the need of EMS and inefficient battery storage in banks, was the impetus for this investigation. Unwanted energy storage can be reduced through more frequent trading of surplus electricity with the utility grid, which will lower the cost of energy. This is an important goal for this research because it will result in less energy being stored than needed.

#### 2. Related Works

The authors in [1] describe a number of characteristics of EMS in MPC and microgrids. In a recent study on microgrid MPC, the topic of economic considerations has been explored in depth. An MPC strategy with various targets, such as that described in [2], can be used to enhance solar grid-connected HES. The study was aimed at managing the multiobjective criterion through linearization of the problem and proving real time traffic into the control unit as its real time input. According to [3], an energy management system has been designed that takes into consideration grid power purchases, electricity bills, and the quality of the power. According to the findings of this study, it is possible to reduce electricity expenditures by 2–6.5%. [4] describes the implementation of a new multiobjective EMS system for a microgrid that makes use of the grasshopper optimization method. This method reduced fuel consumption and CO_{2} emissions by 92.4% and 92.3%, respectively, when compared to baseline levels.

Energy management of high-efficiency solar PV, wind turbines, diesel generators, microturbines, and fuel cell systems is presented in [5] in order to achieve optimal PV, diesel generator, wind turbine, fuel cell, and microturbine capacities that consider the major objective fuel costs, energy costs, charging cost, and discharging cost and greenhouse gas penalties. When this technique was used instead of a normal one, the CO_{2} emissions from a single HES were reduced by 51.60% compared to the standard technique.

EMS for microgrids has also progressed in recent years [6–8], with more sophisticated systems now available. The authors of [9] propose that a solar PV system be used in conjunction with an autonomous scheduling system to assist in reducing total electricity use. In addition [7], it has been demonstrated that an energy management technique with supply-demand is superior to a supply-side management strategy when used in off-grid HES in residential construction.

In order to deal with the HES energy management that consists of PV, battery, wind turbine generator, and fuel cell using a hybrid squirrel-whale, a method is designed in [10]. The authors in [11] investigate a number of different energy management optimization methodologies. The particle swarm optimization, genetic algorithm, fuzzy logic, and differential evolution are just a few examples of algorithms that take their cues from the world of nature and apply them to computer programmes. Researchers use genetic algorithms and particle swarm optimization methodologies to find the best potential responses to their questions. In order to function successfully and efficiently, this and other PEMS systems rely on precise projections of future demand and load [12–15]. In order to forecast future PV power generation, several PV power forecasting systems employ advanced machine learning algorithms. A novel LSTM-RNN model is introduced in [16] for solving typical machine learning difficulties such as overfitting and generalisation.

As demonstrated by a study of several experiments described in [17], artificial neural networks are well-suited for forecasting solar energy generation data. The forecasting models developed by [17–19] require a large quantity of prior data in order to provide good prediction accuracy; however, it has been demonstrated that causal and dilated forms of neural network tend to outperform machine learning methods with limited historical data in a variety of fields [20–24].

#### 3. Proposed Method

A form of logistic regression is used to anticipate energy generation and load demand one step ahead of time in order to reduce uncertainty. Because of the intrinsic feature extraction capabilities of logistic regression, time-series prediction is an excellent fit for logistic regression. It is possible to learn about local time series patterns using parallel processing methodologies, and LR integrates information from nearby steps to provide a final result. LR allows smaller-size kernel filters to catch data that exceeds the length of the kernel specified in the specification. As a result, the number of filters is reduced, which allows for a reduction in the total number of trainable parameters. Aside from that, using residual architecture allows data to flow from one convolutional phase to the next that reduces the problem of vanishing gradients via training process.

Because our data is collected at 1-hour intervals, we adjust the number of filters used in this study to match the hours and kernel size used. Because at each residual block, steady rise in dilation of different local and worldwide trends is learned at each convolutional phase, resulting in different local and global trends at each convolutional step. The proposed method of the predictive model is described and shown clearly in Figure 2.

##### 3.1. Grid-PV-Battery System

A residential building with photovoltaic (PV) panels and a battery bank (lead-acid) for energy storage is investigated in this study as a potential source of renewable energy. This system can be connected to the utility grid, allowing for the exchange of energy between the two systems. A predictive EMS (PEMS) controller has been installed in order to connect the battery bank and PV generation system. An electrical circuit breaker is used as an intermediary between the controller and the utility grid in order for energy to be exchanged between the circuit breakers are crucial safety devices because they may be used to manually switch between the grid and the PEMS controller, which is an important safety feature. The PEMS controller regulates the operation of the battery bank, PV system, and utility grid to meet peak demand requirements. This chip also regulates the battery bank (charging/discharging) and maximum limit of SoC in the PV system. The system design is depicted in Figure 3.

For the PV-battery HES energy supply and demand model, the following mathematical equations can be used to represent the model: where

*P _{t}^{r}*(kW): Residual battery power at time ,

max*S _{t}*: Maximum limit of PEMS controller.

*C _{t}^{g}* ($): Electricity cost from grid,

*C _{t}^{f}* : Positive electricity cost and,

*C _{t}^{e}*: Negative electricity cost.

##### 3.2. Logistic Regression Model

Logistic regression, like ordinary least-squares (OLS) regression, is a technique for making predictions. When employing logistic regression, it is only possible to predict a binary outcome. In this case, the error variance is not normally distributed, which is contrary to the OLS assumption. Therefore, they have a greater likelihood of being spread in an unplanned manner. In order to obtain the linear regression equation from the logistic distribution, we must first conduct an algebraic conversion on the logistic distribution.

Because logistic regression does not produce a preprinted result, it is not commonly used. Furthermore, the unstandardized result does not have the same obvious meaning as the OLS regression result, which further complicates the picture even further. A further limitation of OLS and logistic regression is that there is no to assess the overall fit of the model. An alternative to employing the logistic regression model is to conduct a chi-square test to see how well the data matches the model. A convoluted formula must be used to go back and forth from the logistic equation to an OLS-type equation in logistic regression, and this formula must be used in both directions. In logistic formulas, the probability that occurs is denoted by the letter . The probability that is equal to zero is equal to .

The regression line equation is derived from the sign, which signifies a natural logarithm and is represented by the letters .

The regression equation can also be used to get the value of . Thus, only the regression quantity is known, and the study can calculate theoretically the probability that for a given number of points in the regression.

where

*exp*: Exponent function, .

###### 3.2.1. Multiple Logistic Regression

Logistic regression, like ordinary least-squares regression, can be used with more than one predictor in the same way. There are a variety of alternatives for analysing the data, much like there are for regression. There are several ways to input variables: sequentially in a stepwise fashion, continuously, or in blocks. The results are interpreted through the use of OLS regression. The slopes and odds ratios of the dependent variable represent the predicted value obtained through a dependent variable. A slope obtained mainly represents the changes made at unit change in underlying predictor when the effect of the other variable is held constant. To examine whether or not the owner previous business ownership has an impact on the prediction of widget business failure. Using multiple logistic regression, it is possible to examine whether or not years of experience and previous business ownership are predictive of success or failure in a new firm.

#### 4. Results and Discussions

The study presents a description of the simulation findings obtained for the proposed PV-battery EMS multiobjective predictive control system. The data that will be used in the simulation is discussed at the beginning of the simulation. Following that is the prediction model performance on the displayed test dataset. Finally, dynamic electricity pricing is provided in order to evaluate the success of the proposed methodology.

In this section, the accuracy of the chained prediction model consisting of the LR model is evaluated in light of the hourly statistics and PV energy generation. The 1000 iterations of the prediction model, which is similar to the model that was used to predict the load and PV output datasets, were carried out in the same way. Because the stochastic optimization approach is utilised to train both the LR models, both models have dropout layers, as pointed out by Adam, and the autocorrelation output is given in Figure 4. It is necessary to run the model through multiple iterations in order to make accurate predictions. A single run of LR is performed due to the deterministic nature of the model output results.

For comparison, the normalised absolute error for each model on daily prediction is depicted in Figure 4. As a result, when converting hourly mean absolute errors to one-day spans, a 24-hour average is taken into consideration.

In Figure 4, the neat forecast models are displayed first on the residential load dataset. Our LR model, on average, has the lowest prediction error of all the models tested. The stochastic behaviour, on the other hand, is easily visible, as they exhibit some randomness in their prediction errors, whereas the prediction errors of nave and SVM regression are more deterministic for the same datasets.

The figure shows the PV energy production dataset, which is stochastic. Because of the random PV energy generation dataset, the model is influenced by a range of characteristics, such as solar irradiance and ambient temperature, this is the case. Because PV energy generation data contains a high degree of temporal variability, stochastic prediction using LR is more effective at learning this information.

For quite some time, researchers have been working on novel control and optimization approaches for the efficient management of energy in high-efficiency systems. This system, although simple to install, is focused on making the most of the power provided by the PV array rather than taking advantage of the full range of GCHES features and capabilities. This results as in Figures 5 and 6 in control behaviour that is comparable to that of a stand-alone HES.

Even though the control mechanism itself was straightforward, it was necessary to collect a historical data and it can computationally run demanding the optimization procedure in order to optimise decision trees. In addition, if the cost of electricity and/or the pattern of solar irradiation change, the control model will need to be revised and updated. When compared with traditional control methods, such as flowcharts and trees, predictive control systems use predicted HES variables to update their respective EMS control parameters, saving time and money.

Because of the sliding window training strategy, our prediction model can adjust the output uncertainties and load pattern even in the absence of large historical data. As a result, our proposed prediction model is capable of identifying high-quality solutions to optimise objectives while requiring no preprocessing or data to be used in its development. The implementation complexity is further lowered by the use of only one control parameter, the maximum SoC limit, which reduces the number of steps required. The authors also provide a hierarchical control system for governing information flows and preventing the prediction model from being trained at night, thereby reducing the processing load.

#### 5. Conclusions

This paper discusses LR-based on-grid predictive energy management for distributed energy resources. When it comes to renewable energy sources, a solar array like the one addressed in this study is one of the types in which the battery bank serves as a technology for energy storage. It is necessary to use LR in order to optimise energy exchange with the utility grid. By employing a training technique, the prediction model is capable of properly estimating photovoltaic energy output and load one step ahead of time. The maximum amount of CO_{2} that can be produced as well as the maximum amount of charge that can be stored in a battery bank serve as the constraints on the optimization issue. The proposed approach is put through its paces on a dynamic power cost basis. When compared to existing energy systems, the proposed approach and prediction model can handle more than half of the total yearly load requirement, which is a significant improvement. Achieving the lowest cost of electricity is the economic goal, while lowering emissions is the environmental goal and reaching the greatest possible charge state for battery bank is the technical goal. Sliding window prediction is used to evaluate the performance of the LR model over a 1000-run period, utilising data from PV energy generation and load demand. In future work, the proposed method can improvise the performance, accuracy, and the other metrics using several deep learning mechanisms.

#### Data Availability

The data used to support the findings of this study are included within the article. Further data or information is available from the corresponding author upon request.

#### Conflicts of Interest

The authors declare that there is no conflict of interest regarding the publication of this paper.

#### Acknowledgments

The authors thank the Wolaita Sodo University for providing help during the research and preparation of the manuscript.