*Article* **Effect of Daily Forecasting Frequency on Rolling-Horizon-Based EMS Reducing Electrical Demand Uncertainty in Microgrids**

**Giuseppe La Tona, Maria Carmela Di Piazza \* and Massimiliano Luna**

Consiglio Nazionale delle Ricerche (CNR), Istituto di Ingegneria del Mare (INM), via Ugo La Malfa 153, 90146 Palermo, Italy; giuseppe.latona@cnr.it (G.L.T.); massimiliano.luna@cnr.it (M.L.) **\*** Correspondence: mariacarmela.dipiazza@cnr.it

**Abstract:** Accurate forecasting is a crucial task for energy management systems (EMSs) used in microgrids. Despite forecasting models destined to EMSs having been largely investigated, the analysis of criteria for the practical execution of this task, in the framework of an energy management algorithm, has not been properly investigated yet. On such a basis, this paper aims at exploring the effect of daily forecasting frequency on the performance of rolling-horizon EMSs devised to reduce demand uncertainty in microgrids by adhering to a reference planned profile. Specifically, the performance of a sample EMS, where the forecasting task is committed to a nonlinear autoregressive network with exogenous inputs (NARX) artificial neural network (ANN), has been studied under different daily forecasting frequencies, revealing a representative trend relating the forecasting execution frequency in the EMS and the reduction of uncertainty in the electrical demand. On the basis of such a trend, it is possible to establish how often is convenient to repeat the forecasting task for obtaining increasing performance of the EMS. The obtained results have been generalized by extending the analysis to different test scenarios, whose results have been found coherent with the identified trend.

**Keywords:** energy management system; forecasting error; rolling horizon; demand uncertainty; microgrids

### **1. Introduction**

The microgrid paradigm has gained interest in the last decade as a promising solution for a progressive decarbonization of the energy mix and a more efficient, flexible, and economic operation of electrical power systems [1]. Similarly, the concept of a buildingintegrated microgrid has emerged due to a twofold reason: firstly, for environmental issues, since the electrical power consumption of buildings is about 32% of the total production worldwide with a contribution to the global greenhouse gas (GHG) emissions approximately equal to 30%; secondly, for the growing influence of building-integrated gridconnected renewables on power quality and stability of electrical distribution grids [2,3].

Moreover, the recent provisions introduced for the grid-connected renewable generators encourage the consumers to switch from the role of passive energy users to the role of active energy producers; thus, the users contribute with energy supply and ancillary power quality services to the main power grid, according to the concept of the prosumer microgrid, where a prosumer is a user who can both produce and consume the energy [4,5].

On such a basis, numerous technical contributions have been proposed in the literature on energy management systems (EMSs) for residential/commercial microgrids encompassing renewable generators and battery storage systems (BSS), with the aim of improving energy efficiency and reducing the energy bill by means of demand response (DR) or alternative optimization-based strategies [6–8]. Such EMSs, if properly coordinated with the power grid upstream, can also produce benefits to the main grid manager; for example, by limiting the peak of energy demand and the power loss on electrical feeders and by

**Citation:** La Tona, G.; Di Piazza, M.C.; Luna, M. Effect of Daily Forecasting Frequency on Rolling-Horizon-Based EMS Reducing Electrical Demand Uncertainty in Microgrids. *Energies* **2021**, *14*, 1598. https://doi.org/ 10.3390/en14061598


Academic Editor: Gianfranco Chicco

Received: 18 February 2021 Accepted: 9 March 2021 Published: 13 March 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

preventing adverse events, such as poor renewable-based power production, energy price fluctuations, voltage limits breaches, and so on [4,6,9–11]. Therefore, EMSs are considered nowadays a relevant technical solution for the enhancement of the efficiency, reliability, and economy of smart microgrids [12–14].

EMSs are increasingly gaining interest also in the field of vehicular electrical systems. Recently, the use machine learning techniques for energy management with a special focus on thermal and battery degradation issues has been proposed. In [15,16] reinforcement learning strategies (a soft actor-critic deep reinforcement learning strategy and the deep deterministic policy gradient algorithm combined with an expert-assistance system, respectively) are used to get optimal allocation of power in hybrid electric buses; furthermore, thermal and battery degradation issues are considered in the energy management algorithm formulation, obtaining improved performance in terms of training efforts, optimization, and overheat protection with respect to existing strategies.

