## 1 Introduction
The study also omits the analysis of voltage and current limitations in the lines, which are essential for ensuring reliable and secure operation. Moreover, the EMS is only assessed in grid-connected mode, ignoring the traditional dual-mode nature of microgrids, which can operate both in on-grid and islanded (off-grid) modes. This restricts the practical applicability of the proposed method to more complex and realistic microgrid scenarios. In the specialized literature, multiple tools based on exact methods and commercial software have been proposed to address the problem of energy management in battery systems [24; 25; 26]; however, these solutions often rely on specialized software, such as GAMS, which requires costly licenses and presents restrictions that hinder their practical implementation in environments where flexibility, replicability, and low cost are essential [27]. Moreover, deterministic methods or those based on specialized software tend to fall into local optima as the solution space grows or becomes more complex, limiting their ability to solve nonlinear and high-dimensional problems typical in modern electrical networks. In contrast, sequential programming methods, such as metaheuristic techniques, offer more robust and adaptable algorithms that maintain strong exploratory performance across complex solution spaces. These algorithms can be implemented in widely used engineering languages like MATLAB, facilitating their adaptation, integration with other analysis tools, and application by electric utilities, academic institutions, and research centers. For all these reasons, this research was based on sequential programming software, specifically on metaheuristic optimization techniques, which, according to the state of the art, constitute a well-established and widely studied approach for energy management in electrical networks. In response to the growing need for advanced energy management systems that can optimize BESS operation in AC MGs while aiming to address the specific limitations identified in the current state-of-the-art literature, this work introduces an innovative EMS designed to minimize both energy losses and CO\({}_{2}\) emissions through intelligent battery storage optimization. Unlike previous approaches that often neglect statistical robustness, grid constraints, or dual-mode operation, the proposed solution integrates a comprehensive optimization strategy that considers technical and environmental requirements. At its core lies the Multi-Verse Optimizer (MVO), a powerful metaheuristic algorithm particularly well-suited to handle the multi-objective and nonlinear nature of EMS problems [28], enabling effective navigation of trade-offs between system efficiency and sustainability in real-world MG scenarios. This study develops a comprehensive framework where MVO determines optimal battery charge/discharge cycles while accounting for power flow dynamics through Successive Approximation. What sets this approach apart is its dual focus, not just on traditional operational metrics but specifically on reducing both energy waste and carbon footprint. The methodology undergoes rigorous tuning to ensure peak performance, with comparative analysis against vortex search and genetic algorithms conducted under identical conditions for fair evaluation. Validation occurs on a realistic 33-node MG testbed that mirrors actual operating conditions. By using real solar generation and load profiles from Medellin, Colombia, the system demonstrates its effectiveness across two crucial scenarios: grid-dependent operation, where it minimizes losses during energy exchange, and self-powered mode, where it strategically deploys diesel generation to maintain power quality while constraining emissions. The extensive testing regimen, comprising 100 independent simulations, provides robust evidence of the system's capabilities.