Function: 'Buffalo (I,:) BP - K (I) '
Function: 'Buffalo (I,:) BP - K (I) '
clear
clc
if nargin<1,
% Number of buffalos (or different solutions)
n=10;
end
% list of paramters
m_k=0;
lp1=0.7;
lp2=0.5;
bg=0;
w_k=0;
N_IterTotal=2000;
nd=2; %% Simple bounds of the search domain
Lb=0*ones(1,nd); % Lower bounds
Ub=15*ones(1,nd); % Upper bounds
%beala function
% [ x , y ]
Lb= [-4.5, -4.5];
Ub= [4.5, 4.5];
% tuning = 20;
sum =0;
% overall_best = fobj(Lb+(Ub-Lb).*rand(size(Lb)));
for t=1:1;
end
% % for test
% buffalo(1,:)=[7, 9];
% buffalo(2,:)=[11, 15];
% buffalo(3,:)=[4, 15];
% for i=1:3,
% % buffalo(i,:)=Lb+(Ub-Lb).*rand(size(Lb));
% w_array(i,:)= buffalo(i,:);
% bp_k(i,:)= buffalo(i,:);
% disp(strcat(num2str(buffalo(i,:)),' =[',num2str(bp_k(i)),']'));
% end
% best_buffalo=[11, 15];
[fmin,best_buffalo,buffalo,fitness]=get_best_buffalo(buffalo,buffalo,fitness);
% best_buffalo=[11, 15];
N_iter=0;
%% Starting iterations
for iter=1:N_IterTotal,
for jj=1:n
s=buffalo(jj,:);
w=w_array(jj,:);
%disp(strcat(num2str(jj),' - buffalo before:[',num2str(s),']'));
% Step2. Update the buffalos exploitation using Equation (3.1)
s=s + lp1*(best_buffalo-w)*rand + lp2*(bp_k(jj,:)*rand - w);
disp(strcat(num2str(jj),' - buffalo after :
[',num2str(s),']=',num2str(fobj(s))));
end
% disp(strcat('bestbuffalo :[',num2str(best_buffalo),'] =
',num2str(fmin),''));
%buffalo
end %% End of iterations
end
%Avg= sum/tuning;
%Avg
%overall_best
%overall_best_buffalo
%% Post-optimization processing
%% Display all the buffalos
% disp(strcat('Total number of iterations=',num2str(N_iter)));
% fmin
% best_buffalo
% fmin
%buffalo
% a = 1;
% b = 5.1/(4*3.14^2);
% c = 5/pi;
% r = 6;
% s = 10 ;
% t = 1/(8*pi);
%
% term1 = a * (x(2) - b*x(1)^2 + c*x(1) - r)^2;
% term2 = s*(1-t)*cos(x(1));
% f = term1 +term2 +s;
%
%
% f= (x(2)-(5.1/(4*pi^2))*x(1)^2+5*x(1)/pi-6)^2+10*(1-1/(8*pi))*cos(x(1))+10;
%
%
% frac1 = 1 + cos(12*sqrt(x(1)^2+x(2)^2));
% frac2 = 0.5*(x(1)^2+x(2)^2) + 2;
%
% f = -frac1/frac2;
%
%
%
% f= (1.5-x(1)*(1-x(2)))^2+(2.25-x(1)*(1-x(2)^2))^2+(2.625-x(1)*(1-x(2)^3))^2
% n = 25;
% s1 = 0;
% for j = 2:n;
% s1 = s1+j*(2*x(j)^2-x(j-1))^2;
% end
% y = s1+(x(1)-1)^2;