Neuro-Fuzzy-Based Model Predictive Energy Management for Grid Connected Microgrids

: With constant population growth and the rise in technology use, the demand for electrical energy has increased significantly. Increasing fossil-fuel-based electricity generation has serious impacts on environment. As a result, interest in renewable resources has risen, as they are environmentally friendly and may prove to be economical in the long run. However, the intermittent character of renewable energy sources is a major disadvantage. It is important to integrate them with the rest of the grid so that their benefits can be reaped while their negative impacts can be mitigated. In this article, an energy management algorithm is recommended for a grid-connected microgrid consisting of loads, a photovoltaic (PV) system and a battery for efficient use of energy. A model predictive control-inspired approach for energy management is developed using the PV power and consumption estimation obtained from daylight solar irradiation and temperature estimation of the same area. An energy management algorithm, which is based on a neuro-fuzzy inference system, is designed by determining the possible operating states of the system. The proposed system is compared with a rule-based control strategy. Results show that the developed control algorithm ensures that microgrid is supplied with reliable energy while the renewable energy use is maximized.


Introduction
Owing to the considerably increasing population and use of technology, the share of electricity in energy consumption is expected to reach 50%-20% more than it is today [1]. The amount of electricity consumption per capita, especially in countries with large economies, is increasing worldwide [2]. In addition, according to the data in World Energy Outlook 2018, for the first time, the total number of people without electricity has fallen below 1 billion [3]. When energy sources are evaluated from different aspects such as the cost of energy, ease of procurement and the environmental impact, renewable energy-based sources have significant advantages over fossil-fuels [4]. Because of these reasons, the use of fossil fuels, which is in the first place among more than a century energy sources in the world, has started to be replaced by renewable energy sources. The United Nations Sustainable Development and the Paris Climate Agreement, which aims to reduce emissions to the environment, has further increased interest in renewable resources [5]. Therefore, management of renewable energy sources, such as hydraulic, wind, solar and wave energy, has become crucially important.
Renewable energy sources are not stable in terms of energy sustainability and efficiency. For example; when the sun is bright, solar energy systems generate electrical energy decisively, but they cannot generate electricity in cloudy and evening hours. Important problems arise due to this unstable and intermittent structure. Furthermore, their performance changes in time [6]. Therefore, this issue is being studied more intensively. The aim of the studies is not only to obtain the energy, but also to bring the energy to the appropriate values, to manage the existing energy and to eliminate the fluctuations it may cause in the system.
When the solar irradiation and temperature change, the solar panel cannot provide continuous and constant power. The energy generated from renewable sources cannot be provided at the desired time intervals as in traditional energy sources. By using renewable energy systems with storage units, generated energy can be stored, and the energy continuity can be provided for the users. Energy storage applications can be used when it is needed to store energy from these sources. Storage units have made the energy more feasible especially during peak hours.
Variable weather conditions, day-night conditions and changes in loads require energy management. The energy management systems can support each other and enable and disengage, charge and discharge the batteries according to the level of charge and connect to the grid when the batteries are exhausted and de-energized. One of the most important solutions to the instability problem in renewable energy sources is energy storage. By storing energy, it can exchange power in a planned manner in energy management so that the storage unit can act as a separate active and reactive power source, providing greater flexibility in energy management.
This autonomy offers the ability to manage their own warehouses, manage their own generation and manage and control the power flow to benefit from the grid according to various criteria. Numerous studies pertaining to energy management in microgrids or in the grid-connected power distribution system can be found in the literature [7]. The energy management related studies are carried out for several reasons, including loss minimization in the transmission and distribution systems, reducing greenhouse gas emissions, cost minimization by reducing the generation costs and the electricity bills [8]. There are also technical reasons such as managing the negative impacts of novel technologies, e.g., electric vehicles (EVs) and smart inverters, on the traditional grid structure [5,9,10].

