 function fobj = TestFunctions (F)
    
    switch F
      case 'F1'
        fobj=@F1;
      case 'F2' 
        fobj=@F2;
      case 'F3'  
        fobj=@F3;
      case 'F4'  
        fobj=@F4;
      case 'F5'  
        fobj=@F5;
      case 'F6'  
        fobj=@F6;  
      case 'F7'  
        fobj=@F7;    
      case 'F8'  
        fobj=@F8;   
      case 'F9'  
        fobj=@F9;    
      case 'F10'  
        fobj=@F10;  
      case 'F11'  
        fobj=@F11;  
      case 'F12'  
        fobj=@F12;  
      case 'F13'  
        fobj=@F13;  
      case 'F14'  
        fobj=@F14;  
      case 'F15'  
        fobj=@F15;  
      case 'F16'  
        fobj=@F16;  
      case 'F17'  
        fobj=@F17;  
      case 'F18'  
        fobj=@F18;  
      case 'F19'  
        fobj=@F19;  
      case 'F20'  
        fobj=@F20;  
      case 'F21'  
        fobj=@F21;  
      end
endfunction      
        
function sum=F1(x)
    %%Sphere function
    m=length(x);
    sum=0;
    for j=1:m
        sum=sum+x(j).*x(j);
    end
endfunction

function sum=F2(x)
    %%Ackley function
     m=length(x);
     sum1=0;
     sum2=0;
     a=20;
     b=0.2;
     c=2*pi;
     for j=1:m
         sum1=sum1+x(j).*x(j);
     end
     for j=1:m
         sum2=sum2+cos(c.*x(j));
     end
     sum=-a.*exp(-b*sqrt(sum1./m))-exp(sum2./m)+a+exp(1);
endfunction

function sum=F3(x)
    %%Rastrigin function
     m=length(x);
     B=10;
     sum3=0;
     for j=1:m
         sum3=sum3+(x(j).*x(j)-B.*cos(2.*pi.*x(j)));
     end
     sum=B.*m+sum3;
endfunction

function sum=F4(x)
    %%Griewank function
     m=length(x);
     sum4=0;
     prod1=1;
     for j=1:m
         sum4=sum4+(x(j)*x(j)/4000);
     end
     for j=1:m
         prod1=prod1*cos(x(j)/sqrt(j));
     end
     sum=sum4-prod1+1;
endfunction

function sum=F5(x)
    %%Zakharov function
     sum5=0;
     sum6=0;
     
     m=length(x);
     for j=1:m
         sum5=sum5+x(j)*x(j);
     end
     for j=1:m
         sum6=sum6+j*x(j);
     end
     sum6=sum6*0.5;
     sum=sum5+sum6*sum6+sum6*sum6*sum6*sum6;
endfunction

function sum=F6(x)
    %%Salomon function
     m=length(x);
     sum7=0;
     for j=1:m
         sum7=sum7+x(j)*x(j);
     end
     sum=1.0-cos(2*pi*sqrt(sum7))+0.1*sqrt(sum7);
endfunction


function sum=F7(x)
       %%Brown function
       m=length(x);
        sum8=0;
        for i=1:m-1
            sum8=sum8+(((x(i)*x(i))^(x(i)*x(i)+1))+((x(i+1)*x(i+1))^(x(i)*x(i)+1)));
        end
        sum=sum8;
endfunction

function sum=F8(x)
       %%Sum of different powers function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+(abs(x(i))^(i+1));
        end
        sum=sum1;
endfunction




function sum=F9(x)
       %%Bent cigar function
        m=length(x);
        sum1=0.0;
        for i=2:m
            sum1=sum1+x(i)*x(i);
        end
        sum=1e6*sum1+x(1)*x(1);
endfunction


function sum=F10(x)
       %%Alpine  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+abs((x(i)*sin(x(i))+0.1*x(i)));
        end
        sum=sum1;
endfunction


function sum=F11(x)
       %%Csendes  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+((x(i)^6)*(2+sin(1/x(i)))) ;
        end
        sum=sum1;
