From the perspective of energy, greenhouses can be considered as a black box that exchanges water and energy. Among the applications of modern polygeneration energy systems, the supply of water and energy chains for industrial greenhouses can be mentioned. The present work, presents an innovative solar-biomas polygeneration system for the demand of water, power, and wastewater treatment of a tomato greenhouse. For the power generation in the polygeneration system, an internal combustion engine based on biomass fuel and an organic Rankine cycle using the waste heat of the internal combustion engine have been used. The freshwater production in the system has also been created using the integration of microbial desalination cells, humidificationdehumidification desalination, and reverse osmosis desalination systems. In this section solar energy is used to supply the required heat. The CO2 capture unit in the polygeneration system has been used to remove CO2 from the combusted syngas and it can generate the CO2 demand in the tomato greenhouse. The syngas production in the proposed polygeneration system is created by an air gasification unit. The presented polygeneration system has been evaluated by energy, exergy, exergoeconomic, exergoenvironmental, emergoeconomic, emergoenvironmental (6E) analyses. To present the efficient condition for the proposed polygeneration system investigation of alfalfa, tomato waste, and wheat Straw as suitable biomass fuel for the system was performed. Finally, multi-objective optimization using genetic, dragonfly, and ant-lion algorithms has been performed for the optimization of the whole system. For the integration of the tomato greenhouse with the presented polygeneration system, the water and energy demand of the greenhouse was extracted from the energy balance and humidity balance of the greenhouse. The energy demand of the greenhouse has been reported monthly according to the climate change in Tehran. The main results of the analysis of the proposed system show that alfalfa is more efficient in energy and environmental impact point of view than other biomass fuels. Optimization of the whole system parameters in the five-objective state with an ant-lion algorithm shows that the total power generation, total freshwater production, and total CO2 removal as 215.30 kW, 118.45 m3/ day, and 2.68 ton/day, respectively. However, the overall energy efficiency for the presented polygeneration system is 31.45 %, and the total cost rate and total environmental impact rate are 92.99 $/hr and 5.87 Pts/hr, respectively. Also, the ecological sustainability index of the system is estimated at 9.45.