MATLAB: Explanation about the boundaries at the Particle Swarm Optimization

boundariesparticle swarm optimization

Hey.
I'm a freshman with the handling from Matlab and I have a question for the particle swarm optimization. Attached you can see my script for the PSO and the function (Rosenbrock function).
I have a question about VarMin and VarMax variables. These variables define the upper and lower bound. But when I define for example:
VarMin = 0
VarMax = 5
nVar = 5
Then of course I get for the GlobalBest a vector with 5 columns. For example:
Position: [3.7542e-04 -8.0293e-04 -0.0011 1.1266e-04 1.5088e-04]
How is this possible? There are negative values. And I defined the minimum boundary with zero.
I hope you can help me with my understanding problem.
Kind regards

Best Answer

The only place you use VarMin and VarMax is the line
particle(i).Position = unifrnd(VarMin, VarMax, VarSize);
to initialize the values.
However, as the particle moves, the velocity could easily have it go below VarMin or above VarMax, since you do not catch that it hits those boundaries.
You need to program in a test for hitting the boundaries, and you need to decide what you want to do with that case.