endfunction

function sum=F12(x)
       %%Schaffer  function
        m=length(x);
        sum1=0.0;
        for i=1:m-1
            sum1=sum1+(0.5+(sin(sqrt(x(i)*x(i)+x(i+1)*x(i+1)))*sin(sqrt(x(i)*x(i)+x(i+1)*x(i+1)))-0.5)/((1+0.001*(x(i)*x(i)+x(i+1)*x(i+1)))*(1+0.001*(x(i)*x(i)+x(i+1)*x(i+1))))) ;
        end
        sum=sum1;
endfunction

function sum=F13(x)
       %%Yang2  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+abs(x(i)); 
        end
        sum2=0.0;
        for i=1:m
            sum2=sum2+sin(x(i)*x(i));
        end
        sum2=-sum2;
        sum=sum1*exp(sum2);
endfunction

function sum=F14(x)
       %%Sum squares  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+i*x(i)*x(i); 
        end
        sum=sum1;
endfunction


function sum=F15(x)
       %%Schwefel2_22  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+abs(x(i)); 
        end
        prod1=1.0;
        for i=1:m
            prod1=prod1*abs(x(i)); 
        end
        sum=sum1+prod1;
endfunction


function sum=F16(x)
       %%Deb1  function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+(sin(5*pi*x(i))^6.0); 
        end
        sum=(sum1/m);
endfunction



function sum=F17(x)
       %% Yao Lui function
        m=length(x);
        sum1=0.0;
        for i=1:m
            sum1=sum1+(x(i)*x(i)-10*cos(2*pi*x(i))+10) ; 
        end
        sum=sum1;
endfunction


function sum=F18(x)
       %% Cosine mixture function
        m=length(x);
        sum1=0.0;
        sum2=0.0;
        for i=1:m
            sum1=sum1+cos(5*pi*x(i)) ; 
        end
        for i=1:m
            sum2=sum2+x(i)*x(i);
        end
        sum=0.1*m-0.1*sum1+sum2;
endfunction

function sum=F19(x)
       %% Wavy function
        m=length(x);
        sum1=0.0;
       
        for i=1:m
            sum1=sum1+(1-cos(10*x(i))*exp(-0.5*x(i)*x(i))) ; 
        end
        sum=sum1/m;
endfunction


function sum=F20(x)
       %% Dropwave function
        m=length(x);
        sum1=0.0;
        for i=1:m
          sum1=sum1+(x(i)*x(i));
        end  
         
        sum=-(1.0+cos(12.0*sqrt(sum1)))/(0.5*sum1+2.0);
endfunction

function sum=F21(x)
       %% Yang1 function
        m=length(x);
        sum1=0.0;
        alfa=5.0;
        k=5.0;


       sum1=0.0;
       for i=1:m
           sum1= sum1+(rand*(abs(x(i))^(i)))
       end
       sum=sum1;  
endfunction


function sum=F22(x)
       %% Yang3 function
        m=length(x);
        sum1=0.0;
        mm=5.0;
        beta=15.0;

        sum1=0.0;
        for i=1:m
           sum1 = sum1+((x(i)/beta)^(2*mm))
        end

        prod=1.0;
        for i=1:m
            prod =  prod * (cos(x(i))*cos(x(i)));
        end
        
        sum2=0.0;
        for i=1:D
            sum2= sum2+(x(i)*x(i)); 
        end
        
        sum=exp(-sum1)-2.0*exp(-sum2)*prod;
endfunction

function sum=F23(x)
       %% Yang4 function
        m=length(x);
        sum1=0.0;
        mm=5.0;
        beta=15.0;

        sum1=0.0;
        for i=1:m
           sum1= sum1+(sin(x(i))*sin(x(i)));
        end 

        sum2=0.0;
        for i=1:m
          sum2 = sum2+(x(i)*x(i));
        end

        sum3=0.0;
        for i=1:m
           sum3= sum3+sin(sqrt(abs(x(i))))*sin(sqrt(abs(x(i))));
        end   
        
        sum=(sum1-exp(-sum2))*exp(-sum3);
