Vous êtes sur la page 1sur 6

USER’S 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 flowchart of subroutines in the RPSO algorithm.

1
Figure 1.1 shows the flowchart of subroutines in the RPSO algorithm. Before starting an
optimization, the optimizer is configured 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 specified in init global.m.
The position and fitness values of all candidate designs encountered in the optimization is
recorded in an output file, and the subroutine convg.m is applied for post-processing.

1.2 Program Initialization


The input parameters need to be specified 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 specified 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: Hooke’s coefficients for modelling attractive forces from


>> 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 modified according to the output file name ‘xxxx’. The post-processing is exe-
cuted 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 :);


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 file ‘output.txt’ is generated.
The post-processing subroutine ‘convg.m’ generates three figures that plot the convergence
curve, the element positions and the radiation pattern of the optimal design, respectively.
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 signif-
icant 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 in-
ternal 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 fitness value f(y) is calcu-
lated in evalfit.m and is finally 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 fitness function is defined as the peak SLL in the sidelobe region. Its value is given to
variable ‘fitness’ and returned.
For a general external evaluator, its .exe file can be called in Matlab by:

>> ! xxxx

where ‘xxxx’ is the name of the executable file. In this case, evalfit.m should also read
the output of the evaluator as the input of the fitness function.

Vous aimerez peut-être aussi