In this paper, the ant colony algorithm has been used to find single and two-diode models of solar cells, and then to calculate the maximum power point of photovoltaic cells. First, it is tried to find an exact model of the solar cell by the ant colony algorithm and then to track the maximum power point by the use of the direct method. To verify the results of the simulation and to examine the accuracy of the proposed algorithm, the results of this algorithm have been compared with the ones obtained from algorithms in other sources. They indicate that the ACO algorithm has a higher accuracy than other methods and the error of the model proposed by this algorithm is so negligible. After finding single and two-diode models of solar cells, these two have been applied to track the maximum power point of the solar cell and a comparison has been made among the maximum powers achieved by each these two models.