Stochastic Optimization of Microgrid Operation With Renewable Generation and Energy Storage

—The operation of electric energy storages (EES) in power systems where variable renewable energy sources (VRES) and EES must contribute to securing the supply can be considered as an arbitrage against scarcity. The value of using stored energy instantly must be balanced against its potential future value and future risk of scarcity. This paper proposes a multi-stage stochastic programming model for the operation of microgrids with VRES, EES and thermal generation that is divided into a short- and a long-term model. The short- term model utilizes information from forecasts updated every six hours, while the long-term model considers the value of stored energy beyond the forecast horizon. The model is solved using stochastic dual dynamic programming and Markov chains, and the results show that the signiﬁcance of accounting for short-and long-term uncertainty increases for systems with a high degree of variable renewable generation and EES and decreasing dispatchable generation capacity.

Abstract-The operation of electric energy storages (EES) in power systems where variable renewable energy sources (VRES) and EES must contribute to securing the supply can be considered as an arbitrage against scarcity. The value of using stored energy instantly must be balanced against its potential future value and future risk of scarcity. This paper proposes a multi-stage stochastic programming model for the operation of microgrids with VRES, EES and thermal generation that is divided into a short-and a long-term model. The shortterm model utilizes information from forecasts updated every six hours, while the long-term model considers the value of stored energy beyond the forecast horizon. The model is solved using stochastic dual dynamic programming and Markov chains, and the results show that the significance of accounting for shortand long-term uncertainty increases for systems with a high degree of variable renewable generation and EES and decreasing dispatchable generation capacity.
Index Terms-Energy Management, Variable Renewable Energy Sources, Electric Energy Storage, Stochastic Dual Dynamic Programming, Markov Chains, Quantile Regression

