This paper presents an approach to obtain the optimal power flow solution subjected to various system constraints in a power system using an efficient particle swarm optimization (PSO) technique. In a power system, the continuous control variables are the active power output of the generators and voltage magnitudes of the generator buses, while the discrete variables are the transformer tap settings and switchable shunt devices. Generally, the parameter selection in the PSO equations is conceptualized with the local best (pbest) and global best (gbest) of the swarm, which enables a quick decision in directing the search towards the optimal solution. The impact of the inertia weight plays a significant role in the performance of the algorithm. In this paper the PSO algorithm with global-local best inertia weight (GLBestIW) is considered for the optimal power flow problem. The inertia weight in this method is described as a function of pbest and gbest, which allows the PSO to converge faster with better accuracy. The proposed technique is applied to a standard IEEE 30 bus test system, to obtain the optimal power flow solution by choosing the objective function as minimization of the fuel cost. Comparison of the proposed technique with other optimization techniques used for optimal power flow solution shows the superiority of the proposed approach and confirms its potential for solving optimal power flow problems efficiently. The article presents some promising patents on optimal power flow solution.