The straightness and flatness errors are generally assessed by using the Least Squares Method (LSM). However, the results obtained from LSM often overestimate the tolerances, and are not consistent with the ISO standards' definitions. To this end, this paper presents a method to evaluate those errors by using particle swarm optimization (PSO). The realization technique is detailed. The experimental data is utilized to verify this algorithm, together with a comparison with some typical optimization algorithms.