Related Literature
High penetration of renewables changed the operation paradigms of power systems. In order to cope with these changes, energy management systems have become indispensable for most applications. Due to this, the research field is rich with research on such systems. For instance, there are many methods utilized inf energy management systems such as classical methods [11], metaheuristic approaches [12,13], artificial intelligence methods [14,15] and model predictive control [16][17][18].
A model predictive control strategy, based on weather forecasts, is proposed to reduce the energy required and increase the use of renewable energy sources for energy management in domestic micro-grids [19]. The designed MPC control strategy is based on solving a limited optimal control problem for a given time horizon. This recommended system was compared with the standard rule-based control logic. An improvement in home comfort conditions and an average of 14.5% reduction in the use of primary fossil energy are observed.
The PV power surplus causes voltage fluctuation in the low-voltage distribution grid. In order to eliminate this problem, a new PID control scheme for the ANFIS-based PV interface inverter and ANFIS-based controlled energy storage management system for PV system connection is proposed in [20]. The fuzzy logic-based battery energy storage system (BESS) control scheme is recommended and demonstrated the suitability of the fuzzy controller for DC bus voltage control in [21]. A fuzzy inference system (FIS) is proposed for a system with renewable energy sources and storage unit for the management of the energy storage system in [22]. The proposed system was compared with a rule-based control strategy and showed that the proposed FIS can effectively reduce fluctuation and extend the life cycle of energy storage system (ESS).
Control and switching-based energy management system is recommended for the microgrid system consisting of wind, PV and battery in [23]. The recommended energy management system (EMS) is available with or without mains. This system can be synchronized with different sources to shave load power during the hours when it is the maximum load. For example, according to the strategy, while wind is used as the primary power source, PV is added to increase the reliability of the system in different weather conditions. The battery module is used as an energy storage system during backup power during excess power and / or demand in [23].
In order to manage energy sources distributed from micro-scale energy centers, a self-renewing algorithm that manages optimal energy flows is proposed to achieve minimum energy costs depending on the energy, prices and expected load demand from each source in [24].
MPC with production, consumption, battery and price constraints is designed for a grid connected system consisting of wind, PV and battery in [25]. With this study, it was aimed to select the appropriate source and provide optimum power to the demand side.
A hybrid energy management algorithm is proposed by adjusting the rule base of the fuzzy inference system with hierarchical genetic algorithm (HGA) in [26]. The fuzzy-HGA algorithm appears to be better than the classical fuzzy-GA algorithm, using only 47% of the rules within the rule base. By obtaining a simpler fuzzy logic controller, the entire control system can be implemented in real time on low-cost embedded electronic devices. The grid connected microgrid consisting of wind, PV, solid oxide fuel cell (SOFC) sources, BESS and two equivalent DC and AC loads in [27]. Online-trained neural network-based control system is recommended for MPPT. In order to reduce the power drawn from the grid, fuzzy logic-based EMS is designed.
A fuzzy logic-based EMS is proposed to minimize fluctuations and peak powers of a grid tied microgrid in [11]. The classical fuzzy-genetic algorithm method is proposed in study [12]. Two different GAs is used. The first GA sets the microgrid's energy planning and fuzzy rules, the second GA sets the fuzzy membership functions. fuzzy expert systems are also used in battery power management. Energy management is recommended with a multi-objective particle swarm optimization method of a grid-connected microgrid consisting of a wind-PV-FC battery in [28]. It is aimed to achieve maximum power generation from each source and to reduce the operating cost of the microgrid.
A hybrid algorithm is created using PSO and gray wolf optimization (GWO) and day-ahead scheduling nested energy management strategy is recommended in [29].
Fuzzy logic-based energy management is recommended for a hybrid system consisting of PV-FC-battery in [30]. Real-time and long term predicted data are used at the energy generation and consumption. In the designed system, multiport converter and magnetic bus are used to reduce voltage conversion stages.
A nonlinear MPC approach is proposed in [13]. An artificial NN was used for load trough estimation. Battery state of charge (SOC) control and load planning to ensure voltage stability. Grid connected recommended an MPC-based EMS in [14]. By increasing the use of wind power and battery, the power received from the grid and the energy cost is reduced.
To minimize the cost of energy received from the grid, using Gaussian process (GP) estimation and MPC energy management are recommended in [31]. With the GP, PV output power and load demand power are estimated. An optimization-based MPC algorithm is used.

