The focus of this paper is to optimize the solar energy utilization in the water desalination process. Due to variable nature of solar energy, new system design is needed to address this challenge. Here, reverse osmosis units, as the electrical loads, are considered as an ON/OFF units to track these solar energy variations. Reverse osmosis units are different in sizes and numbers. Various combinations of reverse osmosis units in size and capacity provide different water desalination system performances. To assess each scenario of reverse osmosis units, the total capital cost and operation and maintenance (O&M) cost are considered. The implemented optimization algorithm search all of the possible scenarios to find the best solution. This paper deploys the solar irradiance data which is provided from west coast (Red Sea) of Saudi Arabia for model construction and optimization algorithm implementation.