 

function [Globalminimizer,Globalminimum] = Differential_Search (Func_name,N,Lower,Upper,Maxiter)


fobj = TestFunctions (Func_name); 
D=length(Lower);
Superorganism=zeros(N,D);
Stopoversite=zeros(N,D);
donor=zeros(N,D);
r=zeros(N,D);
Globalminimizer=zeros(1,D);
Globalminimum=1E+200;
yStopoversite=zeros(1,N);
ySuperorganism=zeros(1,N);

for i=1:N
  for j=1:D
    Superorganism(i,j)=Lower(j)+(Upper(j)-Lower(j))*rand;
  end
  ySuperorganism(i)=fobj(Superorganism(i,:));
end

iter=1;

while(iter <= Maxiter)
    
    donor=Superorganism(randperm(N),:);
    p1=0.3*rand;
    p2=0.3*rand;
       if(rand < rand)
            if (rand < p1)
                 for i=1:N
                     for j=1:D
                         if (rand < rand)
                             r(i,j)=1.0;
                         end
                     end
                 end
             else
                 for i=1:N
                   r(i,randi(D))=1.0;
                 end  
             end
        else
             for j=1:D
                 aa(j)=ceil(p2*D);
             end    
             
             r(i,aa)=1.0;
        end
        Scale=4*randn;
        Stopoversite=Superorganism+(Scale.*r).*(donor-Superorganism);
        
        Stopoversite = boundary (Stopoversite, Lower,Upper,N,D);
        
        for i=1:N
          yStopoversite(i)=fobj(Stopoversite(i,:));
          if(yStopoversite(i) < ySuperorganism(i))
             ySuperorganism(i)=yStopoversite(i);
             Superorganism(i,:)=Stopoversite(i,:);
          end   
        end  
        
        [fitnessbest,mindex]=min(ySuperorganism);
        if(fitnessbest < Globalminimum)
            Globalminimum=fitnessbest;
            Globalminimizer=Superorganism(mindex,:);
        end
    
        iter=iter+1;  
end        
        
endfunction