With regard to microgrids, forecasting of generation and load demand is one of the most important tools for an EMS—it is usually employed to plan and schedule optimal power flows in a microgrid and has a significant impact on the effectiveness and performance of the EMS [17]. Several energy-related data forecasting models have been proposed in technical literature, ranging from simple persistence methods, to physical models, to time series linear models, up to artificial intelligence (AI)-based models, including machine learning-based approaches such as the most recent solutions based on deep learning [18,19]. Among them, the most robust and reliable methods, according to the literature, are those based on AI, e.g., artificial neural networks (ANNs), where a suitable trade-off between simplicity and accuracy is also taken into account as an enabling factor for a straightforward real-world implementation of forecasting functionalities within EMSs [20].

As far as the use of forecasting techniques within EMSs is concerned, some authors have focused their interest on establishing the most performing/convenient algorithms to forecast the energy-related variables involved in grid energy management. For example, in [5], a new hybrid machine learning-based method is developed to precisely and simultaneously forecast the microgrid's variables with the aim of improving a DR-based operation; this method encompasses an adaptive neuro-fuzzy inference system, a multilayer perceptron ANN, and a radial basis function ANN.

In [21], some possible candidate forecasting methods have been investigated with regard to their convenience and cost efficiency, rather than to their accuracy, identifying simple forecasting models, based on regression analyses using linear, seasonal linear, and quadratic formulations.

Integration and coordination issues between forecasters and optimizers in EMSs have been explored as well. In [22], for instance, a fully automated control in a home energy management system (HEMS) including all parts of the smart microgrid architecture (noninvasive load identification, forecasting, optimization, renewable energy sources, and storage elements) is proposed; the work is particularly focused on the coordinated use of a forecasting model based on the long short-term memory (LSTM) and an optimization strategy based on a genetic algorithm (GA), working respectively on the prediction and optimal scheduling of load demand.

Other recent contributions in technical literature have been focused on the evaluation of forecasting errors on the EMS performance. A HEMS minimizing cost and energy loss, and improving self-consumption is presented in [23]; here, the accuracy of several forecasting methods is evaluated, demonstrating that forecasting errors in both load demand and renewable generation produce adverse effects on the HEMS performance and, thus, on the household energy cost and lost energy.

Still in the context of the evaluation of the effects of forecasting errors, ref. [24] analyzes the sensitivity of a residential microgrid's battery control to load demand and generation forecasting errors when the battery is involved in arbitrage for residential consumers under the Time of Use pricing scheme; it is demonstrated that low forecasting accuracy has an impact in terms of energy losses.

Although the investigation of the most performing or convenient forecasting techniques for EMSs has received a considerable deal of attention in recent studies, the selection criterion of the daily forecasting frequency, in the framework of an energy management algorithm, has not been properly investigated yet. Specifically, defining how many times the generation/load forecasting should be updated in the typical 24 h horizon of an EMS to achieve enhanced performance is still an open question.

To start filling this gap, in this paper, the effect of forecasting task execution frequency has been evaluated considering the rolling horizon EMS presented in [11]. Such an EMS relies on a two-stage algorithm designed to minimize the electrical demand uncertainty in a grid-connected building microgrid by trying to adhere to a reference planned profile of the power exchanged with the upstream grid. The EMS under consideration was tested considering as a case study a microgrid comprising photovoltaic (PV) generation, battery storage, and electrical loads. The forecasting of both PV-generated power and load demand within the considered EMS is executed once a day according to the multi-stepahead approach, and it is based on the nonlinear autoregressive network with exogenous inputs (NARX) ANN, which is a structure realizing a good balance between performance and simplicity.

In this paper, different update rates of the forecasting task performed using the NARX ANN have been introduced in the EMS execution, and their effect on the demand uncertainty obtained as a result of the EMS operation has been quantitatively evaluated. The analysis has revealed a clear trend relating the forecasting execution frequency in the EMS and the reduction of uncertainty in the electrical demand. Specifically, a reduction of the demand uncertainty is observed for increased forecasting execution frequency up to 48 times a day. Such a trend also allows for the establishment of to what an extent is convenient to repeat the forecasting task in the considered case study for obtaining still significant improvements of the EMS performance. To generalize the observed behavior, the same experiments have been carried out considering also synthetic forecasted profiles and artificial reduction of forecasting errors during the day according to a model. These additional results have confirmed the identified trend. It is worth observing that the presented analysis results could be useful to designers and practitioners involved in the design of EMSs for microgrids.