I. INTRODUCTION
V ARIABLE renewable energy sources (VRES), primarily solar photovoltaic (PV) and wind, are expected to be the main electricity source in the future. The levelized cost of energy (LCOE) of solar PV and onshore wind has been been reduced by 77% and 30% respectively in less than ten years [1], and VRES stand out as a clean and competitive alternative in the electricity market [2]. Despite their relatively low LCOE, large-scale integration of VRES imposes new challenges in balancing the supply and demand. Electric energy storage (EES) technologies have taken large steps both in terms of technological improvements and cost reduction, and distributed EES will probably play an important role in balancing the electricity system.
Traditionally, the electricity system has been organized hierarchically with a relatively small number of centralized dispatchable generators operating to meet an almost inflexible demand. In contrast, VRES are to great extent distributed, weather-driven and uncertain. Moreover, the market price in today's system is often set for large geographical areas and does not capture the challenges related to distributed generation [3]. With the increasing share of distributed energy resources (DERs), a viable option is to move towards decentralized control [4] to manage the system complexity. Microgrids (MGs) offer a possible way of integrating distributed VRES and EES into the power system [5]- [7]. MGs are capable of operating disconnected from the main grid for a limited time or permanently [8], and remote areas may also be organized as MGs to avoid expensive grid expansions.
In power systems with a high share of VRES where some of the dispatchable capacity is replaced by EES, the EES must contribute to secure the supply of the peak demand. The operation of these systems can be considered as balancing dispatchable generation costs against the risk of scarcity [9]. The system's EES must be operated in such a way that they have sufficient high state-of-charge (SOC) for periods with high demand, and they should also have sufficient low SOC upfront periods with high VRES generation to minimize generation curtailment. These decisions must account for both the daily variations and uncertainty in demand and solar PV generation, as well as the variations and uncertainty in wind power generation over several days. Power and energy limitations as well as efficiencies also vary for different EES technologies. Lithium-ion batteries can deliver and absorb high power with low losses, but for a limited time due to energy limitations. For hydrogen EES (electrolyzer and fuel cell), the size of the hydrogen tank can be scaled up at modest cost, while the electrolyzer and the fuel cell are expensive to scale up and have poor round-trip efficiency compared to lithium-ion batteries [10]. The combination of power and energy limitations, efficiency losses, and uncertain generation and demand makes the operation optimization problem highly complex.
Rule-based energy management has been successfully applied for managing DER, both for experimental systems [11]- [13] and virtual systems [14], [15]. These rule-based methods charge/discharge the respective EES based on fixed SOC thresholds and predefined priorities, and their computational performance makes them well suited for integration in a realtime environment. However, they do not utilize knowledge about expected future generation and demand from forecasts.
Information from forecasts can improve the operation strategy by formulating dynamic optimization problems with either deterministic or stochastic generation and load forecasts. The resulting generation, EES charge/discharge and export/import or SOC can be used as a reference to a real-time control system where the system is re-optimized using rolling horizon each time when either the forecast or observed state is updated [16]- [18].
Stochastic dynamic programming (SDP) approaches [19] also account for how the uncertainty is revealed stage-wise, and the operation strategy can be adjusted stage-wise as more uncertainty is revealed. Instead of providing an optimal control, it provides an optimal policy which is a set of decision rules on how to respond to a given state at a given time. The storage marginal value (SMV) obtained from the SDP solution also has a useful interpretation with respect to deciding when to use the different EES opposed to generators using constant marginal cost principles [20].
Operation of EES is in reality an infinite horizon optimization problem, and this is particularly important when studying systems where EES must be used to prevent extreme prices from, for example, periods of scarcity. A common way to avoid the EES from being emptied at the end of the optimization period is to apply a bound on the end SOC, typically for daily planning [21]- [23]. However, this approach is unnecessarily inflexible and prevents utilization of the flexibility beyond the optimization horizon [24]. Solar PV and wind power both have distinct seasonal variation, hence the operation method should also be verified through a whole year as in [14], [15], but these only consider rule-based approaches.
Existing literature often studies EES' capabilities to minimize thermal power generation and reduce CO2 emissions, but very few papers considers how EES should be operated if they must contribute to preventing extreme prices and scarcity. The valuation of stored energy beyond the optimization period has therefore gained little attention. However, research on largescale hydropower has paid more attention to infinite horizon optimization both with SDP [25] and stochastic dual dynamic programming (SDDP) [26].
This paper presents a multi-stage stochastic programming (MSSP) model that accounts for the uncertainty in forecasts and beyond the forecast period. The forecast uncertainty is managed with scenarios generated using gradient boosting quantile regression. The optimal operation beyond the forecast horizon is determined by solving a separate long-term model. The long-term model uses a cyclic Markov chain [26] to represent infinite horizon, and the value of stored energy at the end of the short-term model is given by the cutting planes from the long-term model.
The stochastic short-term model is compared with a deterministic point forecast model and a no-forecast model. The long-term model is compared with fixed SMV. All combinations of the proposed short-and long-term models are tested on data from an actual MG using rolling horizon optimization and simulation for almost a full year.
The remainder of this paper is organized as follows: Section II describes the method, section III presents and discusses the results from the application of the method, while section IV provides the conclusions.

II. METHOD
The optimal energy management of a small-scale power system can be considered as the decision process of meeting a system energy demand using the existing resources with the lowest marginal operating cost. The marginal cost of dispatchable generators is mainly given by the fuel and emission costs, while VRES has marginal operating costs close to zero. The value of lost load (VOLL) represents the cost of not being able to meet the demand, and is normally assigned a high value [27]. However, the marginal value of charging/discharging an EES will vary between zero and the VOLL since the energy charged to an EES can originate from VRES, and the discharged energy can prevent lost load [20].
MSSP will be used to derive a storage end value (SEV) description and a corresponding SMV as a function of both time and state. Results from the proposed SMV description will be compared to using a fixed SMV, which is a commonly used method today [11]- [15]. Furthermore, the value of utilizing meteorological weather forecasts will be investigated by comparing the results of the no-foresight case with both deterministic point-forecast and stochastic forecast for demand and VRES generation. The perfect foresight result is also provided as a reference.

