plz explain error IN PSO CODE
古いコメントを表示
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 件のコメント
Walter Roberson
2018 年 2 月 16 日
CostFunction is returning a struct rather than a numeric value. We would need to see the code to figure out why.
jasleen kaur
2018 年 2 月 17 日
編集済み: Walter Roberson
2018 年 2 月 17 日
jasleen kaur
2018 年 2 月 17 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!