The main contribution of this research is formulating the size optimization of grid-independent hybrid wind/photovoltaic/biodiesel/battery systems and proposing a hybrid algorithm on this optimization problem. There are many investigations based on hybrid wind and PV power systems but the investigation on the hybrid wind/photovoltaic/biodiesel/battery system is rarely found. Here, the optimal design of a biodiesel/wind/photovoltaic/battery energy system for a stand-alone application in Iran is studied. The objective of the optimum design problem is to minimize the life cycle cost of the wind/photovoltaic/biodiesel/battery system subject to some constraints by adjusting four decision variables, namely, number of batteries, photovoltaic area, the swept area of wind turbines, and fuel consumption of the biodiesel generator. To solve the optimization problem, initially, we investigate the performance of two popular metaheuristic algorithms, namely, harmony search and simulated annealing. Moreover, this article proposes a hybrid harmony search-simulated annealing method that combines the advantages of each one of the above-mentioned metaheuristic algorithms. Simulation results show that the proposed hybrid harmony search-simulated annealing improves the obtained solutions, in terms of quality, compared to the solutions provided by individual harmony search or individual simulated annealing algorithms. Moreover, the hybrid photovoltaic/biodiesel/battery system is the best choice to supply the electrical load.