Assessing the Value of Demand Response in Microgrids

: This paper presents a computer application to assist in decisions about sustainability enhancement due to the effect of shifting demand from less favorable periods to periods that are more convenient for the operation of a microgrid. Speciﬁcally, assessing how the decisions affect the economic participation of the aggregating agent of the microgrid bidding in an electricity day-ahead market. The aggregating agent must manage microturbines, wind systems, photovoltaic systems, energy storage systems, and loads, facing load uncertainty and further uncertainties due to the use of renewable sources of energy and participation in the day-ahead market. These uncertainties cannot be removed from the decision making, and, therefore, require proper formulation, and the proposed approach customizes a stochastic programming problem for this operation. Case studies show that under these uncertainties and the shifting of demand to convenient periods, there are opportunities to make decisions that lead to signiﬁcant enhancements of the expected proﬁt. These enhancements are due to better bidding in the day-ahead market and shifting energy consumption in periods of favorable market prices for exporting energy. Through the case studies it is concluded that the proposed approach is useful for the operation of a microgrid.


Introduction
Environmental and social sustainability concerns have driven the transition of power systems from a paradigm of natural monopoly to a market paradigm guided by the objective of liberalization, free access to the grid, and deregulation [1][2][3][4], which are part of the contemporary paradigm of the electricity sector. Although the transition has had technical and economic implications for the management of an electric grid, centralized production is still seen in large power plants, usually in association with extensive lines for delivering energy to geographic sites with a large population. Therefore, it is expected that the distribution grid will have a more active role in the future, which remains an opportunity to be explored since an essentially passive attitude has been exercised [5]. Thus, a more active attitude towards the distribution grid is also expected, through production from distributed energy resources that try to ensure local energy sustainability, including the possibility of energy exporting. A contemporary electric grid should have systems that offer the intelligence of a smart grid [6,7].
The indiscriminate integration of distributed energy resources presents challenges for the safe management and control of power systems [5]. In the context of ensuring local energy sustainability, including the possibility of exporting energy, the best way to take advantage of the potential of production from distributed energy resources is through the approach of a power system that considers production and a set of loads as a subsystem of the power system itself. Therefore, production sources and loads are market, the consideration of a stochastic methodology to deal with the uncertainty of electricity market prices and fluctuations in the power of non-dispatchable sources is of significant relevance. The application of hybrid methods has been suggested for applications in microgrid planning. The advantage of these methods lies in the potentiality of combining two or more methods, taking advantage of the potential of each one for delivering more satisfactory microgrid planning.
Deterministic methodologies for the energy management of microgrids considering demand response are the core of the applications in [20,21]. In [20], the application is an energy management system for a building that includes loads, renewable sources, energy storage devices, electric vehicles, and demand response strategies. The goal is to minimize the daily cost due to the consumption of energy. The problem is formulated by the framework of mixed-integer linear programming (MILP). In [21], the application is an operational planning of a microgrid, including microturbines, a photovoltaic (PV) system, and an energy storage system to help satisfy thermal and electrical loads, with an overall objective of minimal operating cost. The proposed model has demand response strategies for both thermal and electrical consumptions. The MILP formulates the problem and the results show a reduction in cost due to the demand response strategy.
Stochastic methodologies for energy management of microgrids considering demand response are the core of the applications in [22][23][24][25]. In [22], the application is an optimal planning of a microgrid with wind generators, microturbines, fuel cells, energy storage systems based on batteries, and loads. The objective is to maximize the aggregator's profit in an electricity market environment. The framework of the stochastic programming problem formulates the problem with a reformulation as a MILP problem. The uncertain parameters are wind power, day-ahead market prices, and loads. The number of scenarios after a reduction in the original set of scenarios is 100. The results show that the implementation of the demand response is favorable for the aggregator. In [23], the application is an instance of operation planning for a microgrid participating in electricity markets, namely in the day-ahead market and the reserve market. The microgrid includes several distributed energy resources, namely, diesel generators, wind generators, a PV system, and a battery. The microgrid has residential, commercial, and industrial loads subjected to demand response programs. The objective is to minimize the operation cost of the microgrid under uncertainty related to wind power and PV power. The results show that the application of demand response programs can reduce the cost of operation of the microgrid and lead to a more energy-efficient use. In [24], a stochastic methodology is applied to a planning operation of a distribution grid consisting of renewable and non-renewable sources, energy storage devices, electric vehicles, and loads, including the possibility of implementing demand response. The distribution grid managed by the aggregator participates in the electricity market, buying or selling energy. The uncertainty in the problem is due to PV and wind power, electric vehicles, loads, and market prices. The objective is the minimization of the cost of operation of the microgrid, and the final problem is a reformulation as a MILP problem. The conclusion favors the stochastic methodology in comparison to the deterministic one. In [25], a planning operation is proposed for a microgrid consisting of microturbines, wind generators, a wind system, and energy storage devices and fuel cells. The microgrid is in an electricity market and implements strategies for demand response. The objective is to minimize the operation cost of the microgrid. The problem is a stochastic programming problem reformulated as a MILP problem. The uncertainty is related to market prices and the power of renewable sources. The initial number of scenarios goes through a reduction to achieve a reasonable number of scenarios. The conclusion favors demand response to achieve a further reduction in the operation cost of the microgrid.
Heuristic and hybrid methods for energy management of microgrids considering demand response are instances of applications in [26,27]. In [26], an approach based on a particle swarm optimization algorithm addressing the operation of households with the objective of minimization of the electricity usage operation cost shows that the proposed approach contributes to supporting the addressing of favorable decisions. In [27], an in-Sustainability 2021, 13, 5848 4 of 16 stance of an approach offers planning for the operation of a microgrid participating in the electricity day-ahead market. The approach includes treatment for uncertainty in prices of the day-ahead market, PV power, energy demand for traditional loads, and demand for electric vehicles. There are 5000 scenarios describing the uncertainty, generated by Monte Carlo simulation and subsequently subjected to a reduction to deliver 500 representative scenarios. The objective is the minimization of the operation cost of the microgrid using demand-side management strategies, namely demand response, in a formulation based on a stochastic programming problem. The algorithm used to solve this type of planning implements several heuristics, namely variable neighborhood search, differential evolution, and particle swarm optimization. A comparison shows that the proposed planning presents advantages over other heuristics.
The main contributions of the work are as follows: • The development of a computer application based on a formulation of the problem as a stochastic programming problem for assisting decisions about sustainability enhancement due to demand response in microgrids. In this paper, the application of stochastic programming allows the consideration of the uncertainty of wind power, PV power, loads, day-ahead market prices, and imbalance prices. Most of the research considers some of these parameters as deterministic. This paper overcomes this issue.

