This paper proposes a sustainable energy management method for microgrids (MGs) in the urban area while taking into account energy storage systems (ESSs) and renewable energy (RE). This study integrates RE, such as solar and wind energy production, into the power grid, and formulates the optimum dispatch scheme of hybrid energy production, based on ESS charge and discharge planning using their digital models. Electricity is exchanged among the MG systems and the utilities on a daily basis. MG systems' cost-effective dispatch per day is solved by an improved pigeon-inspired optimization algorit...