A. Multi-stage stochastic programming
The operation of an MG with EES and VRES can be modelled as an MSSP model. At each stage, new uncertainty is revealed and a control decision is taken. The solution of an MSSP model is therefore not a sequence of controls, but rather a sequence of decision-rules, often referred to as policies, on how to respond to a given state and for the revealed uncertainty. This is an important difference from multi-scenario (and deterministic) formulations where the optimal control is obtained by assuming perfect foresight for each individual scenario, not accounting for the opportunity to correct the control when more uncertainty is revealed.
The MSSP model variables can be classified into state x t , control u t and random variable ω t . The objective is to find a set of admissible controls (1c) that minimizes the expected stagewise operating costs for all stages (1a). The state transitions function (1b) describes how the state changes for a given control u t representing decisions taken both explicitly and implicitly, and the random variable ω t . The operating cost C t represents the cost accrued in the current stage, while the expected future cost is the cost associated with optimal future decisions.
The resulting problem formulation is an optimization problem with nested expected values of optimization problems, and where the random variable ω t at each stage depends on ω in all previous stages. The size of the extensive problem becomes too large to solve even for problems of modest size. MSSP models are therefore commonly solved with dynamic programming, where the full problem is decomposed into a sequence of stage-wise problems.

B. Stochastic dual dynamic programming
This paper considers SDDP [28] for solving the proposed MSSP problem. SDDP requires a convex problem formulation [29] and stage-wise independent random variables. Similar to SDP, SDDP divides the full problem into smaller stagewise problems, and approximates the future cost for each stage using backward recursion. In contrast to SDP where the state space is discretized, SDDP utilizes a convex problem formulation and approximates the future cost iteratively using multiple linear cutting planes which serve as a lower bound to the future cost. A common approach to managing the stagewise dependent random variables, are by modelling them as state variables using an auto-regressive model [30]. These can be both additive and multiplicative [31] depending on the random variable properties, but require a linear model formulation. This paper instead uses a combination of SDDP and SDP with Markov chains [32]. The sequence of stages and the corresponding Markov states can be described with a policy graph [26] as illustrated in Fig. 1, where R denotes the policy graph root node: Each node is associated with a stage representing a discrete moment in time, and a Markov state which captures states not included in the state variable x i . The matrix φ represents the transition probability between nodes in such a way that φ ij is the transition probability between nodes i and j. The children of node i is denoted i + where i + = ∅ for leaf nodes.
Given that all future decisions are optimal from a given node and onward, the optimal decision for a previous node can be found with backward recursion using Bellman's principle of optimality [33] by reformulating the objective in (1a) as shown in (2a).
By using the recursive formulation in (2a), the complex problem in (1a) to (1c) can be decomposed into a graph of smaller optimization problems, which has a very interesting interpretation for storage models. The first term C i is the stagewise operating costs, in this case diesel and load shedding, while the SEV i (x i ) is the value of the stored energy given perfect future decisions. Just like the marginal operating cost of a generator is given by the derivative of the cost function with respect to generation (3), the SMV is given by the derivative of the SEV with respect to the state (4).
The SMV depends on both the state variable x, and stage and Markov state given by Markov node i, and it can be used to determine how valuable energy stored in an EES is compared to other EES and to dispatchable generators.
The SDDP training algorithm can be divided into two phases as shown in Algorithm 1: forward and backward pass. In the forward pass, a random sequence of nodes i 1 , . . . , i N is sampled from the Markov model, and a random scenario ω i ∈ Ω i is sampled for each node. The Markov model can also represent infinite horizon by incorporating a discount factor ρ < 1 to ensure that the future value produces a finite sum. For the example illustrated in Fig. 1, the outgoing edges from node (2,1) and (2,2) will each sum up to ρ [26]. The algorithm also enforces a maximum number of subsequent nodes as shown in the termination criteria in the first loop in Algorithm 1. For each sampled scenario, the optimization problem (5a) to (5e) is solved, the node, and outgoing state are appended to S, and the next incoming state is updated with the outgoing state. When a random scenario has been simulated through all stages, the backward pass can start. For each node in the sequence i 1 , . . . , i N , V K j (x, ω j ) (5a) to (5e) is solved for all outgoing nodes j ∈ i + and all scenarios ω j ∈ Ω j . The expected objective and the expected state dual value are used to calculate a new cut for the current node i.
In contrast to SDP where the entire state space is explored, Algorithm 1 Forward and backward pass [26].
j,ωj to the optimal objective value setλ K j,ωj to the value of λ j in the optimal solution end for end for end for SDDP only explores the states based on sampling of from the uncertainty distribution.
Algorithm 2 SDDP Forward simulation [26]. set x 1 = x R , n = 1, i 0 = R while i + n−1 = ∅ do sample i n from i n−1 + sample ω n from Ω i n set u n = π i n (x n , ω n ) set c n = C i n (x n , u n , ω n ) set x n+1 = T i n (x n , u n , ω n ) set n = n + 1 end while

