A unified power quality conditioner (UPQC)to compensate current and voltage power quality problems ofsensitive loads. The UPQC consists of a shunt and series inverter having a common dc link. The shunt inverter eliminates current harmonics originating from the nonlinear load side and the series inverter mitigates voltage sag/swell originating from the supply side. The developed controllers for shunt and series inverters are based on an enhanced phase-locked loop and nonlinear adaptive filter. The proposed UPQC achieves superior capacity of mitigating the effects of voltage sag/swell and suppressing the load current harmonics under distorted supply conditions.Particle swarm optimization is discussed for its character of simple computation and high measurement accuracy. Simulation results are shown to verify the effectiveness and superiority of thealgorithm.