endfunction


function sum=F24(x)
       %% Raydan1 function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+((i/10)*(exp(x(i))-x(i)));
        end  
        sum=sum1;
endfunction


function sum=F25(x)
       %% Raydan2 function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+(exp(x(i))-x(i));
        end  
        sum=sum1;
endfunction


function sum=F26(x)
       %% Diagonal1 function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+(exp(x(i))-i*x(i));
        end  
        sum=sum1;
endfunction


function sum=F27(x)
       %% Diagonal2 function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+(exp(x(i))-(x(i)/i));
        end  
        sum=sum1;
endfunction

function sum=F28(x)
       %% Diagonal3 function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+(exp(x(i))-(sin(x(i))*i));
        end  
        sum=sum1;
endfunction


function sum=F29(x)
       %% Hager function
        m=length(x);
        sum1=0.0;
        
        for i=1:m
          sum1=sum1+(exp(x(i))-sqrt(i)*x(i));
        end  
        sum=sum1;
endfunction


function sum=F30(x)
       %% Generalized Tridiagonal 1 function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m-1)
          sum1=sum1+ (((x(i)+x(i+1)-3)*(x(i)+x(i+1)-3)) + ((x(i)-x(i+1)+1)*(x(i)-x(i+1)+1)*(x(i)-x(i+1)+1)*(x(i)-x(i+1)+1))) ;
        end  
        sum=sum1;
endfunction

function sum=F31(x)
       %% Diagonal 4 function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m/2)
          sum1=sum1+ (x(2*i-1)*x(2*i-1)  + 100 * x(2*i)*x(2*i))   ;
        end  
        sum=0.5*sum1;
endfunction


function sum=F32(x)
       %% Diagonal 5 function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m)
          sum1=sum1+ log(exp(x(i))+exp(-x(i)))     ;
        end  
        sum=sum1;
endfunction

function sum=F33(x)
       %% Extended Himmelblau function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m/2)
          sum1=sum1+  ((x(2*i-1)*x(2*i-1) + x(2*i) - 11) * (x(2*i-1)*x(2*i-1) + x(2*i) - 11) +  (x(2*i-1) + x(2*i)*x(2*i) - 7) * (x(2*i-1) + x(2*i)*x(2*i) - 7))      ;
        end  
        sum=sum1;
endfunction


function sum=F34(x)
       %% Generalized White & Holst function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m-1)
          sum1=sum1+ (100 * (x(i+1)-x(i)*x(i)*x(i)) * (x(i+1)-x(i)*x(i)*x(i)) + (1-x(i))* (1-x(i)))      ;
        end  
        sum=sum1;
endfunction


function sum=F35(x)
       %% Generalized PSC1 function
        m=length(x);
        sum1=0.0;
        
        for i=1:(m-1)
          sum1=sum1+  ((x(i)*x(i)+ x(i+1)*x(i+1) + x(i)*x(i+1))*(x(i)*x(i)+ x(i+1)*x(i+1) + x(i)*x(i+1))) + sin(x(i))* sin(x(i)) + cos(x(i))* cos(x(i))      ;
        end  
        sum=sum1;
endfunction


function sum=F36(x)
       %% Perturbed quadratic diagonal function 
        m=length(x);
        sum1=0.0;
        for i=1:m
          sum1=sum1+(x(i));
        end
        sum2=sum1*sum1   
        sum3=0
        for i=1:(m)
          sum3=sum3+ ((i/100)*x(i)*x(i))         ;
        end  
        sum=sum2+sum3;
endfunction


function sum=F37(x)
       %% Extended Hiebert function 
        m=length(x);
        sum1=0.0;
        for i=1:(m/2)
          sum1=sum1+ ((x(2*i-1)-10)*(x(2*i-1)-10)) + ((x(2*i-1)*x(2*i)-50000)*(x(2*i-1)*x(2*i)-50000));
        end
        sum=sum1;
endfunction


function sum=F38(x)
       %% Quadratic QF1 function
        m=length(x);
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+ i*x(i)*x(i);
        end
        sum=0.5*sum1-x(m);