The paper is organized as follows. In Section 2, the main features and the operating mode of the two-stage rolling horizon EMS developed in [11] are recalled. Section 3 presents the case study, i.e., the characteristics of the building's microgrid and the used datasets of PV power generation and load demand. Section 4 deals with the daily forecasting frequency analysis, including a comparison between the results obtained by the EMS in the real case and in the generalized cases. Finally, a discussion of the results is presented, and conclusions are drawn.

### **2. Fundamentals of the Considered EMS**

As stated in Section 1, the paper aims at evaluating the effect of daily forecasting frequency on the performance of EMSs that aim at reducing demand uncertainty in a grid-connected building microgrid trying to adhere to a reference planned profile of the power exchanged with the main power grid. Such a reference profile can be obtained in different ways depending on the goal to be pursued. For example, it can be computed aiming to achieve the minimum operating cost of a microgrid [11,25], possibly considering hourly variable prices or other DR management techniques enforced by the distribution system operator (DSO) [26,27]. In other cases, the reference profile is obtained, reshaping the expected profile of the consumed or injected power at the point of common coupling; for example, reducing its peak-to-mean ratio to avoid incurring in curtailment measures applied by the DSO to preserve grid stability [28,29]. As a third example, it is possible to follow an approach aimed at planning the usage of predictable loads and managing unpredictable loads in real time thanks to a PV-battery backup system to ensure a reliable

and efficient power supply in countries where regular and frequent blackouts occur in the main grid [30].

The proposed investigation will be performed referring to the EMS presented in [11], whose specific main features are described hereinafter; however, the obtained results are representative of the behavior of many EMSs that aim at reducing demand uncertainty trying to adhere to a reference power profile.

The considered EMS pursues two goals at the same time thanks to a two-stage operation aiming at providing advantages both to the end user and to the DSO by computing optimal power references for the controllers of all the electrical devices of the microgrid (i.e., local renewable or non-renewable generators, storage systems, electrical loads as well as the connection to the main grid).

In the first stage, i.e., Planning, it forecasts the 24 h ahead profiles of load demand and environmental variables tied to renewable generation based on past data using an ANN. To achieve good results, the forecasting is performed using the NARX ANN, which has been successfully used in time-series modeling thanks to its simple implementation and its adaptive learning process, even with small-scale data [31]. In the considered case, the exogenous input is the environmental temperature for both PV generation and load demand forecasting. In particular, as far as the dependence of electrical power demand on environmental temperature is concerned, it should be observed that a power consumption scenario framed in a low carbon vision is considered by means of massive use of electrification, e.g., heat pumps for heat, ventilation, and air conditioning (HVAC); on such a basis, a strong dependence of load demand on temperature is envisaged. Based on the forecast data, the EMS solves an optimization problem to find the optimal 24 h profiles of the power flows for all the electrical devices of the microgrid that allow the minimization of the user's cash flow in the whole next day. The point-by-point sum of such optimal profiles gives the planned profile of the power exchanged with the grid in the next 24 h or, for short, the planned GEPP (grid-exchanged power profile), which is a vector of power values across the time steps of a day (positive when the main grid supplies the microgrid, negative when an excess of power from renewable generators is injected into the main grid). The planned GEPP is transmitted to the DSO over a secure Internet connection as an obligation to which the user commits themself. Being based on forecast data, the planned GEPP could be affected by forecasting errors.

In the second stage of the EMS, an Online Replanning task is repeated at each time step of the day using measured data and aiming at minimizing the deviation between the actual GEPP and the planned one that was transmitted to the DSO the day before. In this way, besides minimizing the user's cash flow, the considered EMS also reduces the uncertainty on the GEPP against forecasting errors on the load demand and renewable generation profiles. The DSO can take advantage of this last feature and, by exploiting also the natural statistical compensation of users' deviations, can rely on a quite predictable aggregate demand profile to optimize power dispatching and improve its economic planning policy [32]. It should be observed that the goal of minimizing the cash flow is in any case pursued in compliance with the enforced physical, technical, and contractual constraints. Therefore, considering a more extended electrical system governed by the EMS does not imply criticalities for the DSO.

