필터 지우기
필터 지우기

Initial Position of PSO

조회 수: 4 (최근 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