•
The presentation of several case studies capable of assessing the performance of the microgrid in the presence of increasing levels of demand response. Specifically, the analysis of the effect of demand response on the energy balance of the microgrid, on the energy offers, on the energy consumption profile, and the expected profit.

Problem Settings
Historical data of energy demand enables the extraction of patterns of information to support the forecast of energy demand. However, as well as renewable production, energy demand is a source of uncertainty in the electrical system due to the random instantaneous usage of energy exhibited by consumers [28]. The change in demand affects the distribution of energy spontaneously, for instance: an increase in demand, not foreseen, requires a timely response from costly units that are sufficiently quick, either spinning reserve or energy storage systems. Issues that can contribute to the change in energy demand include electricity prices, weather conditions, renewable production, and major social events. Thus, an area with high growth potential in an electricity market environment is demand response based on stimuli, namely the prices of electricity markets. Demand response is a program that encourages consumers to reduce energy consumption during peak hours and increase consumption during off-peak hours or periods of high energy production. Demand response allows for a reduction in electricity bill cost and an increase in the operating efficiency of the entire electrical system, both technically and economically. Usually, demand response programs are based on subsidized tariffs, due to the flexibility that ensures the grid. A microgrid is an indispensable part of the paradigm shift regarding electrical efficiency and maximization of profit, which requires a mathematical model that fits these factors in electricity markets. Thus, in this work, it is considered that part of the energy that is required in the microgrid in a given period can be consumed in a more economically favorable period. Electrical efficiency may imply a shift of energy consumption to periods when energy is abundant and cheap and the microgrid aggregator must have a convenient strategy for persuading consumers to agree on deferring the usage of energy.

