Weather-Driven Predictive Control of a Battery Storage for Improved Microgrid Resilience

This paper aims to introduce a predictive weather-based control policy for the microgrid energy management to improve the resilience of the microgrid. This policy relies on the application of machine learning models for the prediction of microgrid load demand and solar production and supply interruption in the upstream distribution network. The predictions serve as an input to multiobjective chance constraint optimization that balances the microgrid resilience and economic objectives based on the probability of a supply interruption. The interruption predictions are made with a decision-tree-based model that can predict an upcoming interruption in the distribution network with 78% of the maximum accuracy. The case study microgrid consisting of several customers, solar photovoltaic generation, and battery storage is applied to cluster areas located in Finland. Overall, the developed control policy shows an improvement in the daily resilience of the microgrid in regard to an interruption in the main grid when compared with economic dispatch only.


I. INTRODUCTION
The use of distributed energy resources (DERs) has recently been increasing especially in microgrids (MGs) as they are known to improve the reliability of electricity supply in sparsely populated areas and contribute to the reduction of greenhouse gas emissions [1]. As the integration of DER and household loads increases, maintaining the power system stability and voltage profile as well as management of energy resources in a cost-effective way become more challenging [2]. Microgrids are capable of operating in two different modes: either grid connected or island. While operating in the grid-connected mode, the power is exchanged with the main grid from the distribution feeder, which ensures the power dispatch and contributes to the system stability. In case of power faults, natural disasters, or not meeting power quality requirements, the MG will operate in the island mode. In this mode, battery energy storage systems (BESSs) are used to cover load energy consumption [3]. The BESSs depend on installed load power and have several limitations, such as power rating, Boolean charging/discharging scenarios, and time-dependent energy content dynamics.
During MG operation, a BESS improves resilience during operation in the island mode. Resilience is a relatively new concept in power systems, and in recent years, it has had a significant impact on the definition of the reliability of electricity distribution networks [4]. The definition proposed by [5] involves energy systems being able to recover fast from events caused by external factors. Moreover, the definition provided by [6] for resilience relies on four aspects: foresee/avoid, absorb/withstand, respond/restore, and adapt/upgrade. These elements play a key role in the function of MGs for the modernization and decentralization of electricity grids.
Many strategies to manage the power and improve the re- VOLUME 4, 2016 silience of MGs have been proposed in the literature [1], [7], [8]. These strategies combine predictive models for optimal dimensioning of the BESS based on the DER power infeed forecast of photovoltaics (PVs) and wind turbines and control methods to maximize resilience when operating in the island mode and to maximize energy profits from energy dispatch [9]- [11].
Renewable energy in MGs brings new challenges in terms of how to deal with uncertainty in power generation. In [12], uncertainty quantification is used to facilitate integration of an energy storage and thereby mitigate the impacts of uncertain PV and wind generation. The array of prediction techniques is also growing as artificial intelligence algorithms and optimization methods are being developed. One of such techniques is reported in [13], where forecasting of solar radiance, temperature, and load is carried out in addition to particle swarm optimization to optimally control and manage power in an MG.
Although resilience in microgrids has been a topic of growing interest in the past few years with an exponential increase in publications, to the authors' knowledge, the application of predictive methods has been limited. An approach that uses outage decision-making for power management in smart homes is reported in [14]. Outage management can benefit MGs, which are very prone to interruptions, as well as remote areas of difficult access. In [15], a multilevel MG method is proposed that incorporates a stochastic islanding event into the operational optimization, thereby allowing to foresee the occurrence of interruptions. The model can be adopted for optimal scheduling by applying the uncertainty of loads, DER, demand-side management, and frequency control.
The traditional concept of reliability has also been shifting toward resilience to take into account more characteristics of power grids; still, as discussed in [16], [17], reliability plays an important role in grid management and brings certain benefits to the grid. In [18], these benefits include minimization of load curtailment, flexibility, and improvement in the reliability index. In their paper, the authors propose a general framework for the assessment of the reliability of distribution systems with multiple microgrids to quantify the impact of different operating schemes by using a model predictive control for power management. In [19], the authors develop a resilience-oriented stochastic scheduling method for microgrids considering economic metrics; the resilience index is improved by 16.5% by integrating resilience metrics, stochastic planning, and resilient operation of DER into the method. Further, in [20], a microgrid scheduling strategy is developed considering resilience requirements: operating costs, energy purchasing costs, and degradation cost of the BESS. The solution uses an optimization model ensuring resilience by facilitating possible MG interruptions by securing load supply and robustness in DER.
BESSs have shown efficacy to increase resilience in MGs, and to this end, correct sizing to meet the economic requirements is an important task. In [21], the authors use a linear optimization approach to determine the most cost-effective BESS sizing for different types of load and DER generation. In the optimization, it is necessary to use historical data and accurate forecast resources for DER. Insights into the obtained power-to-energy ratio can also enhance the design of new commercial BESSs, which could possibly benefit and standardize other MG systems.
A similar approach as presented in this paper can be found in [22], where the authors use a home energy storage management system for decision-making. This system enhances home resilience in the face of extreme events. The model decides in advance when to charge the BESS based on the condition of the network and the probability of an outage. The interruption model takes into account the wind speed to provide the probability of an interruption for the location; however, in the case of extreme events there might be also other variables involved. Our approach considers a set of different variables, and by using machine learning techniques, we are able to reliably predict an interruption for the next day, thereby improving the battery state-of-charge (SOC). Furthermore, the model is scalable to the size of the MG or the area of interest, being thus not limited to a single MG but being applicable also to multiple microgrids and large areas. This can greatly improve the resilience in the system to be able to withstand upcoming severe weather interruptions.
In this paper, a weather-based predictive control policy is used to improve the resilience of an MG when operating in the island mode. This method can predict the energy requirements for the BESS and schedule day-ahead optimal operation of the BESS based on predictions of machine learning models for load demand and solar PV power production. The proposed methodology takes into account the probability of an interruption for the prediction horizon based on weather conditions so that any decision taken beforehand to charge/discharge the MG battery will have a profound impact on the MG resilience when operating in the island mode. This will contribute to the MG decentralization paradigm, because the total output power supply from the main grid and the power from the DERs connected to the affected MG will be maximized. The contributions of this paper are: • formulation of multiobjective optimization problem under uncertainty for an MG BESS that takes into consideration the interruption probability and economical charging and thus foresees upcoming island operating modes; • methodology for machine learning predictions of the probability of a daily supply interruption in the upstream distribution network, microgrid load demand, and solar PV production that are integrated into the optimization problem; • introduction of a daily dependency (resilience metric) for the MG that continuously estimates the withstanding capability of the MG in the face of extreme weather events; The rest of the paper is organized as follows. In section II-A, we analyze previous approaches to resilience and optimization in microgrids. The methodology of the proposed approach is presented in Section II. The predictive interruption model and the machine learning model are described in Section III. Section IV addresses the techno-economic dispatch optimization problem for microgrid energy management. A case study MG placed in the clusters of the interruption model, results, and discussion are summarized in Section V. Finally, conclusions of the paper are presented in Section VI.

