Can anyone check my Objective function for GSA and ABC?
1 view (last 30 days)
Show older comments
Iam using standard Gravitational Search Algorithm (GSA) and Standard Artificial Bee Colony (ABC) to run this objective function...
function f=cuba_objfun(x,Initial_St,others,Dm)
%clear all
%clc
Initial_St=6.7;
%p=1;%input('inflow condition'); %high=1, medium=2, low=3, avg=6
x=21.25+(64.28-21.25)*rand(100,12);
filename='Inflowtest.xlsx';
a=xlsread(filename);
%a=alldata;
popsize=50;
D=12;
I=(a(:,1))';
L=(a(:,3))';
others=(I-L);
Dm=(a(:,4))';
[popsize D]=size(x);
for j=1:popsize %no. of row
for i=1:D;
S(j,1)=Initial_St; %initial storage
if i<12
S(j,i+1)=S(j,i)-x(j,i)+others(1,i); %final storage
end
end
end
for c=1:popsize
for d=1:D
release(c,d)=((x(c,d)-Dm(1,d)).^2); %water deficit
sqdev=(sum(release'))';
end
end
for k=1:popsize;
for l=1:D;
if 54.38-S(k,l)<0
penalty1(k,l)=((54.38-S(k,l)).^2); %penalty term 1
else penalty1(k,l)=0;
end
if S(k,l)-6.7<0
penalty2(k,l)=((32-S(k,l)).^2); %penalty term 2
else penalty2(k,l)=0;
end
g1=(sum(penalty1'))';
g2=(sum(penalty2'))';
end
end
g=10000*g1+10000*g2;
f=(sqdev+g);
end
I have this error for ABC = *"In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in test_runABC (line 112) Fitness(i)=FitnessSol;"*
and I have this error for GSA Error registering event(s), Advise failed
Error in registerevent>addevent (line 148) list(m+1) = handle.listener(h, eventname, {@comeventcallback, eventhandler});
Error in registerevent (line 94) addevent(h, event, eventhandler);
Error in xlsreadCOM (line 11) Excel.registerevent({'WorkbookActivate', @WorkbookActivateHandler});
Error in xlsread (line 230) [numericData, textData, rawData, customOutput] = xlsreadCOM(file, sheet, range, Excel, customFun);
Error in test_functions (line 17) a=xlsread(filename);
Error in evaluateF (line 15) fitness(i)=test_functions(L,F_index,dim);
Error in GSA (line 41) fitness=evaluateF(X,F_index);
Error in main (line 29) [Fbest,Lbest,BestChart,MeanChart]=GSA(F_index,N,max_it,ElitistCheck,min_flag,Rpower);Fbest;
Can any Expert on GSA and ABC check my Objective Function? Thank you in Advance
Asmadi
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!