Harmonic pollution minimisation in voltage-source programmed pulse-width modulation (PPWM) inverters is defined as a time-limited optimisation problem in real-time applications with variable DC sources. In order to obtain minimum total harmonic distortion (THD) as the objective function, shuffled-frog-leaping algorithm (SFLA) is modified and employed to calculate the switching angles and compared with non-linear programming as a traditional optimisation method. In addition, particle swarm optimisation and three of its modified versions as popular evolutionary optimisation algorithms are employed to ensure the capability of the proposed optimisation method. Moreover, modified sinusoidal PWM (MSPWM) THD is compared with PPWM THD. Furthermore, as the DC bus voltage in some applications might have high variations (in amplitude or frequency of fluctuations) in a short time, to acquire adequate response speed to this variation of DC source of inverters in real-time control applications, a neural network (NN) is trained by the off-line calculated results of MSFLA for various desired modulation indexes (various DC voltages). Simulation results demonstrate the accurate and high-speed response of the designed NN. The main contribution of this study is to provide a fast accurate method which can track the variation of DC source of inverters with high-quality solutions in real-time control applications.