The Online Replanning task is based on solving another optimization problem, and it is not greedy because it does not aim at minimizing only the deviation at the current time step. Instead, it performs an optimization also considering the future time steps of the current day in a rolling-horizon fashion. Therefore, at each execution of the Online Replanning task, the first set of power references for the microgrid devices, i.e., the set computed for the current time step, is actually sent to the device controllers via an internal communication network. Instead, the other sets of power references, i.e., those computed for the future time steps, are discarded. After the execution of the Online Replanning task in the last time step of the day, a new cycle restarts from the Planning stage.

As explained, in the original formulation of [11], the forecasting task is performed only once in a day (e.g., at midnight); in particular, the whole 24 h ahead forecasted profiles are used in the Planning stage, whereas at each execution of the Online Replanning stage a smaller and smaller residual portion of the same profiles is used to consider future time steps in a rolling-horizon fashion. In Section 4, instead, the new approach will be presented. Using such an approach, the forecasting task is performed several times in a day so that, at each execution of the Online Replanning stage, the residual portions of the most recent forecasted profiles are considered, always in a rolling-horizon fashion. The Planning stage, instead, is kept unchanged and processes the first forecasted profile.

### *Optimization Problems Solved in the Considered EMS and Forecasting Method*

The variables considered in the optimization problems solved in the Planning and Online Replanning tasks are the power flows between couples of microgrid devices and the battery state of charge (SOC).

The objective function of the optimization problem of the Planning task is the cash flow (CF) of the end user, which can be expressed as:

$$f\_{obj}(\mathbf{x}) = \sum\_{t=1}^{N} CF\_{t} \tag{1}$$

$$CF\_t = \begin{cases} \begin{array}{c} GEPP\_t \Delta\_t \mathbb{C}\_{buy} & GEPP\_t \geq 0 \\\end{array} \\\end{array} \tag{2}$$

In the previous equation, *Csell* and *Cbuy* represent the cost of sold/purchased energy, respectively; Δ*<sup>t</sup>* is the time step duration; *N* is the total number of time steps in a day; and *t* ∈ [1, *N*] represents the time step index. The EMS tries to minimize the objective function (1) while satisfying the following set of physical and design constraints at each time step:


All the above constraints are easily translated into equality or inequality relationships among the variables of the system, i.e., the power flows between couples of microgrid devices and the battery SOC. Their mathematical formulation is reported in [11].

The solution of the optimization problem expressed by (1), (2), and the eight constraints is a vector of *N* sets of power references for the microgrid devices (i.e., one set for each time step of the next day) that imply the minimum cash flow for the end user in the whole next day. As stated before, computing the algebraic sum of the power references at each time step gives the planned GEPP, which is transmitted to the DSO. However, since forecasting is never perfect, the actual profiles of load demand and renewable generation of the next day will be different from those considered in the Planning stage. Therefore, the actual GEPP will be different to a greater or lesser extent with respect to the planned GEPP due to forecasting errors.

Aiming to reduce the deviation of the actual GEPP against the self-committed one, at each time step of the day the Online Replanning task recomputes the set of power references for the microgrid devices based on the measured instantaneous values of load demand, renewable generation, and battery SOC. It is worth observing that, in our study, battery SOC values are assumed to be measurable by dedicated subsystems. Actually, technical literature proposes numerous model-based SOC estimation techniques, such as electrochemical (ECM)-based observers; particularly, extensive discussions on the recursive Bayesian filters, including the Kalman filter, the extended Kalman filter, the unscented Kalman filter, particle filter, and other adaptive filters, such as the proportional-integral observer, the sliding mode observer, and the nonlinear predictive filter, have been proposed for the online estimation of battery SOC [33].

It is worth noting that a greedy minimization of the instantaneous differences between the actual GEPP against the self-committed one could lead to having a completely full or empty battery unexpectedly during the day. In such a circumstance, the buffering behavior of the battery would become unidirectional (i.e., only for charging or discharging); thus, the degree of freedom that is requested to null or minimize the GEPP deviation could potentially be lost resulting in very high and prolonged errors against the selfcommitted GEPP.

