The purpose of this paper was to formulate and optimize a sustainable and cost-effective micro grid solution based on a solar photovoltaic grid and a diesel generator for the supply of electricity to populated areas that do not have access to electricity and remote areas away from the main grid. The production of electricity from renewable energy sources is subsidized, which has led to greater application in distribution networks. Island photovoltaic systems have found their place in performing two important functions: providing power in areas without access to the public electricity grid and ensuring uninterruptible power supply in networked systems. Such systems are mostly installed in areas of Africa, Asia and South America where the public electricity network is poorly developed. Designing an island photovoltaic system requires a good knowledge of photovoltaic technology, power electronics and the climatic specifics of the location itself. The main problem in optimizing island photovoltaic systems in our geographical area is the very large differences in irradiation between the winter and summer months. This makes the whole project more expensive because much more investment is needed in photovoltaic modules, which are the most expensive part of the system. Experience and analysis so far show that it is still best to use a hybrid photovoltaic system or a combination of photovoltaic modules and diesel generators because we get complete independence of the system, optimal use of diesel generators, batteries and reduce the total initial investment. The program used to optimize this system has changes in load and power consumption per hour, which gives it great precision for calculating data, and more accurate optimization.