Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
%Assignment#9
% Human group optimization (originally named as Seeker optimization algorithm)
clc;
clear all;
close all;
human=randi([2 30],5,5);
for r=1:5;
for c=1:5;
X(r,c)=human(r,c)^3;
end
human_group=sum(X,2);
end
minimum=min(human_group);
[val loc]=min(human_group);
Gbest=find(human_group==minimum);
LB=2; %Lower bound
UB=12; %upper bound
Ml=1; %Minimum no. of mental process
Mh=100; %Miximum no. of mental process
Npop=50; %no. of bids
Nvar=10; %no. of variable
K=10; %no. of cluster
iter_min=1; %Current iteration
iter_max=10;%Maximum no. of iteration
a=rand(); %a is a random number
N=20;
t=iter_min; % t is Current iteration
%X = initialise population of Npop bids
X=Npop*human;
% Calculate the cost function values of bids
bids = 0;
for r=1:5;
bids= bids + X;
end
bids= bids/X;
bid=max(bids);
bestbids=find(bids==bid);
%find the best bid in the initial population
Gbest;
%generate random number between LowerBound and UpperBound
for r=1:5;
Beta=randsrc(1,1,[LB:UB]);
end
Beta
Y=gamma(X);
for r=1:5;
Q=((Y(1+Beta)*sin(pi*Beta/2))*(Y*(1+Beta/2)*Beta*2^(Beta-1/2)))^1/Beta;
end
u=N*(0*Q^2);
v=N*(0*Q^2);
for iter_min=1:iter_max;
MentalSearch=(2-iter_min*(2/iter_max))*a*u/v^1/Beta*(X-Gbest);
end
%generate integer random number between Ml and Mh
for r=1:5;
qi=randsrc(1,1,[Ml:Mh]);
end
qi
for r=1:5;
for c=1:qi;
MentalSearch=(2-iter_min*(2/iter_max))*a*u/v^1/Beta*(X-Gbest);
NextSearch=X+MentalSearch;
end
if t<X;
X=t;
end
end
%Clustering
%Cluster Npop bids into K clusters
for r=5;
K=K/Npop;
end
%Calculate the mean cost function value of each cluster
for r=1:5;
MeancostK=mean(K);
end
% Select cluster with lowest mean cost function value as the winner cluster
lowestmeanK=min(MeancostK);
winner=find(bids==lowestmeanK);
C=0;
r=rand();
bidn=0;
bidn=bidn+C*(r*winner-bidn);
for r=1:5;
for c=1:5;
X=X+C*(r*winner-X);
end
end
%generate random number between LowerBound and UpperBound
for r=1:5;
Beta=randsrc(1,1,[LB:UB]);
end
Beta
% find best bid in current bids
for r=1:5;
bestb=max(bestbids);
xplus=bestb;
end
if xplus<Gbest;
Gbest=xplus;
end
Gbest
0 Kommentare
Antworten (1)
Mehmed Saad
am 13 Mai 2020
Bearbeitet: Mehmed Saad
am 13 Mai 2020
Y=gamma(X)
Y =
Inf Inf Inf Inf 9.33262154439440e+155
Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf
Inf Inf 3.80892263763056e+260 Inf Inf
Inf Inf Inf Inf Inf
So it is giving you inf in Y which are then shifted to Q, Then you multiply Q with zero in u=N*(0*Q^2) making u NaN. Similarly v also contains NaNs. The step that contains u/v will then give you warning
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!