Therefore, the algorithm of the Online Replanning task proceeds considering the remaining duration of the day in a rolling horizon fashion and computes at each execution the set of power references not only for the current time step *t* = *i* (using measured values) but also for the following steps *t* ∈ [*i* + 1, *N*] (using forecast values). However, only the reference power values for the current time step (*t* = *i*) are sent to the controllers of the microgrid devices, whereas the other values (for *t* > *i*) are discarded. Hence, the objective function that is minimized in the Online Replanning task is the maximum absolute difference between the self-committed GEPP at time step *t* (i.e., *GEPPt*) and the actual GEPP (i.e., *GEPPt*):

$$f\_{obj}(\mathbf{x}) = \max\_{i \le t \le N} |\overline{GEPP\_t} - GEPP\_t|. \tag{3}$$

The constraints for (3) are easily obtained by modifying those of the Planning stage in the following way:


The defined optimization problems are non-linear since they involve piecewise-linear functions. They have been solved using either mixed-integer linear programming [11] (desktop PC implementation) or dynamic programming [32] (embedded implementation); this last method does not imply dependencies from third-party solvers; therefore, it is most suited to be implemented in embedded processing platforms.

As explained before, the NARX ANN is used to perform the forecasting of PV generation and load demand. It predicts the next values of a time series (e.g., load demand and solar irradiance) as a function of the observed past values of the time series and of the observed values of another variable (i.e., the exogenous input). The analytical formulation of such a function relies on the following equation:

$$y\_{t+i} = f(\mathbf{x}\_{t+o}, \dots, \mathbf{x}\_{t}, \dots, \mathbf{x}\_{t-d}, \ y\_{t}, y\_{t-1}, \dots, y\_{t-d}), \ i \in [1, o], \tag{4}$$

where *y* and *x* are, respectively, the variable to be forecast and the exogenous input of the ANN considered at a discrete time step, *d* is the delay, and *o* is the number of output units. The (vectorial) function *f* is approximated by a multilayer perceptron and, to forecast future values, the output is fed back to the network as input. More specifically, data windows from the forecasted series and from the exogenous series are fed, through a delay operator, to the input units of the ANN, which outputs a prediction for the next *o* time steps. These, in turn, are fed back to the ANN as input recursively to forecast for the desired number of future time steps. Figure 1 depicts the structure of the NARX ANN.

Further details on the structure definition and training process related to the NARX ANN are given in [32]. The hyperparameters have been reported in Section 3.

**Figure 1.** Scheme of the used configuration of the nonlinear autoregressive network with exogenous inputs artificial neural network (NARX ANN).

A previously developed forecasting module [20], based on the NARX ANN and using the TensorFlow library [34], has been used to provide updated forecasted profiles at the user's request. It is worth underlining that the forecasting module only manages the forecasting phase, whereas the NARX ANN's training is executed offline. Thanks to this feature, the forecasting task can be embedded in online calculations. Furthermore, the forecasting module has been extended to also provide profiles generated according to user-specified error formulations to allow for investigation of the different scenarios described in Section 4.

### **3. Case Study**

With no loss of generality, the analysis of the daily forecasting frequency was performed on the EMS managing a single household encompassing a direct current (DC) microgrid consisting of a PV generator, a set of electrical loads considered as a single aggregate load, a BSS, and a connection to the utility grid at the point of common coupling (PCC). As shown in Figure 2, each of these elements is electrically connected to the DC bus through a dedicated power electronic converter. Furthermore, each of these converters is coupled with a smart sensor, which is capable of sending detected data and receiving actuation commands [35]. The EMS and the forecasting module communicate with the smart sensors to manage the household grid and to store historical data. Finally, the EMS communicates with the Utility/DSO to send the self-committed GEPP.

The system considered for the study is further defined by the parameters of the EMS and of the considered energy market, reported in Table 1, and by the parameters of the electrical system reported in Table 2.

**Figure 2.** Representation of the elements of the household considered in the study.


**Table 1.** Parameters of the energy management system (EMS) and of the energy market.

**Table 2.** Electrical system parameters.


