In this paper, the optimal design of a grid-connected the hybrid energy system for a sample area in the north Iran is studied. A new innovative cost-based objective function is proposed which is combination of life cycle cost and reliability cost. Also, loss of power supply probability (LPSP) criteria, is considered as constraint for ensuring at the same time certain level of system reliability. Designing process is implemented in such a way that the total cost of the system reaches its minimum. For this purpose, a modified version of Bee algorithm has been proposed to achieve this goal. In order to carry out studies, the actual sample system, whose data has been available, has been studied. The results indicate the good performance of proposed hybrid system to reduce system cost.