Initial Position of PSO

2 次查看(过去 30 天)
Ali Ali
Ali Ali 2018-9-28
编辑: Ali Ali 2018-9-28
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 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by