A. BACKGROUND OF RESILIENCE
The resilience framework introduced in this paper is based on a model proposed by [23]. In this context, to improve the resilience of an MG, we use the blocks shown in Fig.  1. The four pillars of MG resilience are: methods, attributes, interruptions, and metrics. The first block, methods, refers to a variety of methods or techniques that contribute to the improvement of resilience, the ones used in this work including resource allocation, battery scheduling, energy optimization, fault prediction, and load and production predictions. In the second block we find attributes, which are the properties or characteristics of an MG. Understanding of the system attributes of any MG, such as islanding capacity, is important as these attributes play a significant role in the decisionmaking concerning microgrid components. These decisions, in turn, have a direct or indirect impact on the system recovery. In the third block there are interruptions. Here, external events are assumed to be weather dependent and influenced by the grid topology next to the MG connection. Finally, for the assessment of the MG we use one common metric in resilience: dependency [24]. It is an index that means "a linkage or connection between two infrastructures, through which the state of one infrastructure influences or is correlated to the state of the other." This is a key attribute when using a battery storage, and in this work, it is adopted in order to quantitatively characterize dependency in each of the MG load by measuring the need for energy storage to achieve the resilience objective. First, we introduce an analogous availability measurement [24], which measures individual resilience of a load as where T U is the time up (microgrid is connected to the main grid) and T D is the time down (microgrid disconnected from the main grid). T U is directly related to the withstanding capability, whereas T D is the service recovery speed, which is influenced by cyber-physical processes and human-driven activities (e.g., maintenance, repair, availability of human resources). Then, analogous to Eq. (1), the degree of dependency of a load, and for the context of the MG, that of the entire MG load, R L , is given by: where T S is the energy capacity stored in the MG BESS, measured by autonomy when entering the island mode, and u is the equivalent rate of the power grid, inverse to T D . The interdependency of battery and resilience is seen in Eq.
(2). It shows that the BESS makes the MG more resilient to disruptions.

