function hodnota = FUNKCE (param,D,CisFce,A,C,alp)
%funkce vypocita funkcni hodnotu zadane funkce D promennych 
PI=3.141592654;

switch CisFce

    case 1
%%%%%%%%%%%%%%%% 4th De Jong                %%%% min=0
%%%%%%%%%%%%%%% xe(-1.28,1.28)              %%%% max(1D)=(1.28^4)*(1+2+...+D) 
hodnota=0;
for a=1:1:D
    hodnotaPom = a*(param(a))^4;
    hodnota=hodnota+hodnotaPom;
end

    case 2
%%%%%%%%%%%%%% 1st De Jong   %%%% min=0
%%%%%%%%%%%%%%% xe(-5,5)    %%%% max(1D)=25
hodnota=0;
for a=1:1:D
    hodnotaPom = (param(a))^2;
    hodnota=hodnota+hodnotaPom;
end

    case 3
%%%%%%%%%%%%%%% Rosebrocks saddle     %%%% min=0 
%%%%%%%%%%%%%%% xe(-2.048,2.048)      %%%% max(1D)=1768.5 jen zhruba pro
%%%%%%%%%%%%%%% vyssi dimenze
hodnota=0;
for a=1:1:D-1
    hodnotaPom = (100*(-param(a)*param(a)+param(a+1))^2+(1-param(a))^2);
    hodnota=hodnota+hodnotaPom;
end
    
    case 4
%%%%%%%%%%%%%%% 3rd De Jong           %%%% min=0
%%%%%%%%%%%%%%% xe(-2.048,2.048)      %%%% max(1D)=2.048
hodnota=0;
for a=1:1:D
    hodnotaPom = abs(param(a));
    hodnota=hodnota+hodnotaPom;
end
    
    case 5
%%%%%%%%%%%%%%% Rastringins function      %%%% min=0
%%%%%%%%%%%%%%% xe(-5.12,5.12)            %%%% max(1D)=607.8
hodnota=0;
for a=1:1:D
    hodnotaPom = (param(a)^2)-10*cos(2*PI*param(a));
    hodnota=hodnota+hodnotaPom;
end
hodnota=10*D+hodnota;

    case 6
%%%%%%%%%%%%%%% Schwefels function        %%%% min=-D*418.9829
%%%%%%%%%%%%%%% xe(-500,500)              %%%% max(1D)=D*418.9829
hodnota=0;
for a=1:1:D
    hodnotaPom = -param(a)*sin(sqrt(abs(param(a))));
    hodnota=hodnota+hodnotaPom;
end
    
    case 7
%%%%%%%%%%%%%%% Grienwangks function      %%%% min=0 
%%%%%%%%%%%%%%% xe(-100,100)              %%%% max(1D)=

hodnotaPom1=0;
hodnotaPom2=1;

for a=1:1:D
    hodnotaPom1 = hodnotaPom1+(param(a)^2)/4000;
    hodnotaPom2 = hodnotaPom2*cos(param(a)/(sqrt(a)));
end
hodnota=1+hodnotaPom1-hodnotaPom2;

    case 8
%%%%%%%%%%%%%%% Michalewiczs function      %%%% min(10)=-9.66
%%%%%%%%%%%%%%% xe(-5,5)                  %%%% max(1D)=0.966  zhruba
hodnota=0;
m=10;
for a=1:1:D
hodnotaPom=-sin(param(a))*(sin((a*param(a)^2)/PI))^(2*m);    
hodnota=hodnota+hodnotaPom;
end


    case 9
%%%%%%%%%%%%% Easom function       %%%% min=-1 pro x = pi
%%%%%%%%%%%%%% xe(-50,50)        %%%% max(1D)=0 
hodnota=0;

for a=1:1:D-1
   hodnotaPom=-cos(param(a)).*cos(param(a+1)).*exp(-((param(a)-3.1415).^2)-((param(a+1)-3.1415).^2)); 
   hodnota=hodnota+hodnotaPom;
end

    case 10
%%%%%%%%%%% Salomon function       %%%% min=0
%%%%%%%%%%%%%%% xe(-4,4)          %%%% max(1D)=0
hodnotaPom=0;

for a=1:1:D
   hodnotaPom=hodnotaPom+(param(a)^2);    
end

hodnota=-cos(2*PI*sqrt(hodnotaPom))+0.1*(hodnotaPom)+1;

 case 11
%%%%%%%%%%%%%%%% ACKLEY       %%%% min=0
%%%%%%%%%%%%%% xe(-30,30)    %%%% max(1D)=
a=20; b=0.2; c=2*PI;s1=0;s2=0;
for i=1:1:D
  s1 =s1+ cos(c*param(i));
  s2=s2+param(i)^2;
end
hodnota=-a*exp(-b*sqrt(s2/D))-exp(s1/D)+a+exp(1);


    case 12
%%%%%%%%%%%%%%%% Step shpere model    %%%% min=0
%%%%%%%%%%%%%%% xe(-5;5)              %%%% max(1D)=(1.28^4)*(1+2+...+D)
hodnota = 0;
for a = 1 : 1 : D
    hodnotaPom = (round(param(a)))^2;
    hodnota = hodnota + hodnotaPom;
end

    case 13
%%%%%%%%%%%%%%%% Fletcher and Powel function %%%% min=0
%%%%%%%%%%%%%%% xe(-pi,pi)              
hodnota = 0;
for a = 1 : 1 : D
    if (length(param) == D)
        Ai = sum(A(a,:).*sin(alp) + C(a,:).*cos(alp));
        Ci = sum(A(a,:).*sin(param') + C(a,:).*cos(param'));
    else
        Ai = sum(A(a,:).*sin(alp) + C(a,:).*cos(alp));
        Ci = sum(A(a,:).*sin(param(1:end-1)') + C(a,:).*cos(param(1:end-1)'));
    end
    hodnotaPom = (Ai - Ci)^2;
    hodnota = hodnota + hodnotaPom;
end
end
