This study proposes a solar-geothermal multi-generation system integrating proton exchange membrane fuel cells (PEMFCs) for continuous, reliable, and sustainable energy production. During the day, the system utilizes solar and geothermal energy to generate power, heating, fresh water, and hydrogen. At night, PEMFCs use stored hydrogen to maintain power generation and improve efficiency, with the heat released by the PEMFCs further enhancing overall performance. Performance analysis shows that extending nighttime from 8 to 14 h reduces hydrogen consumption from 286.38 to 102.27 kg/h and affects power output and exergy efficiency by 46.6 % and 20.7 %, respectively. To evaluate the system's feasibility at the selected location, hourly analyses were conducted across two different seasons. To expedite the optimization process, three machine learning techniques were employed and evaluated using metrics such as mean squared error, mean absolute error, and R2 score. Among the methods tested, the extreme gradient boosting (XGBoost) regressor combined with the multi-output regressor algorithm provided the most accurate predictions. The XGBoost model was further optimized using a multi-objective approach with a genetic algorithm, leading to the identification of optimal operational points. Under optimal conditions, the system achieves an exergy round trip efficiency of 28.12 %, a total cost rate of 739.14 $/h, and is capable of producing 2.53 kg/s of fresh water and 204.19 kg/h of hydrogen.