B. MICROGRID MANAGEMENT ROUTINE
The Methods block in Fig. 1 contains the elements of load prediction, interruption prediction, DER generation prediction, and BESS management. According to the control policy depicted in Fig. 2, the algorithm starts at day 1 at an interval of a day (from start to end) to analyze the resilience, and an scheduling based on the weather forecast models is made for the next 24 h. Based on the weather conditions, a coefficient for the probability of an interruption is calculated from the forecast model for the probability of interruption. To prepare for an eventual island mode, the MG and the BESS have to VOLUME   be scheduled based on the future output of the DER and load power estimation; the models described in Sections III-A and IV-A provide details of both steps. Once the day is over, the daily dependency is calculated as presented in Section II-A. This process can be continuously checked and updated on a daily basis. Fig. 3 shows the impact of a varying BESS SOC (or analogous T S ) on whole-year runs (n S ); the figure illustrates MG management without considering any prior cost-effective or precautionary charging of the BESS, which is seen as sudden fluctuations from day to day. The values are within a range that depends on the resilience index calculation period (a day) and T S . The dependency index metric is usually calculated based on historical data, and thereby, average T U . When this metric is calculated on a daily basis, it will show a significant difference when compared with a method that does not take the interruption model into consideration because of variability in the charging of the BESS.

III. PREDICTIVE MODELS A. RISK ANALYSIS OF THE PROBABILITY OF AN ELECTRICITY SUPPLY INTERRUPTION
The data provided by the Finnish DSO Elenia were used to predict the daily fault occurrence in the distribution networks of the following regions: Kanta-Häme and Päijät-Häme, Pirkanmaa, Central Finland, and Ostrobothnia. First, we defined clusters comprised of Elenia's substations so that the maximum distance between substations in a cluster was not larger than 50 km. Agglomerative hierarchical clustering, specifically complete-linkage clustering implemented in the scikit-learn library [25], ended up with 31 substation clusters, to which the MGs are connected in our study. Fig. 4 presents the clusters obtained and their centroids in the ETRS-TM35FIN coordinates. Additionally, the figure shows the weather stations closest to Elenia's network. The original data contained 36874 unique faults that occurred in the whole network of Elenia between January 2011 and December 2013. Faults associated with substations were summed up for the corresponding clusters with a daily time resolution. An additional categorical variable indicating the absence or presence of faults per day was introduced for each cluster. These binary variables worked as outcomes in the cluster fault prediction. Next, we created a set of predictors that included weather observations and time variables (see Table  1). The coordinates of the weather stations presented in Fig. 4 were used to collect historical weather observations from [26]. We transformed the coordinates into the WGS84 system and retrieved the data applying the package wwo − hist [27], [28]. For each cluster, the weather observations were gathered and averaged over the weather stations closest to Elenia's substations. The set of input variables included 14 predictors similar to the previous study [29].
Predictive models were built separately for each cluster.  The data collected in 2013 were reserved to test the models, whereas fault records from 2011 and 2012 were included in the training. As a learning algorithm, we chose Random Forest because of its useful properties: the ensemble-based nature aims to reach robustness and control overfitting [25], [30]. To reduce the model variance, we trained 250 trees in each ensemble. The maximum tree depth was tuned for each cluster: when varying the tree depth from 3 to 9, we selected one model trained on the data from 2011 that showed the highest accuracy on the validation data from 2012, and then switched around the training and validation years to select one more model. The outcomes of these two models on the test data were averaged to obtain the final estimate of the fault probability. Besides, to avoid tuning a cut-off for each cluster where the balance between days with and without faults differs, we oversampled the underrepresented class in the training years 2011-2012. As a result, 0.5 cut-off was applied within all clusters when estimating the model accuracy.
According to the previous study [29], the weather observations relevant to predicting faults are contained in a few recent measurements. Therefore, we tested one-, two-, and three-day historical weather as the model inputs and found that when predicting faults for the moment t, the weather observations from the moment t and t-1 led to the highest maximum accuracy across clusters, i.e., 78%, and the highest number of clusters with the accuracy exceeding 70%, i.e., ten clusters. In the real use case scenario, historical weather observations should be substituted with the weather forecast. The resulting accuracy of the test data is presented in Fig. 4. Wind direction (sine) 6 Wind direction (cosine) 7 Dew point temperature,°C 8 Snow depth, cm 9 Air pressure, mb 10 Horizontal visibility, km 11 Cloud cover, % 12 Month (sine) 13 Month (cosine) 14 Day of the month (sine) 16 Day of the month (cosine)

