Optimization of tool path planning using metaheuristic algorithms provides a feasible approach to reduce geometrical machining errors in 5-axis flank machining of ruled surfaces. The solution quality of these algorithms is unsatisfactory in a high-dimensional search space. In this study, various algorithms derived from the electromagnetism-like mechanism (EM) were applied. The test results of representative surfaces showed that all EM-based methods yield more effective optimal solutions than does PSO, despite a longer search time. A new EM-MSS (electromagnetism-like mechanism with move solution screening) algorithm produces the most favourable results by ensuring the continuous improvement of new searches. This work improves the practical values of tool path planning by offering a satisfactory machining quality.