Contribution
The supervisory control of the microgrid energy management system is divided into central and decentralized EMS. In this study, central EMS method, which collects all information such as meteorological and energy consumption, is used. Reference current values of DC-DC bidirectional converter were determined from the previous day with a predictive energy management model based on neuro-fuzzy. Estimates made with higher accuracy compared to previous day make management easier. The following advantages were achieved by using the recommended management algorithm in the designed system.

1) Power received from the utility is kept to a minimum;
2) The battery is prevented from charging and discharging for very small values, thereby contributing to battery life. When the PV system's power drops below 200 W, the system is deactivated with the management algorithm. Since the battery current reference value is determined from previous day, there was no delay in management during the day. In addition, management planning of the place to be managed is made easier thanks to the neuro-fuzzy algorithm.
MPC approach is an optimal control strategy that solved as an optimization problem [32]. Hence, that is control the future behavior of a system using an explicit model of the latter [33,34]. The recommended control unlike classic control engineering MPC setting [32,[35][36][37] this study presents objective function for this proposed method is the energy usage from the grid and battery dischargecharge.
In this study, day ahead PV generation and load forecasting were made using ANN. Then, using these estimates, the reference current value in the bidirectional converter was determined with a twoinput (power, SoC%) ANFIS to use minimum energy from the grid and minimize battery usage, considering the state of charge constraint (14) and PV generation constraint (15).
The rest of the study is organized as follows: Section 2 gives microgrid components. In Section 3, developed forecast models for solar irradiation, temperature and load demand are presented and simulated. neuro-fuzzy, rule-based control strategy and neuro-fuzzy-based energy management of microgrid were mentioned. Finally, energy management estimates and simulation status are given for one day.

Microgrid Components
Microgrid is a small-scale power grid that has specific autonomy with its own energy resources, generation and load, which can be operated autonomous mode or connected to the grid [38]. Figure  1 shows the designed grid-connected microgrid standalone power supply system. The designed microgrid system consist of a PV system and a battery bank. All of them use DC-DC power converters in order to connect them to a central DC bus and DC-DC power converter is connected to a grid by an AC-DC three-phase rectifier.

PV System
The sun provides the Earth with more energy in one hour than the energy consumed by humans all year round [38]. For this reason, it is the renewable energy source that increases the capacity of PV systems, which is one of the renewable energy conversion systems, each year [39]. In this work eighty Sunrise Solartech SR-P660 260 PV models were used for 20 kW power generation and the each of eight serial panels connected in parallel to ten. The power-voltage and current-voltage characteristics of Sunrise Solartech SR-P660 260 PV model obtained [40].
In order to operate the PV panels more efficiently, it is necessary to know the point where maximum power is taken. Maximum power point tracking systems can be used at this point to increase the efficiency of the panel [41]. In this study, the DC-DC converter MPPT control techniques were controlled by perturb and observation algorithm [42] and the PV voltage was adapted to the DC bus voltage. The parameters of the simulation are presented in Table 1, which is taken from [40].

Batteries
In renewable energy sources, they are used as an auxiliary source for feeding loads when energy is not available from the source. It is of great importance in energy management. It reduces the negativity of the variable and unstable structure of renewable energy sources. In this work lead-acid type of battery was used for 18-kWh power store because it is usually the least expensive storage battery, providing good performance and life characteristics [43]. The battery bank rating (Ah) calculation is used the equation in (1), where the battery depth of discharge is taken as 60% [44]. In this study, battery model in Matlab/Simulink library was used.
Hence, 12 V, 125 Ah battery rating is considered. Using (1), it is worked out that the number of batteries required to connected in series was 20.

Inverters/Converters-
In the designed microgrid system, the common DC bus voltage is determined as 400 V and DC-DC converter is used to increase the voltage value at the output voltage the PV system. The output power of PV system is performed by using boost type converter. The parameters of the designed converter are given in Table 2. The output voltage of the battery is 230 V-245 V. In order to discharge the battery, it must be connected to the DA bus, for which we must increase the battery output voltage. However, at the same time in order to be able to charge the battery with the power from the DA bus, we must reduce the voltage of 400 V to the battery output voltage. Hence, the battery uses a bidirectional converter. Figure 2 shows the DC-DC bidirectional converter. The parameters in the converter structure are expressed as equations (2)-(4) [45,46]: where is the battery bank voltage, is the DC-link voltage, is the DC-link current, is the battery bank current, ΔV ( ) is the buck side output desired ripple voltage, ΔV ( ) is the boost side output desired ripple voltage and is the switching frequency. The parameters of the designed DC-DC bidirectional converter are given in Table 3. Figure 3 shows the Matlab/Simulink block diagram of the designed microgrid system.

Forecasting with Neural Networks
In this study, a multilayered, feed forward artificial neural network (ANN) was designed to predict the hourly solar irradiation, temperature and electricity consumption of next day in the same palace in Turkey.
In Figure 4, the structure of the multilayered ANN designed for forecasting is given. The data were normalized between 0.1-0.9 before use. In Table 4, input and output variables of ANNs designed are given. The variables X(1)-X(24) used for electricity load and temperature are the load data of the day just before the forecasting day.

Output Variables Explanation
Hourly data to be estimated for the day to be forecasted (W/m²) The similar day selection interval is shown in Figure 5. Since the solar irradiation, temperature and electricity loads characteristics of the seasonal effects show similarity at the same time during the year, it is considered to be a time series [47]. After selecting the 90-day interval for solar irradiation forecasting, the clearness index of each day for these 90 days was calculated and similar days were classified among themselves. Similarity was also sought between maximum temperatures. These two variables were selected by looking at the correlation between them and solar irradiation (SI). Thus, by increasing the similarity ratio, the error that will occur in the estimation was tried to be minimized. A similar day was found with the weighted Euclidean norm formed using the maximum daily temperature ( ) and clearness index ( ). Similarity ratio was found with the help of equations (5)-(7).
The effect of the parameters used for the similarity selection with the least squares method on solar irradiation was determined [48]. The determined coefficients were chosen as the most appropriate similar day by using the ratio that they affect the day irradiation in Euclidean norm. Load estimation was selected 90 days by the same interval, but 24 hours load data of the previous day was used as input. In other words, only the training and testing interval selection was made with the same method.
After the 90-day training set was created, the day most like the forecast day was selected using a similar day algorithm. The 24-hour data of the similar day was given as the input and the 24-hour data of the forecast day was estimated as the output. Mathematically, 24-h-ahead forecasting can be formulated as equation (8).
In this study, one-step 24-h-ahead hourly forecasting was made. Inputs are 24-hourly data to be estimated of similar day, as given in Table 5. Similar day selection is shown in Figure 5 and described in section 3.1. Table 5. One-step-ahead prediction methods.

Forecasting Inputs
(1), (2), … , (ℎ) , (1), , (2), … , , (ℎ) (1), (2), … , The parameters of ANN designed for solar irradiation forecasting are given in Table 6. ANN parameters were determined by try and error. Since it was observed that the error-value changed slightly when the multilayer was made, but the duration of the program was prolonged, it was decided that a single layer network was better by considering the error-value decreasing with the program time. The number of iterations and the number of neurons in the hidden layer were determined by trial and error in order to provide the highest accuracy considering the error-value (r: correlation coefficient).

The Name of Variables Solar Irradiation
The number of inputs 24 The number of outputs 24 Hidden layer 1

Activation function Logistic sigmoid function
Training algorithm Backpropagation algorithm The number of neurons in hidden layer 29 The number of iterations 63,000 Designed for load prediction, the ANN has different hidden neuron numbers and it was decided that a single layer network was better by considering the error-value decreasing with the program time. In other words, the number of layers was decided by trial and error. A total of 37 hidden neurons and 19,300 iterations were used for load estimation. The temperature forecast variables are the same as solar forecasting. Statistical performance measures such as mean absolute percent error (MAPE), correlation coefficient (r), square mean error (RMSE) and mean absolute error (MAE) were used to measure the performance of the predictions [49].

Neuro-Fuzzy Applications
The neuro-fuzzy algorithm is combining artificial neural networks (ANNs) and fuzzy logic. neuro-fuzzy systems are used in areas such as student modeling system, medical system, economic system, electrical and electronic system, traffic control [50], image processing [51] and feature extraction, production and system modeling, estimations [52], NFS developments and social sciences [53]. The adaptive neural fuzzy inference system (ANFIS) has different structures such as FuNe, fuzzy RuleNet, GARIC or NEFCLASS and NEFCON. ANFIS structure was used in this study. The aim of the neuro-fuzzy method is to apply a learning method using input-output training data and to adjust the parameters of the fuzzy system. ANFIS uses Sugeno fuzzy rules in its structure. It consists of 5 layers. Layer 1 consists of input variables. Layer 2 is a membership layer that controls the weights of the membership function. It takes input values from the first layer and membership values are specified to represent fuzzy sets of related input variables. Layer 3 is called the rule layer and takes the entries from the previous layer. This layer calculates the activation level of each rule. Layer 4 is the defuzzificated layer. It is the definition layer that provides the output values resulting from the extraction of rules. Layer 5 is the output layer that collects all inputs from the previous layer and converts the fuzzy classification results to a clear-value. In Figure 6, a typical architecture of ANFIS is shown.  Figure 7 shows a rule-based controller (RBC) flow chart which is used to compare with the proposed neuro-fuzzy-based energy management. This is the same strategy adopted in [56] (This study has a fuel cell, so our rules are different.). The charging/discharging rate for this RBC is a constant ±6 kW. The power formulation was given in equation (9).

Neuro-Fuzzy-Based Energy Management of Microgrid
Neural networks and fuzzy are used together. In the neuro-fuzzy algorithm, energy state and battery charge rate are used as input and battery current is used as output. The limits of the inputs and outputs and the limits of membership functions are determined by trial and error. Figure 8 is shown the fuzzy clusters of inputs and outputs. fuzzy rule table is given in Table 7.   20% ≤ SOC ≤ 90% (14) 200 W ≤ ≤ 20 kW (15) 25 fuzzy rules were created. The neuro-fuzzy intelligent energy management algorithm controls the power flow by making decisions based on these situations. Some of the rules used when creating the fuzzy rule table in Table 7 are given below.
 Rule 1: If the power is negative high and the SOC is very low, the is zero;  Rule 6: If the power is negative high and SOC is low, the positive is small;  Rule 10: If the power is positive high and the SOC is low, the is negative high;  Rule 14: If the power is positive small and SOC is medium, the is negative small;  Rule 22: If the power is negative small and the SOC is very high, the is positive small; Zero fuzzy value is defined between fuzzy clusters of battery reference current so that the battery does not shorten battery life by charging or discharging for such a small value if the power generated from renewable sources is too little or too large than the load. MPC-inspired energy management algorithm flowchart is given in Figure 9. These two energy management systems were evaluated according to the energy usage from the grid and battery discharge-charge number.

Results of Forecasting
Randomly selected data refer to February 4, 2019. The hourly solar irradiation for the day of forecasting in Figure 10 was found to be 5.56% MAPE, 26.05 W/m² RMSE, 14.71 MAE and 0.9902 correlation coefficient. As the correlation coefficient approaches 1, the degree of accuracy of the estimation increases. The correlation coefficient value of 0.9902 shows us that today's estimation is very good. Percentage error-values provide predictive results to be more meaningful and make the results easier to interpret. MAPE is the average of the sum of absolute values of percentile errors. MAPE measurement was done with normalized (0.1-0.9) values. According to the MAPE performance criterion, the estimates made under 10% are in the "high accuracy" degree, if it is between 10% and 20%, it is "true", if it is between 20% and 50%, it is "acceptable" and if it is above 50%, "false and inaccurate" [57]. Proportional or percentage error measurements are required to compare error measures. A similar day selection algorithm increased the accuracy of the prediction. High-accuracy solar irradiation estimation is performed with the designed ANN structure. The statistical performance measures for randomly selected days for 2019 were given for solar irradiation in Table 8. In this study, estimation was made with a single method and Kolmogorov-Smirnov (K-S) test applied and results are shared in Appendix C, but to test the significance of the accuracy values of two different sets of prediction, a test based on the K-S test principles, referred to as the K-S predictive accuracy (KSPA) test was proposed in [58]. 24-hourly real and forecasted data of the load, temperature and solar irradiation data from 04/02/2019 are given in Appendix B.  For the same day, the hourly temperature for the day of forecasting in Figure 11 was found to be 5.05% MAPE, 1.64 RMSE, 0.0262 MAE and 0.99 correlation coefficient. The correlation coefficient value of 0.99 shows us that today's estimation is very good. High-accuracy temperature estimation is performed with the designed ANN structure. The statistical performance measures for randomly selected days for 2019 are given for temperature data in Table 9.  The forecasting temperature and solar irradiation values are given as input to the designed PV system. In addition, the actual temperature and solar irradiation values are given and the outputs in Figure 12 are obtained. The output with 0.9836 r-value. For the same day, the hourly temperature for the day of forecasting in Figure 13 was found to be 10.24% MAPE, 0.7245 RMSE, 0.0258 MAE and 0.96 correlation coefficient. The correlation coefficient value of 0.96 shows us that today's estimation is very good. High accuracy temperature estimation is performed with the designed ANN structure. The statistical performance measures for randomly selected days for 2019 were given for load data in Table 10.

Results of Energy Management with ANFIS-Based on MPC-Inspired
By means of this energy management, the reference voltage values to be entered for doublesided transducer control and the power-values to be drawn from the grid are determined according to the load and power generation estimation. Figure 15 shows the power distribution profile with ANFIS-based MPC-inspired for 04/02/2019. The battery is charged between 9-14 hours and discharged between 18-21 hours. Between 8-10 hours, unused power from the grid loads are fed by PV system and battery. In Figure 16, the power used from the battery and grid are compared for both cases.  The forecasting errors on the control strategy and performance of energy management is impact. False predictions have a negative effect. For example, the PV generation was estimated to be lower than the actual value between 9-11 hours. Hence, the battery is charged less than it should. Between 12-14 hours PV generation was estimated to be low, electricity consumption was overestimated and excess power was drawn from the grid.
With the recommended management, it was ensured that the battery group has a longer cycle life by reducing the charge/discharge period of the battery by preventing the battery from continuously switching on and off in a small power change. For example, while the battery is not used in the management recommended between 8-9 hours in Figure 16, the battery is used in the system managed by RBC. At the same time, continuous switching of the system is prevented, and power loss is reduced.

Conclusions
In this study, neuro-fuzzy-based MPC-inspired energy management is proposed for grid connected microgrids. Since energy production and consumption data are estimated in the recommended energy management, the model is provided with predictive control by planning energy management by the algorithm. Considering the charging status and the production estimated from the renewable source, the battery is ensured not to be de-energized and at the same time to draw as little energy from the grid as possible. With the recommended algorithm, the energy level in both devices was managed and it charge/discharge amount was decided for the battery. The proposed system is compared with a rule-based control strategy.
The proposed algorithm and ANN-prediction algorithm were implemented and the gridconnected system was simulated. The behavior of the algorithm was examined using day ahead load and PV forecast data for a specific day. The results verify that the developed energy management system predicts the load and generation with high accuracy. The grid usage is reduced with the system recommended according to RBC. Consequently, less energy exchange with the grid ensures that the bills are lower. Battery usage in the recommended system is less than RBC, so battery life is extended. With the recommended management, it was ensured that the battery group has a longer cycle life by reducing the charge/discharge period of the battery by preventing the battery from continuously switching on and off in a small power change. All these benefits encourage investors and house-owners towards use of more renewables, even if that requires some storage installation.

Appendix C
The first line tests the null hypothesis that load/temperature/irradiation for the first group 'real values" contains smaller-values than for the second group "forecasted values". The largest differences between the distribution functions are 0.250/0.208/0.041, accordingly. The approximate pvalue for this is 0.223/0.353/0.959, which are not significant at an acceptable level of significance. The second line tests the hypothesis that load/temperature/irradiation for the first group 'real values" contains larger-values than for the second group "forecasted values". The largest differences between the distribution functions in this direction are −0.041/−0.166/−0.041. The approximate p-value for these small differences are 0.959/0.513/0.959, which are not significant either. Overall, we cannot reject the null hypothesis that these two-samples come from the same distribution.