5 Educational Simulator for Particle Swarm Optimization and Economic Dispatch Applications

Optimization problems are widely encountered in various fields in science and technology. Sometimes such problems can be very complex due to the actual and practical nature of the objective function or the model constraints. Most of power system optimization problems have complex and nonlinear characteristics with heavy equality and inequality constraints. Recently, as an alternative to the conventional mathematical approaches, the heuristic optimization techniques such as genetic algorithms (GAs), Tabu search, simulated annealing, and particle swarm optimization (PSO) are considered as realistic and powerful solution schemes to obtain the global or quasi-global optimums (K. Y. Lee et al., 2002). In 1995, Eberhart and Kennedy suggested a PSO based on the analogy of swarm of bird and school of fish (J. Kennedy et al., 1995). The PSO mimics the behavior of individuals in a swarm to maximize the survival of the species. In PSO, each individual makes his decision using his own experience together with other individuals' experiences (H. Yoshida et al., 2000). The algorithm, which is based on a metaphor of social interaction, searches a space by adjusting the trajectories of moving points in a multidimensional space. The individual particles are drawn stochastically toward the present velocity of each individual, their own previous best performance, and the best previous performance of their neighbours (M. Clerc et al., 2002). The practical economic dispatch (ED) problems with valve-point and multi-fuel effects are represented as a non-smooth optimization problem with equality and inequality constraints, and this makes the problem of finding the global optimum difficult. Over the past few decades, in order to solve this problem, many salient methods have been proposed such as a hierarchical numerical method (C. E. Lin et al., 1984), dynamic programming (A. J. Wood et al., 1984), evolutionary programming (Y. M. Park et al., 1998; H. T. Yang et al., 1996; N. Sinba et al., 2003), Tabu search (W. M. Lin et al., 2002), neural network approaches (J. H. Park et al., 1993; K. Y. Lee et al., 1998), differential evolution (L. S. Coelho et al., 2006), particle swarm optimization (J. B. Park et al., 2005; T. A. A. Victoire et al., 2004; T. A. A. Victoire et al., 2005), and genetic algorithm (D. C. Walters et al., 1993). This chapter would introduce an educational simulator for the PSO algorithm. The purpose of this simulator is to provide the undergraduate students with a simple and useable tool for


Introduction
Optimization problems are widely encountered in various fields in science and technology.Sometimes such problems can be very complex due to the actual and practical nature of the objective function or the model constraints.Most of power system optimization problems have complex and nonlinear characteristics with heavy equality and inequality constraints.Recently, as an alternative to the conventional mathematical approaches, the heuristic optimization techniques such as genetic algorithms (GAs), Tabu search, simulated annealing, and particle swarm optimization (PSO) are considered as realistic and powerful solution schemes to obtain the global or quasi-global optimums (K.Y. Lee et al., 2002).In 1995, Eberhart and Kennedy suggested a PSO based on the analogy of swarm of bird and school of fish (J.Kennedy et al., 1995).The PSO mimics the behavior of individuals in a swarm to maximize the survival of the species.In PSO, each individual makes his decision using his own experience together with other individuals' experiences (H.Yoshida et al., 2000).The algorithm, which is based on a metaphor of social interaction, searches a space by adjusting the trajectories of moving points in a multidimensional space.The individual particles are drawn stochastically toward the present velocity of each individual, their own previous best performance, and the best previous performance of their neighbours (M.Clerc et al., 2002).The practical economic dispatch (ED) problems with valve-point and multi-fuel effects are represented as a non-smooth optimization problem with equality and inequality constraints, and this makes the problem of finding the global optimum difficult.Over the past few decades, in order to solve this problem, many salient methods have been proposed such as a hierarchical numerical method (C.E. Lin et al., 1984), dynamic programming (A.J. Wood et al., 1984), evolutionary programming (Y.M. Park et al., 1998;H. T. Yang et al., 1996;N. Sinba et al., 2003), Tabu search (W.M. Lin et al., 2002), neural network approaches (J.H. Park et al., 1993;K. Y. Lee et al., 1998), differential evolution (L. S. Coelho et al., 2006), particle swarm optimization (J.B. Park et al., 2005;T. A. A. Victoire et al., 2004;T. A. A. Victoire et al., 2005), and genetic algorithm (D. C. Walters et al., 1993).This chapter would introduce an educational simulator for the PSO algorithm.The purpose of this simulator is to provide the undergraduate students with a simple and useable tool for gaining an intuitive feel for PSO algorithm, mathematical optimization problems, and power system optimization problems.To aid the understanding of PSO, the simulator has been developed under the user-friendly graphic user interface (GUI) environment using MATLAB.In this simulator, instructors and students can set parameters related to the performance of PSO and can observe the impact of the parameters to the solution quality.This simulator also displays the movements of each particle and convergence process of a group.In addition, the simulator can consider other mathematical or power system optimization problems with simple additional MATLAB coding.

