This paper proposes a new swarm based evolutionary algorithm called LBEST PSO with dynamically varying sub-swarms (LPSO DVS). Swarm based algorithms are meta-heuristic search methods whose mechanics are inspired by the collaborative behaviour of biological populations. The performance of four swarm based algorithms, i.e., particle swarm optimisation (PSO), fuzzy adaptive particle swarm optimisation (FAPSO), fitness distance ratio particle swarm optimisation (FDRPSO) and LPSO DVS are also compared with genetic algorithm (GA) and improved GA when applied to the power system optimal power flow (OPF) problem. OPF optimises the power system operating objective function, while satisfying the set of system operating constraints. The objective functions considered in this OPF problem are fuel cost (FC) minimisation, voltage stability enhancement index (VSEI) minimisation, transmission loss minimisation (LM) and voltage deviation (VD) minimisation. Simulation results for the IEEE 30 bus system are presented and the comparison is made among the numerical results obtained using the different evolutionary algorithms.