plz explain error IN PSO CODE
Afficher commentaires plus anciens
Undefined operator '<' for input arguments of type 'struct'.
Error in TrainAnfisUsingPSO>RunPSO (line 103)
if particle(i).Best.Cost<BestSol.Cost
CODE IS HERE:
empty_particle.Position=[];
empty_particle.Cost=[];
empty_particle.Velocity=[];
empty_particle.Best.Position=[];
empty_particle.Best.Cost=[];
particle=repmat(empty_particle,nPop,1);
BestSol.Cost=inf;
for i=1:nPop
% Initialize Position
if i>1
particle(i).Position=unifrnd(VarMin,VarMax,VarSize);
else
particle(i).Position=ones(VarSize);
end
% Initialize Velocity
particle(i).Velocity=zeros(VarSize);
% Evaluation
particle(i).Cost=CostFunction(particle(i).Position);
% Update Personal Best
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
% Update Global Best
var1=particle(i).Best.Cost;
var2=BestSol.Cost;
if particle(i).Best.Cost<BestSol.Cost %this line
BestSol=particle(i).Best;
end
end
3 commentaires
Walter Roberson
le 16 Fév 2018
CostFunction is returning a struct rather than a numeric value. We would need to see the code to figure out why.
jasleen kaur
le 17 Fév 2018
Modifié(e) : Walter Roberson
le 17 Fév 2018
jasleen kaur
le 17 Fév 2018
Réponses (0)
Catégories
En savoir plus sur Particle Swarm dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!