This paper deals with a new algorithm and the concept and characteristics of the ant colony algorithm. The authors applied the ant colony algorithm to Rayleigh-wave inversion so as to deduce underground structure from dispersion data, analyzed the problems worthy of attention in the use of the ant colony algorithm and employed the distributive curve of pheromone density to change and narrow the further search scope with the purpose of raising the inversion speed. The inversion analysis of the theoretical model and measured data shows that the ant colony algorithm is effective.