Due to the switching frequency limitation of high power switch devices, traction inverter output waveforms contain a lot of harmonics. So it is necessary to use the optimal pulse width modulation(PWM) technique to reduce the harmonics of traction inverter output waveforms. Firstly, this paper applies particle swarm optimization (PSO) algorithm to the solution of optimal PWM problem, and develops the current total harmonic distortion (THD) minimization optimization model. Secondly, this paper gets the conclusion that optimal PWM has good harmonic optimization effect through the comparison of conventional SPWM method and optimal PWM method under different subsections of subsection synchronous modulation. Finally, the simulation and hardware-in-the-loop (HIL) experiment results verify the accuracy of theoretical analysis.