C. Optimization period
This paper considers the energy management of a smallscale power system. The optimization period is divided into a short-term and a long-term model to reduce the computation time of the short-term model. The short-term model considers the period with available generation and demand forecasts, and the long-term model the time beyond the horizon of the forecast. The long-term model is solved first and the SEV function is extracted as cuts. The short-term model is then built using load and generation scenarios generated from weather forecasts, and SEV function from the long-term model to set the outgoing SEV. The short-term model will then find an efficient operations strategy which also accounts for the value of storing energy beyond the foresight of the weather forecast. To verify the effectiveness of the proposed model, the shortterm model is evaluated based on historical observations. The short-term model is updated every time a new weather forecast is available in a rolling horizon manner. The long-term model is updated monthly based on the expected generation from wind and solar PV, and the expected demand. The split of the horizon into two models also allows the possibility to handle larger cases than demonstrated in this paper.

D. Quantile regression and transition probability
Generation forecasts for the short-term model are determined based on meteorological weather forecasts from the Norwegian Meteorological Institute with a 60-hour foresight updated every sixth hour. Let ψ t+k|t denote the weather forecast for time t+k issued at time t. The goal is to find a set of scenarios Ω t+k = f (ω t−i , ψ t+k|t , k) given previous observations and forecast variables. Unfortunately, it is difficult to include the look-ahead as an explanatory variable in a linear model as the product of two variables is not allowed. Linear models will therefore require a separate regression model for each look-ahead value k [34]. Gradient boosting (GB) is a machine learning technique that can be used for regression by forming an ensemble of weak decision trees [35], [36]. Moreover, GB is not limited to linear combinations, hence the look-ahead can be used directly as an explanatory variable. All training data can therefore be used to fit one model instead of an individual models for each k. This approach will therefore be less dependent on having a large training data set compared to linear regression. The regression has been performed with MLJ.jl (0. 16 using a least square regressor, while scenarios are generated using quantile regression. Let ω α i denote the α quantile of a random variable at node i, andω i an observed value, then P (ω α i ≥ω i ) = α. Moreover, let E[ω α i ] and E[ω i ] denote the mean value of the respective quantiles and the observed values over time. The observed values at the node i are then in the j'th quantile interval if The quantile regression model is trained using historical weather forecasts as explanatory variables and the actual generation as the outcome variable. For each historical forecast, the outcome variable is classified into quantile interval and the number of transitions between the quantile intervals is counted. Let the matrix Φ denote the transition counts such that Φ ij denotes the number of transitions between quantile interval i and j, then the resulting transition probability matrix φ are given by φ ij = Φij n k=1 Φ ik . The resulting quantile intervals compared to the point forecast and observed wind power is shown for a random interval in Fig. 2.

E. Long-term model
The long-term model uses 24-hour scenarios which are representative for each day of the year. The SDDP algorithm is typically run from a known initial state. In this case, the outgoing state of the short-term model that is the incoming state of the planning is not known ahead, hence the initial Markov state and state variable value are randomized to ensure the solution space at the connection point of the longterm model is sufficient explored by the algorithm. Since the problem is, in reality, an infinite horizon problem, a cyclic Markov model is used [26]. The cyclic Markov model permits transition from the nodes representing the final stage back to nodes representing previous stages, in this case 24 hours back, with probability ρ cyclic = 0.8. This will represent an infinite horizon with a discount ρ cyclic and prevents the EES' from emptying after 24 hours.
1) Wind power: The main purpose of the long-term model is to predict net power balance over several days. Wind power is the dominant energy source and also has an evident autocorrelation. The long-term model assumes constant daily wind power generation using five scenarios. To find the scenarios, the 24-hour mean values of historical wind power observations are sorted and divided into intervals of relative size 0.1, 0.2, 0.4, 0.2, 0.1. Each interval represents a scenario where the generation is given by the interval's 24-hour mean value. The corresponding transition probabilities are obtained using the method described in section II-D.
2) Solar PV power: Clearness index (CI) is a number between 0 and 1 and gives the ratio between solar PV power generation and the maximum generation at that particular time. The CIs are calculated for the historical observations where hours with zero generation are neglected to avoid zero division. The mean daily clearness indexes are sorted and divided into three equally sized intervals. The mean value for each interval is used as the CI for the long-term model scenarios. The autocorrelation has not been considered to keep the number of Markov states sufficiently low, and since wind is the dominant power source.
3) Demand power: The demand scenarios are generated using quantile regression with the hour of day and the month of year as explanatory variables. The scenarios are given by the 0.1, 0.5, 0.9 quantiles with probability 0.2, 0.6, 0.2.
F. Short-term model 1) Wind power: The ratio between wind speed and power generation is non-convex [39] and has increasing variability with increasing wind speed [31]. Wind power scenarios are generated using the 0.1, 0.3, 0.5, 0.7, 0.9 quantiles, each with 0.2 probability. The quantile regression model is fitted using the following explanatory variables: wind power forecast at turbine height, wind speed forecast, wind direction forecast, look-ahead hours and last observed power before the forecast period.
The wind speed v ref is forecast at a reference height h ref which usually differs from the turbine height h turbine . Therefore, the turbine wind speed v turbine is scaled using the power law profile [40] shown in (6).
The roughness factor k, is an empirical value for the roughness of the terrain around the wind turbine. Transition probabilities are obtained as described in section II-D.
2) Solar PV power: Solar power explanatory variables are: cloud area fraction forecast, normalized maximum solar power, initial solar power and look-ahead hours. The normalized maximum solar power represents the theoretical maximum generation for that time of day and year as a number between 0 and 1. There are theoretical methods for determining this value given the geographical location, and the panel direction and tilt. Since panel angle and direction as well as seasonal configurations are unknown for the case used here, the normalized maximum solar power has been approximated using historically observed generation by assuming the normalized maximum solar power is given by the maximum observed value at that day and hour plus/minus nine days for all observed years.
3) Demand power: The demand will use the same regression model as the long-term model described in section II-E3.

