# Optimal Energy Management within a Microgrid: A Comparative Study
## 1 Introduction
In order to achieve this control task, the formulation and solution of an optimal power flow (OPF) model is required. In grid-connected mode the power deficit can be supplied by the main grid, and excess power generated in the microgrid can be traded with the main grid and can provide ancillary services [5]. Accordingly, the OPF model in this work considers minimizing the cost of the total energy imported through the PCC for the time span of interest. For this purpose, the energy resources and the power flow within the microgrid are optimized. In this way, the energy management within the microgrid in grid-connected mode is optimized within the context of the tertiary control. The problem is formulated according to the framework provided by the day-ahead dispatch problem. With the day-ahead dispatch scheme, it is possible to perform the optimum management of energy distribution systems to improve the use of renewable energy [13]; moreover, this concept is more related with the active energy management. In this approach, optimization of active power flow in this work is approached as a day-ahead dispatch problem in which appropriate predictions of demand and electricity generation to solve the economic power dispatch within the microgrid are considered. The energy management within a microgrid is a research topic widely dealt with in literature in the last years. In [14] the proposed algorithm is able to adjust microgrid generation to demand on-line in grid-connected-mode. To this end, the algorithm optimizes both fuel consumption and emissions cost functions through a heuristic approach. The optimal power dispatch is virtually formulated as a lossless power dispatch problem. In this way, the algorithm computational burden and execution time (around 1 ms) are very low, which may allow its implementation on low-cost programmable controllers to perform the optimal power dispatch. It is noted that power losses and network voltages issues are not accounted for in this approach. Several simulation tests are presented to show the goodness of the proposed controller. On the other hand, in [15] an economic distributed Model-based Predictive Control (MPC) is proposed to manage the energy in several microgrids in a stochastic way. Through the probabilistic forecasts of renewable power generation and microgrid load, the proposed scheme effectively handles the uncertainties in both supply and demand. The proposed scheme was evaluated on ten interconnected microgrids. The results indicated that it successfully reduces the systemwide operating cost, achieves the supply-demand balance in each microgrid, and brings the energy exchange between the distribution network operator and main grid to a predefined trajectory. The originality of this work lies in the coordination of multi-microgrids and the distribution network through a hierarchical, distributed, economic, and stochastic MPC. Other work which is focused on several microgrids is presented in [16], where optimization-based scheduling strategies for the coordination of microgrids are commented upon. The main novelty of this work is the simultaneous management of energy production and energy demand within a reactive scheduling approach to deal with the presence of uncertainty associated to production and consumption. A Mixed-Integer Linear Programming (MILP) formulation is presented and used within a rolling horizon scheme that periodically updates input data information. Although the use of rolling horizon strategies for scheduling problems in uncertain scenarios is well known, its application in microgrid scheduling constitutes a challenge in this area. The proposed strategy is tested with a microgrid basic structure formed by photovoltaic panels, wind turbines, and energy storage units. Results can be used as the basis for solving further problems with higher complexity. On the other hand, in [17] the problem of energy management in microgrids is formulated for real-time operation.