Approach Proposed
In this paper, the microgrid has the following equipment: wind and PV systems, microturbines, energy storage, and loads, and some are flexible loads. As usual, the losses in the electric lines of the microgrid are negligible to assist decisions about sustainability enhancement because of shifting demand. The objective is the maximization of the expected profit of the microgrid participating in electricity markets. The problem for-mulation is in the framework of a stochastic programming problem reformulated as a MILP. The consideration of stochastic programming allows a convenient way to model uncertainty in the management of the microgrid by considering a set of realizations of the uncertain parameters, i.e., the scenarios. The combination of all realizations of the uncertain parameters results in the scenario tree of the problem. Then, the initial set of scenarios is reduced. Optimal energy bids in the day-ahead market, optimal operating points of the equipment of the microgrid, and the expected profit are obtained from the proposed approach based on two-stage stochastic programming. The proposed approach based on two-stage stochastic programming has the advantage of consideration of the uncertainty of wind power, PV power, loads, day-ahead market prices, and imbalance prices, in contrast to the deterministic one. The flowchart of the proposed approach is shown in Figure 1.
In this paper, the microgrid has the following equipment: wind and PV systems, microturbines, energy storage, and loads, and some are flexible loads. As usual, the losses in the electric lines of the microgrid are negligible to assist decisions about sustainability enhancement because of shifting demand. The objective is the maximization of the expected profit of the microgrid participating in electricity markets. The problem formulation is in the framework of a stochastic programming problem reformulated as a MILP. The consideration of stochastic programming allows a convenient way to model uncertainty in the management of the microgrid by considering a set of realizations of the uncertain parameters, i.e., the scenarios. The combination of all realizations of the uncertain parameters results in the scenario tree of the problem. Then, the initial set of scenarios is reduced. Optimal energy bids in the day-ahead market, optimal operating points of the equipment of the microgrid, and the expected profit are obtained from the proposed approach based on two-stage stochastic programming. The proposed approach based on two-stage stochastic programming has the advantage of consideration of the uncertainty of wind power, PV power, loads, day-ahead market prices, and imbalance prices, in contrast to the deterministic one. The flowchart of the proposed approach is shown in Figure  1.

Problem Formulation
The condition usually assumed for no market power is the point of view followed for the formulation of the short-term microgrid optimal planning of the aggregator in this paper, i.e., the aggregator is not able to exercise influence on the prices by manipulating the offers, and consequently, the problem is as follows: subject to: Figure 1. Flowchart of the proposed approach is shown. X 12,000.

Problem Formulation
The condition usually assumed for no market power is the point of view followed for the formulation of the short-term microgrid optimal planning of the aggregator in this paper, i.e., the aggregator is not able to exercise influence on the prices by manipulating the offers, and consequently, the problem is as follows: subject to: Sustainability 2021, 13, 5848 The parameters and variables of Equations (1)-(35) are defined in Table 1. In (1) is the statement of maximization of the objective function, having the following terms, respectively: the cost/income for purchasing/selling energy in the day-ahead market, the income from selling excess of production in the balancing market, the cost due to the purchasing of deficits of energy in the balancing market, the cost for wind power, the cost for PV power, the variable cost for the microturbines, the start-up cost for the microturbines, the cost for shut-down of microturbines, and the income from the selling of energy to the consumers. In (2) are the constraints for the maximum values of bidding in the day-ahead market. In (3)-(5) is the model for the representation of energy deviation, given by two non-negative deviations [28]. In (6) is the equation of energy balance, with the left side assigned to the available power in the microgrid and the right side to the energy that comes out of the microgrid. In (7)-(13) are the constraints for the variable cost of the microturbines given by a piecewise linear function [29,30]. In (14)- (17) are the constraints for the output power and the maximum available power of the microturbines [29,30]. In (18)- (21) are the constraints for the minimum downtime of the microturbines [29,30]. In (22)- (25) are the constraints for the minimum uptime of the microturbines. In (26) and (27) are the constraints for the binary variables modeling start-up, shut-down, and online/offline of microturbines [29,30]. In (28)-(33) are the constraints for the energy storage system. In (34) and (35) are the constraints for implementing demand response if allowed by the end-users. The problem above can be structured in blocks as follows: In the above structure, Expected profit, Bid, Energy deviation, Energy balance, Microturbines, Energy storage, Demand response are the main blocks for the short-term microgrid optimal planning and matters for further research.

