In this paper, an optimization framework is proposed in order to optimal operation of a water desalination unit in a sustainable green energy network. The operation problem is modeled as a mixed integer linear programming (MILP) and optimized using a mathematical based optimization algorithm. In order to increase the flexibility of the studied sustainable energy system, a fuel cell unit and hydrogen-based vehicles have been included in the system. Moreover, the uncertainty of stochastic parameters has been considered and a machine learning based method namely long short term memory (LSTM) algorithm is utilized for forecasting of the parameters. The proposed methodology is applied on a typical case study and the simulation results are extracted and discussed.