In the simulation experiment of path planning of mobile robot based on firefly algorithm, it is found that the matching relationship between the number of fireflies and obstacles in the iterative process has significant conflict impacts on exploration ability and computational complexity of the algorithm. In order to solve the above problem, an optimal method of path planning based on firefly algorithm with selfadaptive population size is proposed. Firstly, the evaluation of degree of collision is established at the cost of avoiding collision. Based on the degree of collision of the population, two nonlinear functions are proposed to determine the population size. Then, individuals are added or deleted for the firefly population. Individuals are added randomly. The feasible solution and the infeasible solution are distinguished in firefly population, and delete the fireflies in the infeasible solution first when performing the eliminating operation. Finally, on the basis of the existing methods for dealing with infeasible paths, a coefficient that is adaptively adjusted according to the population size is introduced to control the degree to which the infeasible path approaches the feasible area. Compared with fixed population size firefly algorithm, the proposed algorithm has better performance in terms of solution stability, convergence speed and running time. INDEX TERMS path planning, improved firefly algorithm, self-adaptive population size.