Case Studies and Results
As usual, the condition of no market power is assumed for the aggregator of the microgrid. The total generation power is 12.4 MW, and the total load is 8.0 MW. The maximum purchase power in the electricity market is 5.0 MW and the maximum selling power in the electricity market is equal to the total generation power of the microgrid.
The electricity tariff established by the aggregator of the microgrid for flexible loads is reduced by 12% over the estimated price of electricity on the day under consideration, i.e., the aggregator offers a cost reduction from 0.062 $/kWh to 0.054 $/kWh on the road to persuade the end user to consent to flexible loads. Data for the microturbines and energy storage system are in [31]. The scenarios of the uncertain parameters are in [32-34], and are 6, 10, 8, 5, 5, respectively, for the day-ahead market price, the positive/negative imbalance prices, the wind power, the PV power, and energy demand. Therefore, the initial set of scenarios has 12,000 (6 × 10 × 8 × 5 × 5) scenarios.
The program modeling language and the solver for implementation of the case studies are, respectively, GAMS and the CPLEX 12.1 run on a 3.6 GHz processor with 16 GB of RAM. A scenario reduction from 12,000 to 1000 scenarios by the GAMS/SCENRED fast-backward reduction method package is at the beginning of the program execution performed to reduce the computation time.
The parameters of power segments and slope for the piecewise linear function modeling the variable cost per hour are in Table 2.  The scenarios considered for day-ahead market prices and positive and negative imbalance prices [32] are, respectively, in Figure 2a

Case Studies and Results
As usual, the condition of no market power is assumed for the aggregator of the microgrid. The total generation power is 12.4 MW, and the total load is 8.0 MW. The maximum purchase power in the electricity market is 5.0 MW and the maximum selling power in the electricity market is equal to the total generation power of the microgrid.
The electricity tariff established by the aggregator of the microgrid for flexible loads is reduced by 12% over the estimated price of electricity on the day under consideration, i.e., the aggregator offers a cost reduction from 0.062 $/kWh to 0.054 $/kWh on the road to persuade the end user to consent to flexible loads. Data for the microturbines and energy storage system are in [31]. The scenarios of the uncertain parameters are in [32-34], and are 6, 10, 8, 5, 5, respectively, for the day-ahead market price, the positive/negative imbalance prices, the wind power, the PV power, and energy demand. Therefore, the initial set of scenarios has 12,000 (6 × 10 × 8 × 5 × 5) scenarios.
The program modeling language and the solver for implementation of the case studies are, respectively, GAMS and the CPLEX 12.1 run on a 3.6 GHz processor with 16 GB of RAM. A scenario reduction from 12,000 to 1000 scenarios by the GAMS/SCENRED fastbackward reduction method package is at the beginning of the program execution performed to reduce the computation time.
The parameters of power segments and slope for the piecewise linear function modeling the variable cost per hour are in Table 2. The scenarios considered for day-ahead market prices and positive and negative imbalance prices [32] are, respectively, in Figure 2a  The scenarios for wind and PV power [33,34] and load [33] are shown in Figure 3. The scenarios for wind and PV power [33,34] and load [33] are shown in Figure 3.