B. MACHINE LEARNING MODEL FOR LOAD AND SOLAR PV PREDICTION
The time series predictions of the load and solar PV production of the microgrid are required for the operation management of the microgrid BESS. Here, point forecasts (i.e., conditional mean of the predictive distribution) are produced for the next day with a 24 h ahead horizon and implemented with a Light Gradient Boosting Machine (LightGBM) regression [31] from the corresponding library [32]. The Light-GBM model is a scalable and efficient gradient boosting framework that uses a decision-tree-based learning algorithm. In fact, the high accuracy of the LightGBM model was recently demonstrated in the M5 Accuracy competition [33].
The main difference of the model compared with the similar algorithms is the usage of a leafwise tree growth algorithm instead of the depthwise tree growth. This approach facilitates model convergence because of the faster finding of the best split points in each tree node but comes with higher chances for overfitting, i.e., poor generalization for unseen testing data. For instance, the unconstrained maximum depth and number of leaves can improve the training accuracy but also contribute to overfitting. Therefore, hyperparameter tuning is important to achieve a good model generalization with the LightGBM model. In this study, we apply a tree-structured Parzen estimator from the hyperopt library [34] to search for the hyperparameters affecting the model accuracy and overfitting. In particular, for the LightGBM model we tune the learning rate, the number of boosting iterations (i.e., the number of trees to build), the maximum number of leaves in one tree (i.e., the maximum number of nodes per tree), and the maximum depth for a tree model (i.e., the maximum distance between the root node of each tree and a leaf node).
The tuning is carried out with the hyperparameters presented in Table 2 using 500 iterations. The target data for load demand represent an aggregated load of 29 customers from one Elenia secondary substation located in central Finland. The solar PV production data were retrieved from the same location using hourly PV simulations with the renewable-ninja platform [35]. The solar PV is simulated using the MERRA-2 (global) dataset for a system with 30 kWp installed capacity and 10% loss, the system facing south (azimuth angle 180°) and inclined from the horizon with a tilt angle of 35°. Fig. 5 illustrates the target series, both of which have an hourly resolution for the year 2013. Following the concept of weather-dependent operation of low-carbon power systems, we base our predictions solely on historical weather observations and time features presented in Table 3. The weather observations are obtained using open data of the Finnish Meteorological Institute [36].
The error of the point forecast for hour h on day d is estimated by the deviation between the actual observation y h,d and the predictionŷ h,d = f (X h,d ) as follows: The performance evaluation of the model is carried out using k-fold cross-validation with k=12 folds separated per a particular month of a year. In such an arrangement, the model is trained using 11 months of a year and tested on an unseen month. Such a validation is repeated for each month.
To quantify the statistical quality of the forecasts for all fold data, the metric of Mean Absolute Error (MAE) is employed: where D · H is the number of points for the evaluation equal to the number of hours per year. The lower the MAE, the better the model accuracy. Wind direction (cosine) 9 Dew point temperature,°C 10 Snow depth, cm 11 Air pressure (msl), hPa 12 Horizontal visibility, m 13 Cloud amount, (1/8) 14 Hour (sine) 15 Hour (cosine) 16 Day of the week (sine) 17 Day of the week (cosine) 18 Day of the month (sine) 19 Day of the month (cosine) 20 Holiday (binary) The results of the model performance are demonstrated in Table 4. The average point forecast error is close to 3 kW for the load demand and close to 2.5 kW 1 for the solar PV production. However, similar to the fault prediction, the historical weather observations should be substituted with the weather forecast data for the real use case. Besides the values of point prediction, an optimization method in Section IV-A requires a covariance matrix of expected errors to produce stochastic scenarios. This covariance matrix is obtained for each target time series using post-hoc residual simulation; i.e., relying on the corresponding model prediction errors:  where each row of the error matrix represents an hour of a day, and each column a single daily observation. A covariance matrix Σ ∈ R H×H is then derived from the testing error matrix of all folds as follows: where is the variance of the marginal distributions of the prediction errors for look-ahead hours h i and h j . The covariance matrix illustrates the interdependence structure of prediction errors for each forecast horizon. For instance, Fig. 6 shows the examples of the target covariance matrices with a positive covariance between the prediction hours for both prediction targets. The positive covariance means that the prediction errors at two hours tend to increase or decrease in tandem. The covariance pattern has a distinct concentration along the diagonal line, especially marked for the peak hours of load demand and midday hours for solar PV production. Therefore, the model has difficulties in correctly predicting the target values at those hours. However, the covariances sharply decrease with an increase in distance from these forecast horizons.

