The toolbox has an error in the actualization of the
velocities
% Calculate Velocity
if ~psoOptions.Flags.Neighbor %Normal
VStep = w_now*VStep +
psoOptions.SParams.c1*R1.*(PBest-Swarm) +
psoOptions.SParams.c2*R2.*(A-Swarm);
else %With neighborhood
R3 = rand(SwarmSize, psoOptions.Vars.Dim);
%random nos for neighborhood
VStep = w_now*VStep +
psoOptions.SParams.c1*R1.*(PBest-Swarm) +
psoOptionsSParams.c2*R2.*(A-Swarm) +
psoOptionsSParams.c3*R3.*(B-Swarm);
end
%Adding Chi Actualization (Correction)
VStep = psoOptions.SParams.Chi * VStep
% Apply Vmax Operator for v > Vmax
changeRows = VStep > psoOptions.SParams.Vmax;
VStep(find(changeRows)) = psoOptions.SParams.Vmax;
% Apply Vmax Operator for v < -Vmax
changeRows = VStep < -psoOptions.SParams.Vmax;
VStep(find(changeRows)) = -psoOptions.SParams.Vmax;
% ::UPDATE POSITIONS OF PARTICLES:: (Corrected)
Swarm = Swarm + VStep; % Evaluate new Swarm