You are on page 1of 6

USERS MANUAL of UCLA-PSO ALGORITHM

(MATLAB VERSION)

Nanbo Jin and Yahya Rahmat-Samii Department of Electrical Engineering University of California, Los Angeles http://www.ee.ucla.edu/antlab April 2007

Chapter 1

Real-Number PSO (RPSO)


1.1 RPSO Program and Subroutines

Figure 1.1: A owchart of subroutines in the RPSO algorithm.

Figure 1.1 shows the owchart of subroutines in the RPSO algorithm. Before starting an optimization, the optimizer is congured by specifying input parameters in init global.m. The subroutine PSO.m contains the main loop that updates V, X, P and G iteratively. In this loop, boundary conditions are implemented by bc fit.m and the evaluator is called by evalfit.m. The main loop is executed for the number of iterations specied in init global.m. The position and tness values of all candidate designs encountered in the optimization is recorded in an output le, and the subroutine convg.m is applied for post-processing.

1.2

Program Initialization

The input parameters need to be specied in init global.m are: 1. NUM AGENTS: The number of agents in a swarm, M . 2. NUMDIM: The dimension of solution space, N . It equals to the number of unknowns in a variable to be optimized. 3. MAX ITER: The number of iterations to execute the optimization. 4. SEED: The optimization is executed without using a seed (a randomly initialized searm) if SEED = 0. The seed specied in seed.mat is used if SEED = 1. 5. VMAX: The fractional maximum velocity of each agent. Its value is typically selected between 0.1 and 0.2. 6. MAX WEIGHT, MIN WEIGHT: The upper and lower limits of the time varying inertia weight. Their values are typically selected as 0.9 and 0.4, respectively. 7. C1, C2: Hookes coecients for modelling attractive forces from the personal and global bests, respectively. Both values are typically selected as 2.0 to balance the nostalgia and social inuences. 8. BC: Boundary conditions. A absorbing; R reecting; I invisible. 9. VAR RANGE: An N 2 matrix that denes the solution space. Each row of the matrix denes the lower and upper limits of the dynamic range in one dimension. 10. NUM TRIALS: The number of optimization trials. Multiple trials are used to investigate the on-average performance of the optimizer. 11. OUTPUT NAME: The name of the output le.

1.3

Running an Optimization and Post-Processing

After initializing the program, the optimizer and be executed by typing: >> PSO in the command window of Matlab. Note that the current working directory must be the directory where the package is located. After the optimization is nished, the total time duration will be displayed, with an output le generated with the name specied in init global.m. The response will be: 2

>> timecost = File convg.m is a post-processing subroutine that plots the convergence curve and necessary properties of the global optimum. In convg.m, the command lines: load xxxx.txt; c = xxxx(1:NUM AGENTS*MAX ITER, :); should be modied according to the output le name xxxx. The post-processing is executed by typing: >> convg in the command window, with the global optimum stored in a variable best design.

1.4

Example: 10-element Low SLL Aperiodic Array

The example shown here is the optimization of a 10-element aperiodic array, as shown in Fig.1.2. The outermost elements are xed at x = 2.250 , and the goal of optimization is to achieve a design with the lowest sidelobe level (SLL) by changing the element positions using PSO.
z

2.25 x1 x2 x3 x4 x5 x

Figure 1.2: A 10-element, symmetric non-uniform array with the outermost elements xed at 2.25 0 for RPSO application. Since the outermost elements are xed and the array is symmetric, there are only four degrees of freedom and the dimension of the solution space is four. Here we use a 20-agent swarm to provide a relatively thorough sampling of the solution space and run the optimization for 200 iterations. The le init global.m has the following input parameters: <init global.m>: NUM AGENTS = 20; NUMDIM = 4; MAX ITER = 200; SEED = 0; VMAX = 0.2; MAX WEIGHT = 0.9; MIN WEIGHT = 0.4; C1 = 2.0; C2 = 2.0; BC = I; 3

VAR RANGE = [0 2.25 0 2.25 0 2.25 0 2.25]; NUM TRIALS = 1; OUTPUT NAME = output.txt; The optimization takes about 20 seconds and an output le output.txt is generated. The post-processing subroutine convg.m generates three gures that plot the convergence curve, the element positions and the radiation pattern of the optimal design, respectively.
4 6 8 10 12 14 16 18 20 0 Convergence of the Optimization Global Best Average Fitness

Fitness Value

50

100 th The N iteration

150

200

Figure 1.3: The global best and average tness value of the RPSO optimization for a 10-element low
SLL non-uniform array.

5 4 3

Element Positions

0 5 10

2 Power Pattern (dB) 0.5 1 1.5 2 1 0 1 2 30 3 4 5 0 35 40 0 15 20 25

x ()

20

40

60 80 100 120 Elevation Angle (deg)

140

160

180

(a)

(b)

Figure 1.4: (a) The element positions and (b) radiation pattern of the optimal design achieved by PSO. Figure 1.3 plots the global best and average tness value at each iteration. The optimal design is observed at the 110th iteration with four inner elements located at: {xi } = {0.210 , 0.600 , 1.060 , 1.590 }. 4 (1.1)

These concrete numbers can be viewed by typing: >> best design in the command window and the Matlab returns: best design = 0.2146

1.5870

1.0612

0.5998

The element locations are plotted in Fig. 1.4(a). Its radiation pattern is plotted in Fig 1.4(b), which has a peak SLL of -19.7dB.

1.5

Building up an Interface Between PSO and the Evaluator

The PSO algorithm only provides the kernel of the optimizer. Generally, the user needs to build up the interface between PSO and the evaluator to accommodate other applications. In our PSO package, it can be implemented by simply modifying evalfit.m without any significant change to other subroutines. In particular, evalfit.m should be programmed with the form of: function fitness = evalfit(x, parms) y = INTERNAL/EXTERNAL EVALUATOR (x); fitness = f(y); The input of the subroutine is a row vector x which represents a candidate design. An internal or external evaluator (it is the analyzer that addresses the desired application) is then called to analyze x, with a result y returned by the evaluator. The tness value f(y) is calculated in evalfit.m and is nally returned to the main subroutine PSO.m. For instance, in the aperiodic array design example shown above, an internal analyzer is applied to calculate the radiation pattern of each candidate design. The analyzer is directly imbedded in evalfit.m. The tness function is dened as the peak SLL in the sidelobe region. Its value is given to variable fitness and returned. For a general external evaluator, its .exe le can be called in Matlab by: >> ! xxxx

where xxxx is the name of the executable le. In this case, evalfit.m should also read the output of the evaluator as the input of the tness function.

You might also like