Overview of particle swarm optimization
Kennedy and Eberhart (J.Kennedy et al., 1995) developed a PSO algorithm based on the behavior of individuals of a swarm.Its roots are in zoologist's modeling of the movement of individuals (e.g., fishes, birds, or insects) within a group.It has been noticed that members within a group seem to share information among them, a fact that leads to increased efficiency of the group (J.Kennedy et al., 2001).The PSO algorithm searches in parallel using a group of individuals similar to other AI-based heuristic optimization techniques.In a physical n-dimensional search space, the position and velocity of individual i are represented as the vectors  The constants 1 c and 2 c represent the weighting of the stochastic acceleration terms that pull each particle toward the Pbest and Gbest positions.Suitable selection of inertia weight provides a balance between global and local explorations, thus requiring less iteration on average to find a sufficiently optimal solution.In general, the inertia weight ω has a linearly decreasing dynamic parameter framework descending from max ω to min ω as follows (K.Y. Lee et al., 2002;H. Yoshida et al., 2000;J. B. Park et al., 2005).

Purpose and motivation of simulator
As a result of the rapid advances in computer hardware and software, computer-based power system educational tools have grown from very simple implementations, providing the user with little more than a stream of numerical output, to very detailed representations of the power system with an extensive GUI.Overbye, et al. had developed a user-friendly simulation program, PowerWorld Simulator, for teaching power system operation and control (T.J. Overbye et al., 2003).They applied visualization to power system information to draw user's attention and effectively display the simulation results.Through these works, they expected that animation, contouring, data aggregation and virtual environments would be quite useful techniques that are able to provide efficient learning experience to users.Also they presented experimental results associated with human factors aspects of using this visualization (D. A. Wiegmann et al., 2005;D. A. Wiegmann et al., 2006;N. Sinba et al., 2003).Therefore, like other previous simulators, the motivation for the development of this simulator is to provide the students with a simple and useable tool for gaining an intuitive feel for the PSO algorithm, mathematical and power system optimization problems.

Functions of simulator
The basic objectives of this simulator were to make it easy to use and to provide effective visualization capability suitable for presentations as well as individual studies.This educational simulator was developed by MATLAB 2009b.MATLAB is a scientific computing language developed by The Mathworks, Inc. that is run in an interpreter mode on a wide variety of operating systems.It is extremely powerful, simple to use, and can be found in most research and engineering environments.
The structure and data flow of the developed PSO simulator is shown in Fig. 1.The simulator consists of 3-parts, that is, i) user setting of optimization function as well as parameters, ii) output result, and iii) visualized output variations, as shown in Figs. 2, 3, and  4, respectively.Since the main interaction between user and the simulator is performed through the GUI, it presents novice users with the information they need, and provides easy access for advanced users to additional detailed information.Thus, the GUI is instrumental in allowing users to gain an intuitive feel of the PSO algorithm, rather than just learning how to use this simulator.
In this simulator, parameters (i.e., maximum number of the iteration, maximum and minimum number of inertia weight, acceleration factors 1 c and 2 c , and number of particles) that have the influence of PSO performance can be directly inputted by users.In addition, www.intechopen.com

Basic ED problem formulation
The ED problem is one of the basic optimization problems for the students who meet the power system engineering.The objective is to find the optimal combination of power generations that minimizes the total generation cost while satisfying an equality constraint and a set of inequality constraints.The most simplified cost function can be represented in a quadratic form as following (A.J. Wood et al., 1984): where, C total generation cost; J set for all generators.While minimizing the total generation cost, the total generated power should be the same as the total load demand plus the total line loss.However, the transmission loss is not considered in this paper for simplicity.In addition, the generation output of each generator should be laid between minimum and maximum limits as follows: where min j P and max j P are the minimum and maximum output of generator j, respectively.

Valve-point effects
The generating units with multi-valve steam turbines exhibit a greater variation in the fuelcost functions.Since the valve point results in ripples, a cost function contains high order nonlinearities (H.T. Yang et al., 1996;N. Sinba et al., 2003;D. C. Walters et al. 1993).Therefore, the cost function ( 5) should be replaced by the following to consider the valvepoint effects: where j e and j f are the cost coefficients of generator j reflecting valve-point effects.
Here, the sinusoidal functions are added to the quadratic cost functions.