G. Simulation
To verify the value of the different optimization strategies, historical observations are simulated with rolling horizon. The short-term model policy is updated each time a new forecast is available. For each observed value, the corresponding node i is identified based on the Markov state and stage, and the optimal control is found by solving (5a) to (5e). The optimal control u and the resulting state x are saved, and the procedure is repeated for the next stage using the previous outgoing state as the incoming state.

H. Mathematical description
This section summarizes the mathematical description of generators, demand, EES and objective. Dispatchable generators can adjust the generation between zero and maximum generation continuously (7), while the VRES generators have uncertain time varying upper bounds given by weather conditions (8). The demand is uncertain and load shedding can be applied if the system has insufficient capacity (9). Power can be injected and withdrawn from the EES at constant efficiency (10a), but the SOC limits must be respected (10b) and the charge and discharge power must stay within their limits (10c) and (10d). In grid-connected mode, the system can exchange power with an external market within the transmission limits (11a) and (11b). The power injected and withdrawn must be balanced at all time (12). The objective is to minimize the cost of dispatchable generation, net import and load shedding (13).
The mathematical description above is repeated for each node i. Incoming state x i is the initial SOC soc e,t−1 for the first time step in the node, and the outgoing state x i is the SOC soc e,t for the final step in the node. The random variable ω t includes the maximum VRES generation (8), such that VRES can be freely curtailed at no cost, and the demand (9).
I. Reference models 1) Perfect foresight: The perfect foresight model uses the mathematical model description from section II-H but optimizes the whole period at once with the actual historical generations and demand instead of using forecasts. The SEV at the end of the optimization is set using the fixed SMV described in section II-I3.
2) Deterministic rolling horizon model: The deterministic model formulation uses the same mathematical model description presented in section II-H as the stochastic model, but with least square point forecasts instead of multiple scenarios.
3) Rule-based model: Rule-based models [11]- [13] uses a fixed priority for generators and EES to decide where to withdraw lacking or inject surplus energy. Given an arbitrary EES e with charge/discharge efficiency η c e /η d e and SMV CE e , then the cost of discharging one unit will be CEe η d e , hereby referred as discharge cost. The corresponding value of charging one unit, the charge value, will be CE e η c e . If the EES SMV is chosen in such a way that the discharge cost is less than the diesel generation cost, the EES will be used to meet the demand before the diesel generator. Likewise diesel will not be used to charge the EES as long the charge value is less than the diesel cost, and the EES given most value will be charged first when there is surplus VRE generation.
The cases with fixed end value will use SMV 80 e/M W h for both EES. Since the charge value is less than the marginal cost of the diesel generator, both of the EES will only be charged when there are surplus VRES generation. The discharge value of the battery is less than the diesel generator marginal cost or the grid purchase price, hence it will displace diesel generation or import whenever possible. However, the discharge value of hydrogen is higher. Consequently, it will only be used to prevent load shedding.

