The current study is conducted to propose a polygeneration system for producing electricity, potable water, cooling, hot domestic water, hydrogen, oxygen, and nitrogen. The proposed system is fueled by heavy oil, natural gas, and solar radiation. Accordingly, the integration of an air separation unit, gasifier, gas turbine cycle, steam Rankine cycle, organic Rankine cycle combined by ejector refrigeration cycle, solid oxide fuel cell, thermoelectric generator, proton exchange membrane electrolysis, adsorption desalination, concentrated photovoltaic thermal collector and CO2 capture are done. The energy, exergy, exergoeconomic, exergoenvironmental, emergoeconomic, and emergoenvironmental analyses have been done to evaluate and compare different aspects of the system. With this, it becomes possible to move towards sustainable development by considering different aspects of the problem. For better performance of the system, multi-objective optimization was done using artificial intelligence. In this optimization, the decision variables were selected as a result of a comprehensive sensitivity analysis. As a result of this optimization the exergy efficiency of the system, LCOE, LEIOE, the emergy rate of the system, and the flow of produced hydrogen are 18.51%, 142.94$/MWh, 330.77Pts/MWh, 14443.28 × 1011 sej/s, 101.88 kg/h. The net power production of the system is 427.98 MW while the hydrogen cost is 19.56/GJ.