function [BEST,FITBEST] = Archimedes_Optimization_Algorithm (Func_name,N,Lower,Upper,Maxiter)

fobj = TestFunctions (Func_name);
D=length(Lower);
X=zeros(N,D);
XNEW=zeros(N,D);
den=zeros(N,D);
vol=zeros(N,D);
acc=zeros(N,D);
acc_norm=zeros(N,D);
acc_temp=zeros(N,D);

den_best=zeros(1,D);
vol_best=zeros(1,D);
acc_best=zeros(1,D);

BEST=zeros(1,D);  
fitness=zeros(1,N);
 
C1=2.0;
C2=6.0;
C3=1.0;
C4=2.0;
u=0.9;
l=0.1;

 

for i=1:N
  for j=1:D
    X(i,j)=Lower(j)+(Upper(j)-Lower(j))*rand;
    acc(i,j)=Lower(j)+(Upper(j)-Lower(j))*rand;
    den(i,j)=rand;
    vol(i,j)=rand;
    acc_norm(i,j)=acc(i,j);
   end
   fitness(i)=fobj(X(i,:));
end

[minval,mindex]=min(fitness);
BEST=X(mindex,:);
den_best=den(mindex,:);
vol_best=vol(mindex,:);
acc_best=acc(mindex,:);

iter=1;

while(iter <= Maxiter)
    
    TF=exp((iter-Maxiter)/Maxiter);
    if(TF>1)
      Tf=1.0;
    end
    d=exp((Maxiter-iter)/Maxiter)-(iter/Maxiter);
    
    acc=acc_norm;
    
    for i=1:N
      for j=1:D
        den(i,j)=den(i,j)+rand*(den_best(j)-den(i,j));
        vol(i,j)=vol(i,j)+rand*(vol_best(j)-vol(i,j));
        if (TF<0.45)
          mrand=ceil(rand*N);
          acc_temp(i,j)=(den(mrand,j)+(vol(mrand,j)*acc(mrand,j)))/(rand*den(i,j)*vol(i,j));
        else
          acc_temp(i,j)=(den_best(j)+(vol_best(j)*acc_best(j)))/(rand*den(i,j)*vol(i,j));
        end
      end
    end
  
    for i=1:N
      for j=1:D
        acc_norm(i,j)=u*((acc_temp(i,j)-min(min(acc_temp)))/(max(max(acc_temp))-min(min(acc_temp))))+l;
      end
    end

    for i=1:N
      if(TF<0.4)
         for j=1:D
           mrand2=ceil(rand*N);
           XNEW(i,j)=X(i,j)+C1*rand*acc_norm(i,j)*(X(mrand2,j)-X(i,j))*d;
         end
      else
         for j=1:D
           p=2.0*rand-C4;
           T=C3*TF;
             if(T>1.0)
                T=1.0;
             end 
             if(p<0.5)
                 XNEW(i,j)=BEST(j)+C2*rand*acc_norm(i,j)*(T*BEST(j)-X(i,j))*d;
             else
                 XNEW(i,j)=BEST(j)-C2*rand*acc_norm(i,j)*(T*BEST(j)-X(i,j))*d;
             end
          end
       end
    end  
   
    XNEW=boundary (XNEW, 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,:);
     den_best=den(mindex,:);
     vol_best=vol(mindex,:);
     acc_best=acc(mindex,:);
     FITBEST=minval;
    iter=iter+1;
end





endfunction
