function [FoodPos,FoodFit]  = Salp_Swarm_Optimization1 (fobj,N,Lower,Upper,Maxiter)
D=length(Lower);
SalpFit=zeros(1,N);
FoodPos=zeros(1,D);
SalpPos=zeros(N,D);
XNEW=zeros(N,D);
FoodFit=1E+200;


for i=1:N
  for j=1:D
    SalpPos(i,j)=Lower(j)+(Upper(j)-Lower(j))*rand;
  end
  SalpFit(i)=fobj(SalpPos(i,:));
end
 
 SalpPos = sortX (SalpPos,fobj,N,D);
 
 FoodPos=SalpPos(1,:);
 foodFit=fobj(FoodPos);
 
 iter=1;
 
 while (iter <= Maxiter)

     c1 = 2*exp(-(4*iter/Maxiter)^2);
     
     for i = 1 : N
        if (i <= N/2)
          if (rand < 0.5)
            SalpPos(i,:)=FoodPos+c1.*((Upper-Lower).*rand+Lower);
          else
            SalpPos(i,:)=FoodPos-c1.*((Upper-Lower).*rand+Lower);
          end
        elseif ((i>N/2) && (i<=N))
            SalpPos(i,:)=0.5.*(SalpPos(i,:)+SalpPos(i-1,:));
        end
     end
  
     SalpPos = boundary (SalpPos, Lower,Upper,N,D);
     
     for i=1:N
       SalpFit(i)=fobj(SalpPos(i,:));
       if SalpFit(i) < FoodFit
         FoodPos=SalpPos(i,:);
         FoodFit=SalpFit(i);
       end  
     end
    
     SalpPos = sortX (SalpPos,fobj,N,D);
  
     iter=iter+1;
      
    
    
 end 

endfunction
