This study investigates the use of division algorithms to optimize the size of a desalination system integrated with a microgrid based on a wind turbine plant and the battery storage to supply freshwater based on cost, reliability, and energy losses. Cumulative exergy demand is used to identify and minimize the energy losses in the optimized system. Division algorithms are used to overcome the drawback of low convergence speed encountered by the well-known method genetic algorithm. The findings indicated that there is a positive relationship between cost, cumulative exergy, and reliability. More specifically, when the loss of power supply probability is 10%, compared to when it is 0%, the total cumulative exergy demand and total life cycle cost are reduced by 34.76% when the battery is full and 45.44% when the battery is empty and there is a 44.43% decrease in total life cycle cost, respectively. However, the more reliable system, the less exergy is lost during the production of 1 m3 freshwater by desalination integrated into wind turbine plant.