endfunction

function sum=F39(x)
       %% Extended quadratic penalty QP1 function 

        m=length(x);
        sum1=0.0;
        for i=1:(m-1)
          sum1=sum1+ (x(i)*x(i)-2)*(x(i)*x(i)-2);
        end
        sum2=0;
        for i=1:m
          sum2=sum2+x(i)*x(i);
        end  
        sum2=(sum2-0.5)*(sum2-0.5)
        sum=sum1+sum2;
endfunction

function sum=F40(x)
       %% Extended quadratic penalty QP2 function 

        m=length(x);
        sum1=0.0;
        for i=1:(m-1)
          sum1=sum1+ (x(i)*x(i)-sin(x(i)))*(x(i)*x(i)-sin(x(i)));
        end
        sum2=0;
        for i=1:m
          sum2=sum2+x(i)*x(i);
        end  
        sum2=(sum2-100)*(sum2-100)
        sum=sum1+sum2;
endfunction


function sum=F41(x)
       %% Diagonal 6 function

        m=length(x);
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+ (exp(x(i))-(1-x(i)));
        end
 
        sum=sum1;
endfunction

function sum=F42(x)
       %% SINE function

        m=length(x);
        sum1=0.0;
        for i=1:(m-1)
          sum1=sum1+ sin(-0.5*x(i+1)+x(i)*x(i));
        end
 
        sum=sum1;
endfunction


function sum=F43(x)
       %% BIGGSB1 function

        m=length(x);
        sum1=(x(1)-1)*(x(1)-1);
        for i=1:(m-1)
          sum1=sum1+  ((x(i+1) - x(i))*(x(i+1) - x(i)));
        end
        sum1=(1-x(m))*(1-x(m));
 
        sum=sum1;
endfunction


function sum=F44(x)
       %% Diagonal7 function

        m=length(x);
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+ exp(x(i))-2*x(i)-x(i)*x(i);
        end
        sum=sum1;
endfunction


function sum=F45(x)
       %% Diagonal8 function

        m=length(x);
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+ x(i)*exp(x(i))-2*x(i)-x(i)*x(i);
        end
        sum=sum1;
endfunction

function sum=F46(x)
       %% Diagonal9 function

        m=length(x);
         
        for i=1:(m-1)
          sum1=sum1+  (exp(x(i))-i*x(i));
        end
        sum1=sum1+10000*x(m)*x(m);
        sum=sum1;
endfunction

function sum=F47(x)
       %% COSINE function

        m=length(x);
         
        for i=1:(m-1)
          sum1=sum1+cos(-0.5*x(i+1)+x(i)*x(i));;
        end
         
        sum=sum1;
endfunction

function sum=F48(x)
       %% Full Hessian FH3 function
        m=length(x);
        sum2=0.0;
        for i=1:m
            sum2=sum2+x(i);
        end
        sum2=sum2*sum2;
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+(x(i)*exp(x(i))-2*x(i)-x(i)*x(i));
        end
         
        sum=sum1+sum2;
endfunction

function sum=F49(x)
       %% LIARWHD function
        m=length(x);
        sum2=0.0;
        for i=1:m
            sum2=sum2+4 * (x(i)*x(i)-x(1))* (x(i)*x(i)-x(1));
        end
        sum1=0.0;
        for i=1:(m)
          sum1=sum1+(x(i)-1)*(x(i)-1);
        end
         
        sum=sum1+sum2;
endfunction


function sum=F50(x)
       %% SINQUAD function
        m=length(x);
        sum3=(x(1)-1)^4;
        sum2=0.0;
        for i=2:(m-1)
            sum2=sum2+ ((sin(x(i)-x(m))-x(1)*x(1)+x(i)*x(i))*(sin(x(i)-x(m))-x(1)*x(1)+x(i)*x(i)));
        end
        sum1=(x(m)*x(m)-x(1)*x(1))*(x(m)*x(m)-x(1)*x(1));
        sum=sum1+sum2+sum3;
endfunction


 










