单峰测试函数部分
F1:Sphere Function
$$ f_1\left( x \right) =\sum_{i=1}^{30}{x_{i}^{2}},\quad-100\leqslant x_i\leqslant 100 $$
$$ \min \left( f_1 \right) =f_1\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F1(x)
o=sum(x.^2);
end
F2:Schwefel's Problem 2.22
$$ f_2\left( x \right) =\sum_{i=1}^{30}{\left| x_i \right|}+\prod_{i=1}^{30}{\left| x_i \right|},\quad-10\leqslant x_i\leqslant 10 $$
$$ \min \left( f_2 \right) =f_2\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F2(x)
o=sum(abs(x))+prod(abs(x));
end
F3:Schwefel's Problem 1.2
$$ f_3\left( x \right) =\sum_{i=1}^{30}{\left( \sum_{j=1}^i{x_j} \right) ^2},\quad-100\leqslant x_i\leqslant 100 $$
$$ \min \left( f_3 \right) =f_3\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F3(x)
dim=size(x,2);
o=0;
for i=1:dim
o=o+sum(x(1:i))^2;
end
end
F4:Schwefel's Problem 2.21
$$ f_4\left( x \right) =\max \left\{ \left| x_i \right|,\quad1\leqslant i\leqslant 30 \right\} ,-100\leqslant x_i\leqslant 100 $$
$$ \min \left( f_4 \right) =f_4\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F4(x)
o=max(abs(x));
end
F5:Generalized Rosenbrock's Function
$$ f_5\left( x \right) =\sum_{i=1}^{30}{\left[ 100\left( x_{i+1}-x_{i}^{2} \right) ^2+\left( x_i-1 \right) ^2 \right]},\quad-30\leqslant x_i\leqslant 30 $$
$$ \min \left( f_5 \right) =f_5\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F5(x)
dim=size(x,2);
o=sum(100*(x(2:dim)-(x(1:dim-1).^2)).^2+(x(1:dim-1)-1).^2);
end
F6:Step Function
$$ f_5\left( x \right) =\sum_{i=1}^{30}{\left( \left| x_i+0.5 \right| \right) ^2},\quad-100\leqslant x_i\leqslant 100 $$
$$ \min \left( f_6 \right) =f_6\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F6(x)
o=sum(abs((x+.5)).^2);
end
F7:Quartic Function i.e. Noise
$$ f_5\left( x \right) =\sum_{i=1}^{30}{ix_{i}^{4}+random\left[ \text{0,}1 \right)},\quad-1.28\leqslant x_i\leqslant 1.28 $$
$$ \min \left( f_7 \right) =f_7\left( \text{0,}\cdots ,0 \right) =0 $$
function o = F7(x)
dim=size(x,2);
o=sum([1:dim].*(x.^4))+rand;
end
多峰测试函数部分
F8:Generalized Schwefel's Problem 2.26
$$ \begin{aligned} f_{8}(x)=&-\sum_{i=1}^{30}\left(x_{i} \sin \left(\sqrt{\left|x_{i}\right|}\right)\right), \quad-500 \leq x_{i} \leq 500 \\ & \min \left(f_{8}\right)=f_{8}(420.9687, \cdots, 420.9687)=-12569.5 \end{aligned} $$
function o = F8(x)
o=sum(-x.*sin(sqrt(abs(x))));
end
F9:Generalized Rastrigin's Function
$$ \begin{aligned} f_{9}(x)=&\left.\sum_{i=1}^{30}\left[x_{i}^{2}-10 \cos \left(2 \pi x_{i}\right)+10\right)\right]\\ &-5.12 \leq x_{i} \leq 5.12, \quad \min \left(f_{9}\right)=f_{9}(0, \cdots, 0)=0 \end{aligned} $$
function o = F9(x)
dim=size(x,2);
o=sum(x.^2-10*cos(2*pi.*x))+10*dim;
end
F10:Ackley's Function
$$ \begin{aligned} f_{10}(x) &=-20 \exp \left(-0.2 \sqrt{\frac{1}{30} \sum_{i=1}^{30} x_{i}^{2}}\right) \\ &-\exp \left(\frac{1}{30} \sum_{i=1}^{30} \cos 2 \pi x_{i}\right)+20+e \\ &-32 \leq x_{i} \leq 32, \quad \min \left(f_{10}\right)=f_{10}(0, \cdots, 0)=0 \end{aligned} $$
function o = F10(x)
dim=size(x,2);
o=-20*exp(-.2*sqrt(sum(x.^2)/dim))-exp(sum(cos(2*pi.*x))/dim)+20+exp(1);
end
F11:Generalized Griewank's Function
$$ \begin{array}{r} f_{11}(x)=\frac{1}{4000} \sum_{i=1}^{30} x_{i}^{2}-\prod_{i=1}^{30} \cos \left(\frac{x_{i}}{\sqrt{i}}\right)+1 \\ -600 \leq x_{i} \leq 600, \quad \min \left(f_{11}\right)=f_{11}(0, \cdots, 0)=0 \end{array} $$
function o = F11(x)
dim=size(x,2);
o=sum(x.^2)/4000-prod(cos(x./sqrt([1:dim])))+1;
end
F12:Generalized Penalized Function(分为两种,此为第一种)
$$ \begin{aligned} f_{12}(x)=& \frac{\pi}{30}\left\{10 \sin ^{2}\left(\pi y_{1}\right)+\sum_{i=1}^{29}\left(y_{i}-1\right)^{2}\right.\\ &\left.\cdot\left[1+10 \sin ^{2}\left(\pi y_{i+1}\right)\right]+\left(y_{n}-1\right)^{2}\right\} \\ &+\sum_{i=1}^{30} u\left(x_{i}, 10,100,4\right) \\ -50 \leq x_{i} \leq 50, \quad \min \left(f_{12}\right)=f_{12}(1, \cdots, 1)=0 \end{aligned} $$
function o = F12(x)
dim=size(x,2);
o=(pi/dim)*(10*((sin(pi*(1+(x(1)+1)/4)))^2)+sum((((x(1:dim-1)+1)./4).^2).*...
(1+10.*((sin(pi.*(1+(x(2:dim)+1)./4)))).^2))+((x(dim)+1)/4)^2)+sum(Ufun(x,10,100,4));
end
F13:Generalized Penalized Function(分为两种,此为第二种)
$$ \begin{gathered} f_{13}(x)=0.1\left\{\sin ^{2}\left(\pi 3 x_{1}\right)+\sum_{i=1}^{29}\left(x_{i}-1\right)^{2}\left[1+\sin ^{2}\right.\right. \\ \left.\left.\cdot\left(3 \pi x_{i+1}\right)\right]+\left(x_{n}-1\right)^{2}\left[1+\sin ^{2}\left(2 \pi x_{30}\right)\right]\right\} \\ +\sum_{i=1}^{30} u\left(x_{i}, 5,100,4\right) \\ \text { where } \quad u \leq x_{i} \leq 50, \quad \min \left(f_{13}\right)=f_{13}(1, \cdots, 1)=0 \\ u\left(x_{i}, a, k, m\right)= \begin{cases}k\left(x_{i}-a\right)^{m}, & x_{i}>a \\ 0, \\ k\left(-x_{i}-a\right)^{m}, & x_{i}<-a \leq x_{i} \leq a \\ y_{i} & =1+\frac{1}{4}\left(x_{i}+1\right) \end{cases} \end{gathered} $$
function o = F13(x)
dim=size(x,2);
o=.1*((sin(3*pi*x(1)))^2+sum((x(1:dim-1)-1).^2.*(1+(sin(3.*pi.*x(2:dim))).^2))+...
((x(dim)-1)^2)*(1+(sin(2*pi*x(dim)))^2))+sum(Ufun(x,5,100,4));
end
固定维多峰测试函数
F14:Shekel's Foxholes Function
$$ \begin{aligned} &f_{14}(x)=\left[\frac{1}{500}+\sum_{j=1}^{25} \frac{1}{j+\sum_{i=1}^{2}\left(x_{i}-a_{i j}\right)^{6}}\right]^{-1}\\ &-65.536 \leq x_{i} \leq 65.536, \quad \min \left(f_{14}\right)=f_{14}(-32,-32) \approx 1\\ &\text { where }\\ &\left(a_{i j}\right)=\\ &\left(\begin{array}{cccccccccc} -32 & -16 & 0 & 16 & 32 & -32 & \cdots & 0 & 16 & 32 \\ -32 & -32 & -32 & -32 & -32 & -16 & \cdots & 32 & 32 & 32 \end{array}\right) \end{aligned} $$
function o = F14(x)
aS=[-32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32;,...
-32 -32 -32 -32 -32 -16 -16 -16 -16 -16 0 0 0 0 0 16 16 16 16 16 32 32 32 32 32];
for j=1:25
bS(j)=sum((x'-aS(:,j)).^6);
end
o=(1/500+sum(1./([1:25]+bS))).^(-1);
end
F15:Kowalik's Function
function o = F15(x)
aK=[.1957 .1947 .1735 .16 .0844 .0627 .0456 .0342 .0323 .0235 .0246];
bK=[.25 .5 1 2 4 6 8 10 12 14 16];bK=1./bK;
o=sum((aK-((x(1).*(bK.^2+x(2).*bK))./(bK.^2+x(3).*bK+x(4)))).^2);
end
F16:Six-Hump Camel-Back Function
$$ \begin{aligned} f_{16}=& 4 x_{1}^{2}-2.1 x_{1}^{4}+\frac{1}{3} x_{1}^{6}+x_{1} x_{2}-4 x_{2}^{2}+4 x_{2}^{4}, \\ &-5 \leq x_{i} \leq 5 \\ x_{\min }=&(0.08983,-0.7126),(-0.08983,0.7126) \\ & \min \left(f_{16}\right)=-1.0316285 \end{aligned} $$
function o = F16(x)
o=4*(x(1)^2)-2.1*(x(1)^4)+(x(1)^6)/3+x(1)*x(2)-4*(x(2)^2)+4*(x(2)^4);
end
F17:Branin Function
$$ \begin{aligned} f_{17}(x)=&\left(x_{2}-\frac{5.1}{4 \pi^{2}} x_{1}^{2}+\frac{5}{\pi} x_{1}-6\right)^{2} \\ &+10\left(1-\frac{1}{8 \pi}\right) \cos x_{1}+10 \\ &-5 \leq x_{1} \leq 10, \quad 0 \leq x_{2} \leq 15 \\ x_{\min }=&(-3.14212 .275),(3.142,2.275),(9.425,2.425) \\ & \min \left(f_{17}\right)=0.398 \end{aligned} $$
function o = F17(x)
o=(x(2)-(x(1)^2)*5.1/(4*(pi^2))+5/pi*x(1)-6)^2+10*(1-1/(8*pi))*cos(x(1))+10;
end
F18:Goldstein-Price Function
$$ \begin{aligned} f_{18}(x)=& {\left[1+\left(x_{1}+x_{2}+1\right)^{2}\left(19-14 x_{1}+3 x_{1}^{2}-14 x_{2}\right.\right.} \\ &\left.\left.+6 x_{1} x_{2}+3 x_{2}^{2}\right)\right] \times\left[30+\left(2 x_{1}-3 x_{2}\right)^{2}\right.\\ &\left.\times\left(18-32 x_{1}+12 x_{1}^{2}+48 x_{2}-36 x_{1} x_{2}+27 x_{2}^{2}\right)\right] \\ &-2 \leq x_{i} \leq 2, \quad \min \left(f_{18}\right)=f_{18}(0,-3)=3 \end{aligned} $$
function o = F18(x)
o=(1+(x(1)+x(2)+1)^2*(19-14*x(1)+3*(x(1)^2)-14*x(2)+6*x(1)*x(2)+3*x(2)^2))*...
(30+(2*x(1)-3*x(2))^2*(18-32*x(1)+12*(x(1)^2)+48*x(2)-36*x(1)*x(2)+27*(x(2)^2)));
end
F19&F20:Hartman's Family
function o = F19(x)
aH=[3 10 30;.1 10 35;3 10 30;.1 10 35];cH=[1 1.2 3 3.2];
pH=[.3689 .117 .2673;.4699 .4387 .747;.1091 .8732 .5547;.03815 .5743 .8828];
o=0;
for i=1:4
o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
end
end
function o = F20(x)
aH=[10 3 17 3.5 1.7 8;.05 10 17 .1 8 14;3 3.5 1.7 10 17 8;17 8 .05 10 .1 14];
cH=[1 1.2 3 3.2];
pH=[.1312 .1696 .5569 .0124 .8283 .5886;.2329 .4135 .8307 .3736 .1004 .9991;...
.2348 .1415 .3522 .2883 .3047 .6650;.4047 .8828 .8732 .5743 .1091 .0381];
o=0;
for i=1:4
o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
end
end
F21&F22&F23:Shekel's Family
function o = F21(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];
o=0;
for i=1:5
o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end
function o = F22(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];
o=0;
for i=1:7
o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end
function o = F23(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];
o=0;
for i=1:10
o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end
1 条评论
::huya:rangwokankan::