Analysis of Energy Balance of Microgrid without Demand Response
This case study analyzes how the microgrid behaves in the absence of demand response. This analysis is the starting point for comparison with the following cases. The energy balance of a microgrid without demand response is shown in Figure 4.  Figure 4 shows, as expected, that all incoming energy is equal to the outgoing energy, i.e., there is an even balance in the microgrid. The positive part represents the energy available due to production in the microgrid and the purchase in the market, compensating for the deficit. The negative part represents the energy removed from the microgrid, i.e., the usage by the loads, and the energy sold on the market due to overproduction. In a market environment in each period, either there is a positive or a negative deviation. The positive or negative deviations and the charge or discharge of storage devices are merely indicative. In Figure 3, purchase offers on the market between hour 1 and hour 7 are above 1300 kW because it is a period of low prices in the day-ahead market. In this period, it is more rewarding to purchase energy on the market than to produce energy

Analysis of Energy Balance of Microgrid without Demand Response
This case study analyzes how the microgrid behaves in the absence of demand response. This analysis is the starting point for comparison with the following cases. The energy balance of a microgrid without demand response is shown in Figure 4. The scenarios for wind and PV power [33,34] and load [33] are shown in Figure 3.

Analysis of Energy Balance of Microgrid without Demand Response
This case study analyzes how the microgrid behaves in the absence of demand response. This analysis is the starting point for comparison with the following cases. The energy balance of a microgrid without demand response is shown in Figure 4.  Figure 4 shows, as expected, that all incoming energy is equal to the outgoing energy, i.e., there is an even balance in the microgrid. The positive part represents the energy available due to production in the microgrid and the purchase in the market, compensating for the deficit. The negative part represents the energy removed from the microgrid, i.e., the usage by the loads, and the energy sold on the market due to overproduction. In a market environment in each period, either there is a positive or a negative deviation. The positive or negative deviations and the charge or discharge of storage devices are merely indicative. In Figure 3, purchase offers on the market between hour 1 and hour 7 are above 1300 kW because it is a period of low prices in the day-ahead market. In this period, it is more rewarding to purchase energy on the market than to produce energy  Figure 4 shows, as expected, that all incoming energy is equal to the outgoing energy, i.e., there is an even balance in the microgrid. The positive part represents the energy available due to production in the microgrid and the purchase in the market, compensating for the deficit. The negative part represents the energy removed from the microgrid, i.e., the usage by the loads, and the energy sold on the market due to overproduction. In a market environment in each period, either there is a positive or a negative deviation. The positive or negative deviations and the charge or discharge of storage devices are merely indicative. In Figure 3, purchase offers on the market between hour 1 and hour 7 are above 1300 kW because it is a period of low prices in the day-ahead market. In this period, it is more rewarding to purchase energy on the market than to produce energy with microturbines, so their contribution in these hours is below 290 kW. Between hour 3 and hour 6, the storage devices are called to store energy to later satisfy the demand or eventually store energy to sell it in periods of higher compensating day-ahead market prices, between hour 19 and hour 21. Hour 21 corresponds to the period of the highest day-ahead market price, so in this period the energy storage device is called to discharge energy. Additionally, regarding microturbines, from hour 8 onwards, the contribution has a significant value.

Effect of Demand Response on the Energy Balance of the Microgrid
This case study analyzes how the microgrid behaves in the presence of demand response. The case study considers three levels of demand response: 5%, 10%, and 25%. The energy balance of the microgrid with demand response is shown in Figure 5. with microturbines, so their contribution in these hours is below 290 kW. Between hour 3 and hour 6, the storage devices are called to store energy to later satisfy the demand or eventually store energy to sell it in periods of higher compensating day-ahead market prices, between hour 19 and hour 21. Hour 21 corresponds to the period of the highest day-ahead market price, so in this period the energy storage device is called to discharge energy. Additionally, regarding microturbines, from hour 8 onwards, the contribution has a significant value.