IV. MICROGRID ENERGY STORAGE MANAGEMENT A. OPTIMIZATION PROBLEM
The operation management of the MG aims to produce a BESS schedule for the next day using convex stochastic optimization with chance constraints, i.e., constraints that are required to hold with a high probability. The convex optimization problem is described with an objective in Section IV-A1 and a list of constraints in Section IV-A2.

1) Objective function
The objective function of the optimization problem considers a trade-off between cost reduction and outage prevention goals: outage prevention (8) subject to (19) − (29) power balance and DER operational constraints where λ ∈ [0, 1] is a weight coefficient that is equal to the probability of an outage occurrence, f Op is an objective containing the operating costs of devices, and Ef Rel is an approximated expectation of the reliability of the supply objective. Intuitively, the higher the probability of an outage is, the more weight is given to the reliability of the supply goal. Otherwise, the optimization prioritizes the cost-effective load shifting with the BESS, e.g., by charging the BESS when the grid energy is cheap and discharging when it is expensive. f The electricity costs are formed by selling the electricity to the grid and buying it from the grid, as well as assuming that the prices for the exported electricity C ex t are often lower than the prices of the imported electricity C im t from the grid [37], i.e., C im t ≥ C ex t , ∀t ∈ T : where p t is the power scheduled at the PCC of the MG [38] during the metering period ∆t. The MG purchase electricity price C im t (C/kWh) consists of the electricity network service charges C nsc ( C/kWh), the price of electrical energy, and the electricity tax C etax ( C/kWh). Here, the price of electrical energy is based on the wholesale market prices C ws t (C/kWh) and a retail margin. The network service charges and the market price include a value added tax (VAT, 24%). Finally, the purchase electricity price is formulated as follows: The MG electricity selling price C ex t consists of the wholesale market price C ws t (without VAT) and a network service charge for the feed-in generation C fic ( C/kWh): The degradation cost of the BESS during the operation is included by penalizing excessive charge-discharge cycling with a coefficient β as follows: VOLUME 4, 2016 where p b d,t is a decision variable of scheduled battery storage power, C inv is the investment cost of the BESS ( C/kWh), n cyc is the estimated lifetime in equivalent cycles, and DOD max is the maximum allowed depth of discharge (DoD). In addition, other market-related components can be added to the objective function, such as revenue from the provision of a BESS for the frequency regulation service [39]. This BESS application is especially demanding for a lowcarbon power system with an increasing share of renewable generation.
The availability of self-supply and battery storage capacity enables the MG to withstand the outage event in the upstream grid by switching to island operation. In that case, the reliability objective function is formulated using expected energy not supplied (EENS), i.e., the amount of the net demand unsupplied by local resources during the outage: where [·] + ≡ max[·, 0] is the elementwise ramp-up function, ∆t is the metering period, C ens is the unit cost of the energy not supplied, and p out t is the unsupplied net demand during an outage. In such a formulation, we consider an equal probability of an outage to happen at any hour of a day. The unsupplied demand at time t is calculated based on the local demand p load d,t , supply p solar d,t , and available active power p b,sup t of the BESS as follows: is the available active power in one time step if the BESS energy capacity e b t at time t is emptied at a constant power over the next τ max time periods with a self-discharge rate α and a discharge loss coefficient η [38]. The unknown variables (i.e., solar PV production p solar d and load demand p load d ) are specified as normal random variables p ∼ Normal(p, Σ) using the predicted mean and covariance matrix of prediction errors from Section III-B. The expectation of the reliability of the supply objective Ef Rel containing these random variables is then computed using scenario-based sample average approximation (SAA): where p b d serves as an optimization variable, whereas p solar d,i and p load d,i are random variables with i = 1, . . . , N scenarios that are drawn using the Markov chain Monte Carlo (MCMC) method.