Simulations for the different considered scenarios were performed considering three publicly available datasets as measured data for the EMS, each providing a different measurement: (1) electric power consumption, (2) solar irradiance, and (3) temperature. The first dataset provides measurements of electric power consumption in one household located in Sceaux, France, with a one-minute sampling rate over a period of almost 4 years [36,37]. The second dataset contains solar irradiance measurements for the same location with a time step of one minute obtained from the Copernicus Atmosphere Monitoring Service (CAMS) radiation service [38,39]. Finally, the third dataset holds temperature measurements for the same location at one-hour intervals obtained from the Photovoltaic Geographical Information System (PVGIS) service [40]. All the datasets were resampled at a 30 min rate.

The NARX ANN used in this study for solar irradiance forecasting has an input delay equal to 7, 2 hidden layers with 20 and 10 neurons respectively and an output consisting of 1 neuron (it predicts one future time step at a time and needs 48 feedback iterations to forecast one day). As for the load demand forecasting, the used NARX ANN has an input delay equal to 7, 2 hidden layers with 30 and 20 neurons respectively and an output consisting of 12 neurons (it predicts 12 future time steps at a time, and it needs 4 feedback iterations to forecast one day).

### **4. Analysis and Results**

In this section, the analysis of the effect of daily forecasting frequency on EMS performance is presented and discussed. Starting from preliminary considerations about the dependence of forecasting performance on execution starting time during the day, some test scenarios have been defined. In particular, three alternative formulations of forecasting error trend have been proposed, against which the proposed method was compared and validated. The considered error metrics on the GEPP are the normalized maximum error (NMAX) and the normalized root mean square error (NRMSE). Both errors are normalized with respect to the maximum grid contractual power *Pxg*.

Intuitively, forecasting performance improves as new information on the considered variable is available during a day. For example, in the case of solar irradiance, as the hours of the day progress, it is clearer whether it is a cloudy or a sunny day. This intuition has been verified by forecasting the solar irradiance using the NARX ANN starting at different hours of the day and terminating at midnight (i.e., with a reducing forecasting window). As an example, Figure 3 shows such forecasted profiles for a sample day in the case of solar irradiance, and it is possible to notice that these profiles are less dispersed and closer to the measured profile when forecasting starts in the later hours. In quantitative terms, the results for solar irradiance, particularly in terms of NMAX, are shown by the metrics reported in Table 3.

**Figure 3.** Solar irradiance forecasted profiles during a sample day, starting at successive two-hour intervals.

**Table 3.** Error metrics for solar irradiance forecasting starting at successive two-hour intervals for a sample day.


On the basis of such considerations, EMS simulations have been executed for a 50-day period with different daily forecasting frequency using the same datasets and starting with an initial SOC of 80%. Specifically, the considered daily forecasting frequencies are {1, 2, 4, 8, 12, 24, 48} times a day, and four test scenarios have been considered:


The first scenario aims at evaluating the effect of different daily forecasting frequencies on EMS performance in the real application, i.e., when the EMS uses the NARX ANNbased forecasting at each invocation. The other scenarios have been devised aiming at generalizing the results obtained in Scenario 1 considering different degrees of abstraction in the formulation of forecasting errors. In particular, two aspects have been considered; on the one hand, Scenario 2 still uses the NARX ANN-based forecasting, whereas in Scenarios 3 and 4, synthetic forecasted profiles with given error metrics have been generated as described in the following section to unlink the test results from the specific forecasting method; furthermore, Scenarios 2, 3, and 4 use forecasting errors that are artificially reduced at successive invocations according to the previously verified intuition (see Figure 3 and Table 3) as described in the following section.

### *4.1. Generation of Synthetic Forecasted Profiles and Artificial Reduction of Error*

The synthetic forecasted profiles considered in Scenario 3 (high-performance generated forecasting) and in Scenario 4 (average-performance generated forecasting) are obtained, adding to the measured profiles *m* an error modeled as the sum of a Gaussian term and an impulsive term in order to impose predefined NRMSE (10% in Scenario 3 and 15% in Scenario 4) and NMAX (50% in Scenario 3 and 100% in Scenario 4) metrics. More specifically, the Gaussian term has zero mean and a standard deviation calculated as

$$\sigma = NRMSE[\max(m(t\_i)) - \min(m(t\_i))],\tag{5}$$

where *NRMSE* is the desired value of this metric. Instead, the impulsive term is calculated by sampling from a uniform distribution over the time steps of the day and adding at such steps the value of the desired maximum absolute error:

