Electrical power is an important factor to any community, commercial center or industry. Currently, new forms of electricity generation are being proposed and implemented. Among them, hybrid microgrid systems (HGMS) have been playing a significant role. Such systems are gaining increasing attention in the energy transition moment that the entire World is facing nowadays. The balance of load and electricity generation from renewable energy sources is a major challenge in the operation and planning of HGMS projects. This work presents a new modeling for a microgrid system and its optimization using the Canonical Differential Evolutionary Particle Swarm Optimization to demonstrate the economic viability of the electric energy supply. The proposed approach made it possible to optimize the operation of HGMS and provide decision aid for choosing between two different battery storage systems.