2) Constraints and component models
The MG network power flow is described using a static direct current (DC) power flow formulation. The static setting of power flow assumes that the power flows are constant over the metering time interval, typically equal to one hour, whereas the DC formulation leaves out the reactive power flow and voltage phase angles. The network contains devices d ∈ D (e.g., generators, loads, storages, and power converters) that have one or more terminals providing a bidirectional power flow 2 . Here, the internal MG network structure is neglected assuming a single bus connection of all devices without connecting lines. The reasoning for such a simplification given in [40] concludes that an MG network with a limited capacity and proximity of devices does not typically provide the limiting constraints but complicates the formulation. Therefore, following the formal notation in [41] to describe the problem, a single bus of the MG is described by the net illustrated in Fig. 7. The net exchanges power between terminals of devices and guarantees power conservation over the connected terminals (i.e., the sum of the terminal powers is zero). The power balance in the net of the MG with M terminals in each time period can be expressed as follows: where p d,t is the scheduled power at time t ∈ T of a device at the connected terminal. The devices modeled in the MG network include a grid tie, a renewable generator, an aggregated fixed-power load, and a lossy BESS. The grid tie is a single-terminal device modeled as a generator and representing a connection to an external power grid. The renewable generator is a single-terminal device that produces power, i.e., its terminal power p d,t satisfies p d,t < 0. Similarly, the fixed load is also a single-terminal device that consumes a fixed amount of power p d,t > 0. The power values at the terminals of the generator and the load devices correspond to the mean forecasts of production and demand of these devices. The lossy BESS is formulated as a composite device by connecting a constant-efficiency power converter that models the charge and discharge losses of the BESS and a storage with self-discharge losses. The internal energy state e b t ∈ R + of the BESS is expressed as: where α is the (per-period) leakage rate limited by 0 < α ≤ 1, and ∆t is the time interval between time periods. Furthermore, we constrain the energy charge of the BESS at the beginning and end of every optimization cycle to 50% of the available energy capacity of the BESS E b : which enables to decouple the results of daily experiments. The useful energy capacity is then limited by: The charge and discharge rate is limited by the restricted p and maximum p powers of the BESS as follows: The power converter is a two-terminal device that transfers power at a certain efficiency. The conversion efficiency in the forward and reverse directions η ∈ (0, 1) for terminals 1 and 2 is characterized by: We approximate these nonconvex constraints with their convex hull: Similarly, typically nonconvex chance constraints are computed with conservative approximations [42]. Here, we apply chance constraints to the unsupplied net load demand: where γ is a high probability. With this constraint, we target the probability of a deficient power balance during an outage to be less than 1 − γ.

3) Implementation details
The optimization problem is formulated and solved using a collection of Python-based software packages for convex optimization, namely cvxpy [43], cvxpower [41], and cvxstoc [42], where cvxpy is a modeling language for convex optimization problems; cvxpower provides a declarative language for describing and optimizing power networks; and cvxstoc is a modeling framework for specifying and solving convex stochastic programs. We use 100 Monte Carlo samples for an approximation of the expression expectation and the chance constraints. The chance constraint probability is equal to 95%. The simulation data are selected to represent the real-life operating environment of the MG. The wholesale market price is retrieved for the Finnish bidding area for the year 2019 using Nordpool's historical market data. The static values of the electricity tariff are taken from actual retail tariffs and Elenia's distribution tariffs. The characteristics of the BESS are chosen based on the peak load demand of the MG and interpolation of the reference scenario for the development of the parameters of a stationary LiFePO 4 BESS to the year 2021 [44]. The charging/discharging efficiency of the BESS is 96%, the battery investment cost C inv is 378.64 C/kWh, and the number of equivalent life cycles n cyc is 10 4 cycles. The leakage rate of 0.1% of the BESS capacity per day is equally distributed among T time periods and applied at any time t as α = 0.001/T . With the allowed DoD of 90 %, the marginal cost of the battery degradation β is 0.021 C/kWh. The maximum number of time periods for the expected duration of outages τ max is determined from the relation of BESS energy capacity to nominal power and equals 1 and 2 hours. The unit cost of the demand not supplied consists of the unit cost for the amount and duration of unexpected interruptions in Finland, which are together equal to 12.1 C/kWh [45], and the profit loss from the distribution fees C nsc not received. This value for the duration of unexpected interruptions is given in the 2005 value of money and is not adjusted using the consumer price index. All the static cost data used in the optimization are provided in Table 5. The implementation source codes and some real-world historical data are available online 3 . Four test scenarios are considered for the operation management of the MG: economical, reliable, uncertain, and perfect foresight. The former two assume the usage of the BESS solely for the objective functions of cost reduction (i.e., λ = 0 in Eq. (8)) or outage reduction (i.e., λ = 1 in Eq. (8)), whereas the latter two are described by Eq. (8) with the predicted (i.e., uncertain scenario) and known (i.e., perfect foresight scenario) outage probability λ. Importantly, the chance constraint is not applied for the economical scenario. The objective functions in Eq. (8) are normalized for the uncertain scenario using weighted min-max normalization [46] applied to prosumer flexibility modeling in [39]. For instance, in the case of the cost reduction objective, the minimum value is acquired from the economical scenario, whereas the maximum is derived from the reliable scenario. The same logic holds for the outage reduction objective.