Effect of Demand Response on the Energy Balance of the Microgrid
This case study analyzes how the microgrid behaves in the presence of demand response. The case study considers three levels of demand response: 5%, 10%, and 25%. The energy balance of the microgrid with demand response is shown in Figure 5.  Figure 5 shows a tendency for higher purchase offers with higher levels of demand response. When the day-ahead market price is high, there is a progressive increase in sales offers and a decrease in energy consumption for higher levels of demand response. The increase in the level of demand response does not change the behavior of energy storage in the batteries, with charges and discharges happening at low and high prices, respectively.  Figure 5 shows a tendency for higher purchase offers with higher levels of demand response. When the day-ahead market price is high, there is a progressive increase in sales offers and a decrease in energy consumption for higher levels of demand response. The increase in the level of demand response does not change the behavior of energy storage in the batteries, with charges and discharges happening at low and high prices, respectively.

Effect of Demand Response on the Energy Offers
The results of a simulation for an analysis of the effect of flexible loads to improve the management of the microgrid for a series of day-ahead market prices are shown in Figure 6.

Effect of Demand Response on the Energy Offers
The results of a simulation for an analysis of the effect of flexible loads to improve the management of the microgrid for a series of day-ahead market prices are shown in Figure 6. Figure 6. Effect of demand response on the energy bid is shown: high market price, high selling offer; low market price, high purchase offer. Figure 6 shows the selling offers and the purchase offers, respectively, indicated by positive and negative powers, showing the potential as expected from the effect of allowing for controllable loads. At hours having lower day-ahead market prices (blue line), the purchase offers tend to increase if higher levels of demand response are allowed, e.g., the purchase increases from hour 1 to hour 8, due to the shifting of the consumption of controllable loads to these hours. The highest power difference due to the strategies without demand response and with the demand response at 25% is in hour 2, having low market prices. As shown, the increase from 0% to 25% in demand response implies increasing the purchase from 1.96 MW to 3.14 MW in hour 2, i.e., about 60% of demand increasing in a convenient hour. On the contrary, at hours having higher day-ahead market prices, the selling offers tend to increase if higher levels of demand response are allowed, e.g., the increase from hour 9 to hour 14, due to the shifting of the consumption of controllable loads to a convenient hour. The shift in energy usage to periods of low day-ahead market prices liberates energy in hours of high day-ahead market prices, which increases the selling offers. The highest power difference due to the strategies without demand response and with the demand response at 25% is in hour 21, at the highest price. As shown, the increase from 0% to 25% in demand response implies increasing the selling from 0.84 MW to 2.48 MW in hour 21, i.e., about three times more.

Effect of Demand Response on the Energy Consumption
The results of a simulation for an analysis of the potential benefit of having several levels of demand response on the energy demand profile for confirming the improvement in the management of the microgrid for a series of day-ahead market prices are shown in Figure 7. Figure 6. Effect of demand response on the energy bid is shown: high market price, high selling offer; low market price, high purchase offer. Figure 6 shows the selling offers and the purchase offers, respectively, indicated by positive and negative powers, showing the potential as expected from the effect of allowing for controllable loads. At hours having lower day-ahead market prices (blue line), the purchase offers tend to increase if higher levels of demand response are allowed, e.g., the purchase increases from hour 1 to hour 8, due to the shifting of the consumption of controllable loads to these hours. The highest power difference due to the strategies without demand response and with the demand response at 25% is in hour 2, having low market prices. As shown, the increase from 0% to 25% in demand response implies increasing the purchase from 1.96 MW to 3.14 MW in hour 2, i.e., about 60% of demand increasing in a convenient hour. On the contrary, at hours having higher day-ahead market prices, the selling offers tend to increase if higher levels of demand response are allowed, e.g., the increase from hour 9 to hour 14, due to the shifting of the consumption of controllable loads to a convenient hour. The shift in energy usage to periods of low day-ahead market prices liberates energy in hours of high day-ahead market prices, which increases the selling offers. The highest power difference due to the strategies without demand response and with the demand response at 25% is in hour 21, at the highest price. As shown, the increase from 0% to 25% in demand response implies increasing the selling from 0.84 MW to 2.48 MW in hour 21, i.e., about three times more.

