# Optimal Energy Management within a Microgrid: A Comparative Study
## 1 Introduction
The online energy management is modelled as a stochastic optimal power flow problem and an energy management strategy (EMS) based on Lyapunov optimization is proposed. Then, the proposed EMS is applied to a real microgrid system. The simulation tests done show that the performance of the proposed EMS is close to an optimal offline algorithm. In a similar way, an algorithm for EMS based on multilayer ant colony optimization (EMS-MACO) is presented in [18]. Its main aim is to find energy scheduling in a microgrid through the optimal operation of its microsources. By this way, the electricity production cost can be reduced. The performance of the proposed algorithm is compared with modified conventional EMS (MCEMS) and particle swarm optimization (PSO) based on EMS. Analysis of obtained results demonstrates that the system performance is improved and the energy cost reduced. Specifically, the MACO algorithm, due to needing less iterations to converge, can provide a better response than the PSO and, moreover, the application of MACO reaches the lowest energy cost, reducing it by about 5% and 20% when compared with PSO and MCEMS, respectively. A decentralized microgrid energy management system is proposed in [19]; the controllers are located in each household and built on open code optimizers, and low-cost hardware was developed. In order to minimize the chances of a failure, a solution redundant in the aspects of communication and hot standby control devices was developed. The optimization problem is solved through linear programming (linprog). The microgrid is basically formed by a load, two solar panels, two wind turbines, and an energy storage unit. Microgrid power lines can be made as AC or DC. Besides that, the microgrid can be connected to the power grid and can interact with it. The obtained results show that the proposed solution can be useful for small settlements and farms instead of industrial installations. Finally, the interested reader can find a survey which presents the latest advances in adaptive and intelligent methods to control microgrids in [20]. The motivation of applying intelligent techniques is to enhance the control system performance in the microgrid. Thus, in that work, several control and intelligent techniques, such as Proportional-Integral-Derivative (PID) controller, MPC, PSO, and so on, used to manage the energy in a microgrid are discussed and classified. At this point, it is important to emphasize the main problem of OPF dealt with in this work: optimal energy management as a part of the tertiary control in a microgrid. It is addressed according to the energy optimization approach for microgrids. The minimization of the cost of energy imported from the main network is the aspect considered to formulate the optimization objective; that is, it is considered an economic aspect. In addition, the determination of reference curves of power generated, stored, and exchanged with the main network throughout the day in advance, i.e., the optimum dispatch of energy, defines the scope of the present work. Thus, the problem has been formulated as a dispatch problem using the concept of day-ahead. The associated optimization model has been formulated as a unified model taking into account distributed generation sources and energy storage units, i.e., batteries. Moreover, different from traditional models, the proposed optimization model has taken into account constraints for the balance equations corresponding to the nodes of the microgrid. By this way, through the model optimization, not only is the best energy management for the microgrid obtained but, at the same time, the generation and voltage levels of all the elements which form the microgrid are fulfilled. Any of the works cited in the previous paragraph use a unified microgrid model which includes a wind turbine, photovoltaic modules, electric vehicle, and so on, and formulate it using the concept of day-ahead.