$$\varepsilon = NMAX[\max(m(t\_i)) - \min(m(t\_i))],\tag{6}$$

where *NMAX* is the desired value of this metric.

The resulting profile is clipped to zero for negative values to maintain the physical meaning of the profile. For this reason and since the pseudo random samplings are executed on a relatively small number of samples (i.e., the time steps of a day), the resulting values of the metrics slightly deviate from the desired values but nonetheless they are still a good approximation.

In Scenarios 2 to 4, the forecasting error is reduced at successive invocations within a day by progressively reducing a parameter of the forecasting error model proposed in [41]. According to such an approach, the forecasting module produces (for both solar irradiance and load demand) a forecasting once a day and artificially revises it during the day as a weighted sum of the measured profile and the initial forecasting, according to

$$F^{\text{rev}}(t\_i) = m(t\_i) + \lambda (F(t\_i) - m(t\_i)), \ \lambda \in [0, 1], \ i \in \{0, 1, 2, \dots, N\}, \tag{7}$$

where *F* is the initial forecasting, *m* is the measured profile, *Frev* is the revised forecasting, and *λ* is a weight coefficient (for *λ* = 0 the revised forecasting equals the measured profile, for *λ* = 1 the revised forecasting equals the initial forecasting). In our approach, the weight *λ* is linearly reduced during the day as

$$
\lambda = \frac{1}{(t\_0 - t\_n)}(t\_i - t\_0) + 1. \tag{8}
$$

In this way, the forecasting accuracy is progressively increased.

### *4.2. Simulation Results and Discussion*

Simulation results for Scenario 1 (real forecasting) are shown in Figure 4. It is clear that the EMS performance in terms of GEPP errors improves with the increase of the daily forecasting frequency. In particular, a reduction of 5.3% on NMAX is observed and a slight reduction of about 0.2% is noted on NRMSE.

**Figure 4.** Error metrics on the grid-exchanged power profile (GEPP) for different values of daily forecasting frequency in Scenario 1.

It is worth noting that the EMS shows a good capability in reducing the errors on the GEPP (EMS output). Additionally, for the sake of completeness, the error metrics of the forecasted load and generation profiles (EMS inputs) are given in Table 4.

**Table 4.** Total errors of load and generation forecasted profiles as seen by the planning stage of the EMS in Scenarios 1 and 2.


The GEPP metrics reported in Figure 4 are calculated over the entire 50-day simulation period; however, it is also useful to observe how the daily error evolves. As an example, Figure 5 shows the daily GEPP NMAX values for the different daily forecasting frequencies; it is possible to note that in some days the error metric reduction with increased forecasting frequency is more significant than in others.

A similar trend, i.e., error reduction for increasing daily forecasting frequency, has been obtained performing simulations in Scenario 2. In fact, the decreasing trend is clearly shown in Figure 6 and GEPP NMAX is reduced up to 16.9%, whereas GEPP NRMSE is reduced up to 1.7%.

Simulation results in Scenario 3 with an imposed forecasting NMAX of 50% and an imposed forecasting NRMSE of 10%, show a decrease of GEPP NMAX up to 13.8% and of GEPP NRMSE up to 1.2%, as depicted in Figure 7.

**Figure 5.** Daily normalized maximum error (NMAX) of GEPP on a sample week for different daily forecasting frequencies in Scenario 1.

**Figure 6.** Error metrics on GEPP for different values of daily forecasting frequency in Scenario 2.

**Figure 7.** Error metrics on GEPP for different values of daily forecasting frequency in Scenario 3.

Finally, simulation results in Scenario 4, with an imposed forecasting NMAX of 100% and an imposed forecasting NRMSE of 15%, confirm the trend of performance increase with the increase of the daily forecasting frequency as Figure 8 shows. In particular, NMAX decreases up to 24.6% and NRMSE decreases up to 1.9%.

**Figure 8.** Error metrics on GEPP for different values of daily forecasting frequency in Scenario 4.

The simulation results in all the considered scenarios show the same trend with an improvement of EMS performance with the increase of daily forecasting frequency up to 48 times a day. The observed decreasing trends could be expected based on the intuition verified with the help of Figure 3 and Table 3. However, thanks to the performed investigation, it has been found that the trends present a saturation for higher frequency values. In particular, it can be observed that in Scenarios 2 to 4 for frequencies higher than or equal to 12 times a day, the metrics almost flatten. On the other hand, in Scenario 1, the decrease of the metrics is more gradual and between the three higher frequencies considered there is an NMAX difference of 3.2%. This can be explained considering that this scenario uses real forecasting whose errors only qualitatively follow the ideal model of forecasting error decrease during the day.