J. Implementation
The proposed method has been implemented in the programming language Julia (1.4.2) using the toolbox SDDP.jl (0.3.14) [41] and Gurobi (9.1) for solving the stage-wise linear optimization models. The long-term models were trained with 1000 iterations, and the short-term models with 100 iterations. To simulate the proposed case, 1350 short-term models were trained and simulated in 4-5 hours while the training time for 12 months of the long-term model was around 1.5 hours on a laptop with Intel i7-8650U CPU and 16 GB RAM.

K. Case study
Rye microgrid is located in Central Norway near Trondheim and is partly funded by the Horizon 2020 project REMOTE [42]. The MG comprises a farm and a few residential houses, and the electricity is supplied by solar PV panels and a wind turbine [43]. The turbine height and the reference height are 30 and 10 meters respectively, and the roughness factor is set to 0.3 considering the wind turbine is partially surrounded by forest [44]. There is also a lithium-ion battery and a hydrogen storage unit with an electrolyzer and a fuel cell to balance the load and generation. A diesel generator serves as backup when the VRE generation is persistently low. The generation capacities are 86 and 135 kW for solar PV and wind respectively. The import price and diesel generator operating cost are both 100 e/MWh, while the sale price is 50 e/MWh. The VOLL is 5000 e/MWh. The EES numerical values are presented in Table I. Diesel and wind power generation capacities in this study have been reduced from the original system to increase the probability of scarcity. This choice is made to study the impact of EES operation strategies in critical periods of the year where EES are needed to prevent load shedding. Time series for historical observed generation and load, and historical weather forecasts can be downloaded from [45].
The system has sufficient VRES power generation in the long run, as shown in Fig. 3a. However, Fig. 3b shows that there is a significant weekly variability, especially for the wind power, that must be balanced with EES. For an average daily load above 20 kW, a fully charged lithium-ion battery can meet the load for maximum 24 hours, while a full hydrogen tank can meet the demand for around 80 hours. If the dispatchable generation capacity is low, it is crucial to have sufficient stored energy in the EES to prevent load shedding. The analysis period is between 2020-01-01 and 2020-12-09.

A. Operation strategy
The main goal is always to meet the demand using the least expensive energy source due to the high load shedding cost. VRE generation with zero marginal cost is always preferred if available, while the priority between the diesel generator and EES varies and is given by the EES SMV. The SMV represents the marginal value of adding a unit of energy to an EES at a specific time, and is a function of the SOC of all EES in the system as well as the wind state, and shows how to optimally operate available generation, import and export capacity. Fig. 4 illustrates the resulting strategy based on SMV for hydrogen (a) and battery (b) with 15kW import/export capacity. The corresponding boundaries for the SMV are given in the legend where C p and C s represents the market purchase and sale prices. Fig. 4 shows that it is optimal to use available import capacity to charge the EES when the SOC is sufficiently low. For slightly higher SOC, the optimal strategy is to import instead of using stored energy such that the stored energy is saved for potential future situations with risk of scarcity. When the SOC is sufficiently high, the stored energy should be used to meet the demand, while when the SOC is close to maximum the energy should be exported to prevent potential generation curtailment.
This interpretation of the strategy is actually a set of rules similar to the rule-based approaches [11]- [15]. However, the resource priorities are updated based on both expected generation and demand as well as the SOC for all EES and the system wind states. A similar strategy can be extracted from the short-term strategy giving even more accurate rules that also considers the short-term generation and load forecasts. Additionally, This makes the proposed method suitable for integration towards real-time systems.