Effect of Demand Response on the Energy Consumption
The results of a simulation for an analysis of the potential benefit of having several levels of demand response on the energy demand profile for confirming the improvement in the management of the microgrid for a series of day-ahead market prices are shown in Figure 7. Figure 7 shows that at hours where the day-ahead market price is low, the increase in the level of demand response tends to imply more usage of energy at these hours, e.g., from hour 1 to hour 8, the day-ahead market price is low, and higher energy consumption happens because of a high level of demand response. A higher difference between a scenario without demand response and at 25% of demand response is in hour 1. This increase is due to a lower market price, implying an increase in energy consumption of 25% at hour 1 in comparison with the scenario without demand response, i.e., an increase from 4.76 MW to 5.93 MW. Meanwhile, when the market price increases, energy consumption tends to decrease with higher levels of demand response, e.g., from hour 9 to hour 14, and due to the higher day-ahead market prices, there is a decrease in energy usage at 25% of demand response, because of shifting energy demand to lower-priced hours. The highest reduction of energy consumption between a strategy without demand response and at 25% of demand response is in hour 20, one of the hours with the highest market price. Sustainability 2021, 13, x FOR PEER REVIEW 12 of 17 Figure 7. Effect of demand response on the energy demand is shown: high market price, low energy demand; low market price, high energy demand. Figure 7 shows that at hours where the day-ahead market price is low, the increase in the level of demand response tends to imply more usage of energy at these hours, e.g., from hour 1 to hour 8, the day-ahead market price is low, and higher energy consumption happens because of a high level of demand response. A higher difference between a scenario without demand response and at 25% of demand response is in hour 1. This increase is due to a lower market price, implying an increase in energy consumption of 25% at hour 1 in comparison with the scenario without demand response, i.e., an increase from 4.76 MW to 5.93 MW. Meanwhile, when the market price increases, energy consumption tends to decrease with higher levels of demand response, e.g., from hour 9 to hour 14, and due to the higher day-ahead market prices, there is a decrease in energy usage at 25% of demand response, because of shifting energy demand to lower-priced hours. The highest reduction of energy consumption between a strategy without demand response and at 25% of demand response is in hour 20, one of the hours with the highest market price.

Effect of Demand Response on the Expected Profit
The potential benefit of having several levels of demand response on the hourly expected profit is evident from the behavior, as shown in Figure 8.

Effect of Demand Response on the Expected Profit
The potential benefit of having several levels of demand response on the hourly expected profit is evident from the behavior, as shown in Figure 8.  Figure 8 shows that profit increases with the increase in the level of demand response in periods of higher day-ahead market prices. The periods where this difference is most important are from hour 10 to hour 12 and from hour 19 to hour 22. The highest difference between the profit without demand response and the profit with demand response of 25% is at hour 21 when the profit increases by about 80%, from USD 61 to about USD 109. The effect of applying demand response on the total expected profit is shown in Figure 9.  Figure 8 shows that profit increases with the increase in the level of demand response in periods of higher day-ahead market prices. The periods where this difference is most important are from hour 10 to hour 12 and from hour 19 to hour 22. The highest difference between the profit without demand response and the profit with demand response of 25% is at hour 21 when the profit increases by about 80%, from USD 61 to about USD 109. The effect of applying demand response on the total expected profit is shown in Figure 9. Figure 9 shows that the expected profit increases with the increase in the level of demand response, e.g., without demand response, the profit is USD 505, with demand response at 10% it is USD 618, and with demand response at 25% it is USD 770, and the increases are 23% and 53%, respectively. Consequently, the aggregator can increase the profit by convenient management of the level of demand response. However, this management depends on agreement with the consumers of the microgrid. Figure 8 shows that profit increases with the increase in the level of demand response in periods of higher day-ahead market prices. The periods where this difference is most important are from hour 10 to hour 12 and from hour 19 to hour 22. The highest difference between the profit without demand response and the profit with demand response of 25% is at hour 21 when the profit increases by about 80%, from USD 61 to about USD 109. The effect of applying demand response on the total expected profit is shown in Figure 9.  Figure 9 shows that the expected profit increases with the increase in the level of demand response, e.g., without demand response, the profit is USD 505, with demand response at 10% it is USD 618, and with demand response at 25% it is USD 770, and the increases are 23% and 53%, respectively. Consequently, the aggregator can increase the profit by convenient management of the level of demand response. However, this management depends on agreement with the consumers of the microgrid. Figure 9. Effect of demand response on the expected profit is shown: high level of demand response, high expected profit.