A. TEST SCENARIOS
In this paper, we used real interruption data obtained from several substations in Finland. For the sake of simplicity, the MG was theoretically placed at the centroid of fault clusters where the interruption data were obtained to produce fair results. The scenarios chosen are the five clusters with the best accuracy and the one with the lowest accuracy from Fig.  4 as follows: • Cluster 1: highest accuracy cluster ≈ 78% • Cluster 2: accuracy cluster ≈ 75% • Cluster 3: #1 accuracy cluster ≈ 73% • Cluster 4: #2 accuracy cluster ≈ 73% • Cluster 5: accuracy cluster ≈ 72% • Cluster 6: lowest accuracy cluster ≈ 56% Each cluster prediction is used independently for the optimization as explained above in Section IV-A.

B. RESILIENCE
The daily resilience metric calculated using Eq. (2) for the year 2013 is shown in Fig. 8  economical approach (predicted); considering only the economical approach (economical); the reliability model approach (reliable); and faults to be known (foresight). The daily resilience metric gives a granular view of how the prior knowledge of the operational behavior of the microgrid can enhance the MG resilience over a period of time. We analyzed the faults in the region under study and found that 2 h for T D explains more than 90% of the interruption time for outages occurring in the region, and T U = 24 − T D , because the daily index analysis covers a period of 24 h. The variation seen in the daily resilience illustrated in Fig. 8 is due the variation in the load and in the energy stored in the battery. Fig. 8 presents a comparison between the abovementioned approaches between clusters 1 and 6 (the highest and lowest accuracies). Fig. 8 shows how the combination of economical and predicted approaches faults yields a better dependency and thus, the microgrid is more resilient to upcoming events by having more energy available when a fault occurs. The above-discussed trade-off maintains a balance that results in a more robust grid but also considering the energy prices. From only the economical perspective, there is a significant decrease in dependency when faults occur for that specific day, thereby reducing the resilience. Furthermore, Figs. 8b and 8d show how increasing the value of the battery storage enhances the dependency index for all approaches.
A closer look at the all-year-round dependency for the approaches is analyzed in Fig. 9: the economical and foresight approaches are very similar having a lower adjacent value smaller than the other two approaches and more outside points. Moreover, the dependency data for the economical approach is more distributed on the axes meaning that it is not dependent on resilience. The reliable and predicted approaches follow a resilient strategy and thereby a narrow distance between adjacent values. Their medians are almost the same but have variations in the first and third quartiles with the predictive one having greater values closer to 1. There is no difference between clusters for the economical approach because it does not consider interruption data, whereas for the other approaches the difference is almost negligible because of the smaller discrepancies in the interruption accuracy.
The violin plot shown in Fig. 10 contains the plots of the dependency index based on a 24 h ahead horizon and calculated hourly for five days (five without faults and five with faults) for five clusters with a higher accuracy. The scenarios plotted were the economical approach and the proposed predictive approach. We can see that when a fault occurs in these two scenarios, the proposed approach becomes slightly more conservative, thereby narrowing the upper and lower adjacent values and maintaining the median at higher levels of dependency. The economical approach does not VOLUME 4, 2016 distinguish a possible upcoming fault event, meaning that the lower adjacent value is smaller. The tendency of the proposed predicted approach to be more conservative with the available energy shows an increase in the resilience especially for the days that have a high probability of a fault occurrence. The scenario plotted in Fig. 10 considers 2 h of energy available in the battery.

