Solving the optimal power flow problem is one of the main objectives in electrical power systems analysis and design. The modern optimization algorithms such as the evolutionary algorithms are also adopted to solve this problem, especially when the intermittency nature of generation resources are included, as in wind and solar energy resources, where the models are stochastic and non-linear. This paper uses the particle swarm optimization algorithm for solving the optimal power flow for IEEE-30 bus system. In addition to selection of the most effective control variables based on sensitivity analysis to alleviate the violations and return the system back to its normal state. This adopted strategy would decrease the optimal power flow calculation burden by particle swarm optimization algorithm, especially with large systems.