function [aaa,Ck,bestf]=gloa(func,par,ra,rb) %this is the main gloa function. func:fucntion name; par:number of %parameters; ra:lower bound for solution space; rb:upper bound for solution %space %for convenience, the output can be put in a file instead of disp. % example call [aa,c,b]=gloa(@Rosenbrock,50,-100,100); % tic fnc=func;%str2func(func); %func to be optimized iter=2000; %Max iteration gr=10;%number of groups ch=25;%Population in each group pr=par;%number of parameters r2=0.1;%the rates for the leader, itself and the random in mutation r1=0.8; r3=1-r1-r2; q=par/2+1;%*0.5;%determines the transfer rate a=ra; b=rb;%solution space aaa=[0 0];%keeps the output c=(b-a); x=a+c*rand(ch,pr,gr); %initial populations %initial evaluation of the population for i=1:gr for j=1:ch F(j,1,i)=fnc(x(j,:,i)); end end %leaders are assigned to each group for i=1:gr; [~,I]=min(F(:,1,i)); Father(:,:,i)=x(I,:,i); end %The main body of the algorithm for it=1:iter; for i=1:gr; for j=1:ch; %the mutation step A = (r1)*x(j,:,i)+r2*Father(:,:,i)+r3*(a+c*rand); NEW1=fnc(A); if(NEW1