Given the presence of a saturation in the error metric trends, an attempt was made to describe them by usual saturated mathematical laws, such as exponential or hyperbolic functions. However, such functions are not suitable to fit the observed trends. Furthermore, the error metric trends exhibit some outliers due to one or both the following reasons—the presence of stochastic variables (forecasting errors) and the use of nonlinear optimization algorithms. These outliers (observed in Scenario 1 and Scenario 4) do not hinder the validity of the general findings.

It is worth noting that the most significant observed result is the reduction of the NMAX metric. This implies that a more frequent forecasting execution improves the EMS capability to handle generation/demand peak errors. On the other hand, a lower but still appreciable reduction of NRMSE is also exhibited in all the scenarios.

Comparing the results obtained in the different scenarios, it is possible to observe that an increase of the daily forecasting frequency leads to a more significant reduction of the error metrics when the less performing forecasting is involved, e.g., in Scenario 4.

The consistency of the obtained results in all the considered scenarios is a key achievement of the proposed analysis since it proves the general validity of such results, under the assumption that forecasting of considered variables improves as the time of the day progresses.

Furthermore, the repetition of the forecasting task usually implies a negligible computational cost for the execution of EMS steps. As a matter of fact, in the considered case study, the forecasting task takes less than a second to produce a result, whereas the duration of the EMS time step is much higher, i.e., 30 min. Therefore, it can be executed even at each time step without impairing the EMS operation. However, in the worst case, i.e., for a very large electrical network and a very complex forecasting algorithm, the total EMS computation time could increase beyond the EMS time step; in such a case, it would not be feasible to repeat the forecasting at each time step and a tradeoff between lower forecasting frequency and higher EMS performance would be needed. Nonetheless, according to the observed trends, a modest decrease of the daily forecasting frequency with respect to once per time step would still provide a significant reduction of the error metrics.

### **5. Conclusions**

Accurate forecasting of load demand and renewable generation is a pivotal element of optimization-based EMSs in microgrids. For such a reason, beside the refinement of forecasting models, investigation on how and how often to run forecasting task within an EMS deserves attention.

This paper aims at analyzing the effect of daily forecasting frequency on the performance of EMSs used to reduce demand uncertainty in microgrids by adhering to a reference planned profile. Specifically, the paper considers a sample EMS of this kind, shows the results obtained using different daily forecasting frequencies, and generalizes such results, considering also synthetic forecasted profiles and artificial reduction of forecasting errors during the day according to a model.

In summary, the analysis showed that: (1) a more frequent forecasting execution improves the EMS capability to handle generation/demand peak errors, thus reducing NMAX error of the grid-exchanged power profile (theoretically up to 24.6%); (2) the reduction of the NRMSE is lower but still appreciable (theoretically up to about 2%); (3) the accuracy of the forecasting method affects the entity of the error metric reduction obtained with a more frequent forecasting execution; (4) the higher the daily forecasting frequency, the smaller the entity of the progressive error reduction (saturation effect).

The above considerations highlight the importance of using an accurate forecasting method and executing the forecasting task several times in a day in order to achieve the highest performance of the EMS. Finally, the repetition of such a task usually implies a negligible increase of the computational cost of the EMS algorithm while improving the EMS performance; otherwise, for very large electrical networks and very complex forecasting algorithms, a suitable compromise could be chosen by the EMS designer.

**Author Contributions:** Conceptualization, G.L.T., M.C.D.P., and M.L.; methodology, G.L.T., M.C.D.P., and M.L.; software, G.L.T.; validation, G.L.T., M.C.D.P., and M.L.; writing—original draft preparation, G.L.T., M.C.D.P., and M.L.; writing—review and editing, G.L.T., M.C.D.P., and M.L.; supervision, M.L.; funding acquisition, G.L.T. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by Italian Ministry of University and Research (MUR) grant number 2017WA5ZT3\_004, program PRIN2017, and project HEROGRIDS.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest.

## **References**

