function [BEST, FuncBEST] = Differential_Evolution1(fobj,N,Lower,Upper,Maxiter)
D=length(Lower);
X=zeros(N,D);
Y=zeros(N,D);
BEST=zeros(1,D);
fitness=zeros(1,N);
CR=0.5;

for i=1:N
  for j=1:D
    X(i,j)=Lower(j)+(Upper(j)-Lower(j))*rand;
  end
  fitness(i)=fobj(X(i,:));
end
iter=1;
  while(iter <= Maxiter)
      
    for i=1:N
      
       k1=ceil(N*rand);
       k2=ceil(N*rand);
       k3=ceil(N*rand);
   
       while(i==k1)
           k1=ceil(N*rand);
       end
             
       while((k1==k2)||(i==k2))
           k2=ceil(N*rand);
       end
       
       while((k2==k3)||(k1==k3)||(i==k3))
           k3=ceil(N*rand);
       end
       
       jrand=ceil(rand*D);
   
         for j=1:D
             if ((rand < CR) || (j==jrand))
                 Y(i,j)=X(k1,j)+rand*(X(k2,j)-X(k3,j));
             else
                 Y(i,j)=X(i,j);
             end
         end
    end     
       Y = boundary (Y, Lower,Upper,N,D); 
    
       X=update (X,Y,fobj);
       for i=1:N
         fitness(i)=fobj(X(i,:));
       end
       [minval,mindex]=min(fitness);
       BEST=X(mindex,:);
       FuncBEST=fobj(BEST);  
     
       iter=iter+1;
       
  end


endfunction
