Error in evolutionary ANFIS training in MATLAB

1 visualizzazione (ultimi 30 giorni)
I am getting the following error while training ANFIS using Particle Swarm Optimization (PSO):
Error using fismf/set.params
Gaussian membership function must have positive sigma value.
Error in SetFISParams (line 21)
fis.input(i).mf(j).params=p(1:k);
Error in TrainFISCost (line 26)
fis=SetFISParams(fis,p);
Error in TrainAnfisUsingPSO>@(x)TrainFISCost(x,fis,data) (line 20)
Problem.CostFunction=@(x) TrainFISCost(x,fis,data);
Error in TrainAnfisUsingPSO>RunPSO (line 106)
particle(i).Cost=CostFunction(particle(i).Position);
Error in TrainAnfisUsingPSO (line 32)
results=RunPSO(Problem,Params);
I have attached the following functions used in the code. Kindly guide me how to resolve the issue?

Risposta accettata

Walter Roberson
Walter Roberson il 2 Mag 2023
Problem.nVar=numel(p0);
Problem.VarMin=-25;
Problem.VarMax=25;
You set the minimum and maximum for each FIS parameter to -25 to +25, no matter what the role is of the parameter. However, the sigma parameters cannot be negative.
% Apply Position Limits
particle(i).Position = max(particle(i).Position,VarMin);
particle(i).Position = min(particle(i).Position,VarMax);
That particular code would be fine for the case where VarMin and VarMax were vectors the same size as Position, instead of being scalars, to allow the min and max to be set individually for each variable.
% Velocity Mirror Effect
IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside);
I was thinking for a moment that this code would have a problem if VarMin and VarMax were vectors, but looking at the code again, as long as they were vectors the same size as Position the code should be fine.
So... you should be setting VarMin and VarMax to be vectors with limits that depend upon the role of the associated variable. And make sure the vector orientation is the same as will be used for Position
In practice you might need to add additional kinds of constraints, as some FIS that accept range limits, expect those limits to be strictly increasing, whereas your code would (easily!) exchange maximum and minimum.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by