Deterministic vs. Stochastic Solution
The analysis of the level of uncertainty reveals how uncertainty affects the decision making of the microgrid aggregator. This analysis employs the following quality metric: the value of the stochastic solution (VSS). The quality metric VSS is involved in the comparison between considering a stochastic programming problem at the expense of a deterministic one. More specifically, VSS is the difference between the optimum value of the objective function Z SP for the stochastic programming problem, and the optimum value Z DP for stochastic programming problem with the first state variables fixed at the respective expected values, i.e., the values resulting from the problem where the random parameters are replaced by mean values. The computation of the quality metric VSS is as follows: In (36), Z DP is calculated using the fixed values of the first state decision variable P DAM t , corresponding to the hourly bids of the deterministic programming problem. In the case study, the value of the VSS as a percentage is 1.9%, which justifies the interest in considering a stochastic programming problem instead of a deterministic programming problem.

Discussion
The simulations of the case studies are in favor of having flexible loads for taking advantage of demand-side management strategies through short-term microgrid optimal planning, allowing better performance in the management of the microgrid. Short-term microgrid optimal planning is an indispensable application in current power system paradigms, i.e., in terms of profiting from improved coordination of the participation in the electricity market with the demand-side management. From the point of view of those who manage the microgrid, having greater availability of energy to sell in periods of favorable market prices delivers more profitable market participation. From the point of view of end users, the application of the demand response allows consumers to have advantageous tariffs and an active contribution to the energy efficiency of the microgrid. This contribution is not less use of energy, but a shift of part of the demand to periods of lower market prices, i.e., by allowing a change in the consumption profile. In general, this is to be expected in the intelligent grids of the future, and this type of contribution from the consumers. The simulations quantify a reduction in the electricity tariff for consumers of about 12% over the estimated price of electricity in the day under consideration. Without demand response, the energy cost would be higher. Consequently, in general, short-term microgrid optimal planning coordinating the participation in the electricity market with the demand-side management has advantages for a better performance of the aggregator of the microgrid and end users. Additionally, it is expected that demand response can provide flexibility for the grid, guarantee more efficient use of the electrical infrastructure, and be used to improve the stability of the power system. For instance, demand response is used in frequency control. Further, demand response can be used to improve steady-state voltage stability. Additionally, demand response in a microgrid is important for the main grid, as the microgrid is seen as a single entity that aggregates a large volume of loads, which facilitates the operation of the system operator and the management of energy supply. For instance, the system operator can ask the microgrid aggregator to change the energy consumption profile to ensure safe operation and avoid congestion problems.

Conclusions
This paper presents short-term microgrid optimal planning formalized to address the capability of meeting the implications of an aggregator of a microgrid participating in the market environment and having demand-side management. This short-term microgrid optimal planning based on a two-state stochastic programming problem reformulated as a MILP allows for the management of the microgrid following the sources of uncertainty. The formularization of the sources of uncertainty is through a set of scenarios of historical data subjected to reduction. An analysis of the simulations shows that the application of demand-side management strategies, such as demand response, can guarantee a better operation in a market environment. For instance, the results show that by increasing the level of flexible loads by up to 25%, the energy bid in the day-ahead market may increase by 200% and there may be a reduction in energy consumption by 25% in periods of higher market prices. Likewise, the expected profit from participation in the market can increase by about 53% with a level of demand response of 25%.  Microturbine i commitment decision for scenario s at period t y sit Microturbine i start-up decision for scenario s at period t z sit Microturbine i shut-down decision for scenario s at period t