VI. CONCLUSION
Preparation of a grid against severe fault conditions is one of the least investigated actions to take account of when increasing the overall resilience in an MG. The reason behind this is the unpredictable and probabilistic nature of these events. In this paper, weather-based decision-making for charging a BESS in an MG was developed. The methodology includes three different models: interruption prediction, load demand, and solar PV production forecast. We were able to effectively predict an upcoming interruption in the system with 78% accuracy and thereby implement a multiobjective chance constraint optimization to schedule the microgrid battery storage according to the prediction. The proposed optimization approach takes into consideration two objectives: resilience to possible supply interruptions and economic dispatch so that we can guarantee a safe and economical operation of the grid.
We also proposed daily quantification of the resilience metric of dependency, which measures on a daily basis the energy stored in the BESS revealing for the day ahead how independent the MG will be from the main grid. We showed that when compared with the economical, reliable, and foresight approaches, our control policy can improve the overall resilience for short and long periods of time in regard to an interruption in the main grid so that the MG operates in the island mode. When calculating the resilience index in our proposed approach, the probability of the occurrence of a fault determines whether we can prepare the MG for the upcoming events. Fault data are not usually available for all places where microgrids are located or they are designed to be built; this is due to companies' polices that prevent the data being shared, or data are simply nonexistent for the region. The more data are available, the more precise are the outcomes from outage models, meaning better results in the MG resilience. Having this type of data, we can see from our approach that a trade-off between an economical and resilient MG can be possible by employing multiobjective BESS optimization. An overall resilience improvement can only be achieved by correctly assessing the framework cycle and its individual pillars described in detail in the paper.
In summary, using interruption and economic dispatch ensures that the microgrid does not operate oversized when there is no risk of a fault occurrence and that it also enters into a hardening state, which increases the amount of energy stored in the BESS in the case of a high probability of a fault occurrence, thereby supplying energy for longer periods when operating in the island mode.
MIKKO KOLEHMAINEN graduated from the Helsinki University of Technology in 1987 with software engineering as his major subject. He has received his PhD (D.Sc.Tech.) from the same university in 2004. During his career, he has first worked as system analyst and chief software engineer in the software industry, developing solutions for energy companies. In the 90's he has moved to the academic world working as researcher both in bioinformatics and environmental sciences, followed by a nomination to research director of environmental informatics; a new and emerging field. Currently as a professor, he is leading the research group of environmental informatics at the University of Eastern Finland. Since 2001, the research group has been carrying out industry related projects using Artificial Intelligence methods to solve data based problems related to the environment. Professor Kolehmainen has also worked as a CTO of a start-up company helping the companies to utilize the AI in their operation. He was the chair of ICANNGA'09. He is currently a Postdoctoral researcher with LUT University, Lappeenranta, Finland, in the research group "Cyber-Physical Systems Group." His research interests include renewable energy-based smart microgrids, electricity distribution and markets, demand-side management, energy management systems, and information and communications technology. He focuses on applying optimization, computational concepts, and artificial intelligence techniques to renewable electrical energy problems. He is currently a professor (tenured) of energy markets at LUT University. His present research interests are related to business and market models for integration of distributed energy resources in energy markets. Prof. Honkapuro has been active in academic research related to electricity distribution business and electricity markets for over 15 years.
PEDRO H. J. NARDELLI received the B.S. and M.Sc. degrees in electrical engineering from the State University of Campinas, Brazil, in 2006 and 2008, respectively. In 2013, he received his doctoral degree from University of Oulu, Finland, and State University of Campinas following a dual degree agreement. He is currently Assistant Professor (tenure track) in IoT in Energy Systems at LUT University, Finland, and holds a position of Academy of Finland Research Fellow with a project called Building the Energy Internet as a large-scale IoT-based cyberphysical system that manages the energy inventory of distribution grids as discretized packets via machine-type communications (EnergyNet). He leads the Cyber-Physical Systems Group at LUT and is Project Coordinator of the CHIST-ERA European consortium Framework for the Identification of Rare Events via Machine Learning and IoT Networks (FIREMAN). He is also Adjunct Professor at University of Oulu in the topic of "communications strategies and information processing in energy systems". His research focuses on wireless communications particularly applied in industrial automation and energy systems. He received a best paper award of IEEE PES Innovative Smart Grid Technologies Latin America 2019 in the track "Big Data and Internet of Things". He is also IEEE Senior Member. More information: https://sites.google.com/view/nardelli/