Initial Position of PSO
2 次查看(过去 30 天)
显示 更早的评论
Hi There,
How do I initiate an initial position for PSO when moving from position to another.. I'm using class below to initiate my particles.
classdef sample_particle
properties
swarm = [];
index = 1;
end
methods
function [ obj ] = sample_particle( varargin )
% set the position of the initial swarm
for i = 1 : 8
for j = 1 : 8
obj.swarm(obj.index, 1, 1) = i;
obj.swarm(obj.index, 1, 2) = j;
obj.index = obj.index + 1;
end
end
obj.swarm(:,2,:) = 0; % set initial velocity for particles
obj.swarm(:,4,1) = inf; % set the best value so far
end
end
end
and objective function and end point
function [ z ] = objfcn_02( x )
x1=x(:,1); % starting X position
y1=x(:,2); % starting y position
x2=10; % ending X position
y2=10; % ending y position
z = sqrt((x1-x2).^2+(y1-y2).^2);
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle Swarm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!