B. Simulation of historical observations
The optimal operation of almost a full year with historical data is summarized in Table II for three conditions of the system and seven different methods. The outgoing SOC is shown in the table, but the value of it is not included in the costs.
The dispatchable generation capacity of 75kW of the cases 1-7 is always sufficient to meet the peak demand. The difference in operating cost between the different methods originates from diesel consumption. The fixed end value of the cases 2-4 is conservative and prioritizes hydrogen for load shedding prevention, which results in a poor utilization of VRE compared to the cut end values from the stochastic model. By also considering the forecast uncertainty in case 4, the VRES utilization increases considerably. The stochastic cuts of cases 5-7 adjust the strategy both with respect to SOC, wind state and time of the day and the year, and position the SOC such that surplus generation can be absorbed efficiently.
Given perfect information (case 8), it is also possible to fully prevent load shedding with a 15kW diesel generator by starting it upfront to ensure sufficient energy in the system's EES before periods with low VRES generation. The operating costs are actually slightly less than for case 1 due to lower final hydrogen SOC. Storing only the surplus VRES generation, as indicated by the fixed SMV strategy, is not sufficient to prevent load shedding (cases 9-11). It is evident that utilizing information from weather forecasts improves the operational strategy, and the load shedding can be almost eliminated with cut end values (cases [12][13][14]. Cases 11 and 14 also show that it is possible to both reduce load shedding while still keeping the diesel consumption low. Also note that case 12 has a high utilization of wind and solar compared to 14, but still higher operating costs. This is because the lack of forecast imposes rapid cycling of the hydrogen storage resulting in high efficiency losses, while the stochastic model has less frequent cycling of the hydrogen storage and less losses. By replacing the diesel generator with a grid connection with equal capacity, the surplus generation can be exported. The export price is set to half of the import price, for example due to grid tariffs. The value of using stochastic forecasts and stochastic end value is even more pronounced here. The stochastic forecast methods (cases 18 and 21) have both the lowest load shedding and the highest export compared to the equivalent deterministic and no-forecast cases. Cases 19 and 21 also have higher outgoing SOC than the corresponding fixed end value cases (16 and 18) making them better prepared to prevent future scarcity.
The snapshot from case 21 in Fig. 5 shows positive import although the net generation (VRES minus demand) is positive. If the SOC is sufficiently low, it is important to increase the SOC to prevent potential future load shedding. This is also in reflected in the long-term strategy shown in Fig. 4.
Although the results originate from a small-scale power system, they are also relevant for large-scale power systems. To reach net zero emissions towards 2050, 63% of the energy will originate from VRES with 74% of the total generating capacity [46]. The high share of variable and uncertain generation makes prevention of scarcity and extreme prices increasingly important. The stored hydro-dominated Nordic power system which has been operated as a competitive market where the price has been influenced by the risk of scarcity since the early 1990s [47] shows that this is a feasible direction.

IV. CONCLUSIONS
The work presented in this paper shows the importance of accounting for uncertainty in power systems when more of the dispatchable generation capacity in autonomous systems is replaced by VRES and EES. The proposed multi-stage stochastic programming model has demonstrated a reduction in the operational costs associated with import, export and thermal generation while at the same time increasing the security of supply for the presented isolated microgrid compared to a deterministic point-forecast model and a noforecast model. The results show a 70% cost reduction when using the stochastic model compared to a deterministic pointforecast model with fixed storage end value for the weakly grid connected system, where 95% of the improvement originates from reduction in load shedding. The model is also able to export excess energy without while keeping the risk of load shedding low. The benefits of the proposed model were most significant for weakly connected systems and systems with low dispatchable generation capacity.
Managing generation and load uncertainty is particularly important in microgrids where stored energy rather than installed capacity is the limiting factor in supplying the load in critical periods. Realistic and robust scheduling models are a key component in the efficient and secure operation of systems with a high share of VRES and EES.

A. Future work
Possible steps towards a more applicable model could be to add more details such as: generation cost curves and efficiency as a function of charge/discharge for EES, EES degradation costs, start/stop costs for generators and EES, as well as power flow equations. The proposed improvements will impose new challenges with respect to convexity which can be handled both with convex relaxations and integer variables, and by using stochastic dual dynamic integer programming as solution method [48].
The use of discrete Markov states to represent uncertainty has clear limitations with respect to dimensionality. Adding new types of random variables yields an exponential growth in problem size, but can be overcome either with principal component analysis to reduce the dimensionality, or by using a linear model formulation of the random variables.