Case studies
This simulator can choose and run five different mathematical examples and two different ED problems: (i) The Sphere function, (ii) The Rosenbrock (or banana-valley) function, (iii) Ackley's function, (iv) The generalized Rastrigin function, (v) The generalized Griewank function, (vi) 3-unit system with valve-point effects, and (vii) 40-unit system with valvepoint effects.In the case of each mathematical example (functions (i)-(v)), two input variables (i.e., 2-dimensional space) have been set in order to show the movement of particles on contour.For the case study, 30 independent trials are conducted to observe the variation during the evolutionary processes and compare the solution quality and convergence characteristics.
To successfully implement the PSO, some parameters must be assigned in advance.The population size NP is set to 30.Since the performance of PSO depends on its parameters such as inertia weight ω and two acceleration coefficients (i.e., 1 c and 2 c ), it is very important to determine the suitable values of parameters.The inertia weight is varied from 0.9 (i.e., max ω ) to 0.4 (i.e., min ω ), as these values are accepted as typical for solving wide varieties of problems.Two acceleration coefficients are determined through the experiments for each problem so as to find the optimal combination.

Mathematical examples
For development of user's understanding of the PSO algorithm, five non-linear mathematical examples are used here.In each case, the maximum number of iterations (i.e., max iter ) was set to 500.The acceleration coefficients (i.e., 1 c and 2 c ) was equally set to 2.0 www.intechopen.comfrom the experimental results for each case using the typical PSO algorithm.And all of the global minimum value of each function is known as 0. The global minimum value was successfully verified by the simulator.

The sphere function
The function and the initial position range of input variables (i.e., i x ) are as follows:

The rosenbrock (or banana-valley) function
The function and the initial position range of input variables (i.e., i x ) are as follows:

The ackley's function
The function and the initial position range of input variables (i.e., i x ) is as follows:

The generalized rastrigin function
The function and the initial position range of input variables (i.e., i x ) is as follows:

The generalized griewank function
The function and the initial position range of input variables (i.e., i x ) is as follows:

Economic dispatch(ED) problems with valve-point effects
This simulator also offers examples to solve ED problem for two different power systems: a 3-unit system with valve-point effects, and a 40-unit system with valve-point effects.The total demands of the 3-unit and the 40-unit systems are set to 850MW and 10,500MW, respectively.All the system data and related constraints of the test systems are given in (N.Sinba et al., 2003).Because these systems have more than 3 input variables, the simulator shows a histogram for the generation output instead of the contour and particles.Since the global minimum for the total generation cost is unknown in the case of the 40-unit system, the maximum number of iterations (i.e., max iter ) is set to 10,000 in order to sufficiently search for the minimum value.
Table 2 shows the minimum, mean, maximum, and standard deviation for the 3-unit system obtained from the simulator.The generation outputs and the corresponding costs of the best solution for 3-unit system are described in Table 3.In order to find the optimal combination of parameters (i.e., max ω , min ω , 1 c , and 2 c B), six cases are considered as given in Table 4.The parameters are determined through the experiments for 40-unit system using the simulator.In The result screens for 3-unit and 40-unit system are shown in Figs. 12 and 13, respectively.Each histogram expresses the result of generation output for each generator.

Conclusion
This chapter presents an educational simulator for particle swarm optimization (PSO) and application for solving mathematical test functions as well as ED problems with non-smooth cost functions.Using this simulator, instructors and students can select the test functions for simulation and set the parameters that have an influence on the PSO performance.Through visualization process of each particle and variation of the value of objective function, the simulator is particularly effective in providing users with an intuitive feel for the PSO algorithm.This simulator is expected to be an useful tool for students who study electrical engineering and optimization techniques.
number and Iter is current iteration number.

P
electrical output of generator j; Fig. 7. Optimization process for the sphere function.
Fig. 8. Optimization process for the Rosenbrock function.
Initial and final stages of the optimization process for the generalized Griewank function are shown in Fig.11.

*
Global value of the 3-unit system was known as 8234.0717.T

Table 1 .
Table 1 shows the average values of objective functions and two input variables for each function achieved by the PSO simulator.Results for Each Test Function

Table 3 .
Generation Output of Each Generator and The Corresponding Cost in 3-Unit System