Borrar filtros
Borrar filtros

Initial Position of PSO

2 visualizaciones (últimos 30 días)
Ali Ali
Ali Ali el 28 de Sept. de 2018
Editada: Ali Ali el 28 de Sept. de 2018
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

Respuestas (0)

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by