function [BEST,FuncBEST] = Sine_Cosine_Algorithm1 (fobj,N,Lower,Upper,Maxiter)
D=length(Lower);
X=zeros(N,D);
XNEW=zeros(N,D);
fitness=zeros(1,N);
BEST=zeros(1,D);


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

[minval,mindex]=min(fitness);
BEST=X(mindex,:);
 
iter=1;

while(iter <= Maxiter )
    
    for i=1:N
      for j=1:D
           r2=2.0*pi*rand; 
           r3=2.0*rand;    
           r4=rand;
           if (r4<0.5)
             XNEW(i,j)=X(i,j)+(sin(r2)*abs(r3*BEST(j)-X(i,j)));
           else
             XNEW(i,j)=X(i,j)+(cos(r2)*abs(r3*BEST(j)-X(i,j)));
           end        
      end
    end  
     
    X = boundary (X, Lower,Upper,N,D);
    X = update (X,XNEW,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
