This paper presents a method for optimal sizing of a Micro grid connected to a hybrid source to ensure the continuity and quality of energy in a locality with a stochastically changing population. The hybrid system is composed of a solar photovoltaic system, a wind turbine, and an energy storage system. The reliability of the system is evaluated based on the voltage level regulation on IEEE 33-bus and IEEE 69-bus standards. Power factor correction is performed, despite some reliability and robustness constraints. This work focuses on energy management in a hybrid system considering climatic disturbances on the one hand, and on the other hand, this work evaluates the energy quality and the cost of energy. A combination of genetic algorithms of particle swarm optimization (CGAPSO) shows high convergence speed, which illustrates the robustness of the proposed system. The study of this system shows its feasibility and compliance with standards. The results obtained show a significant reduction in the total cost of production of this proposed system.