单目标优化问题 常用的 测试函数(MATLAB版)
###############################################
# 测试函数 #
###############################################
#1. De jong 函数F1
# min f1(x1,x2,x3) = x1^2+x2^2+x3^2; -5.12<=x1,x2,x3<=5.12;
# 一个极小点f1(0,0,0)=0
# 《遗传算法原理及应用》周明 孙树栋 编著 p125。
# GA参数取默认值(以下未交代的GA参数都取默认值)
# xu注:注意,含下标的变量在变量定义域表达式的表示形式要和数学表达式
# 中的一致!
#
x1^2+x2^2+x3^2; -5.12<=x1,x2,x3<=5.12;
# 以连加形式表示上式(只可以字母i为变量下标):
sum(1, 3, xi^2); -5.12<=xi<=5.12;
sum(1, 3, x[i]^2); -5.12<=x[i]<=5.12;
# 指定 i 或 k 或 j 等字母为变量下标的连加形式表达式:
# 说明:当指定某字母为变量下标,其变量名就不能含该字母 !
sumx(1, 3, i, xi^2); -5.12<=xi<=5.12;
sumx(1, 3, k, xk^2); -5.12<=xk<=5.12;
sumx(1, 3, j, xj^2); -5.12<=xj<=5.12;
# 变量下标带 [ ] 的连加形式表达式:
sumx(1, 3, i, x[i]^2); -5.12<=x[i]<=5.12;
#1-a min f(x) = sum(1, 100, (x-0.5)^2);
# 0<=xi<=1.0; i=1, 2, ..., 100;
# 最优解:f(0.5, 0.5, ..., 0.5) = 0
#
sum(1, 100, (xi-0.5)^2); 0<=xi<=1.0;
#1-1. * De jong 函数F2 , 又称 Rosonbrock马鞍函数
# min f2(x1,x2) = 100*(x1^2-x2)^2+(1-x1)^2;
# 它具有一个全局极小点f(1,1)=0 .该函数虽然
# 是单峰值函数,但它却是病态的(螺旋型),难以进行全局极小化。
# 摘自: 《遗传算法原理及应用》p125
#
# 这函数是二参数、单极值的非二次函数,但在x2=x1处有一狭
# 长深谷,其最小值在(x1,x2)=(1,1)时,min f=0,
# 寻优中可能陷入局部解.
#
# Rosenbrock 函数是一个二维单峰值函数,具有一个全局极小点
# f(1.0,1.0)=0.0,但它却是病态的,在函数曲面上沿着曲线x2=x1^2
# 有一条较为狭窄的山谷,传统的梯度优化方法搜索到谷边缘时,往往
# 会发生振荡,难以进行全局优化。
# 但它在全局极小点邻近的狭长区域内取值变化极为缓慢, 可用于评价
# 算法的搜索性能。
# 摘自:多点正交交叉的遗传算法 刘 清等
# xu注:当变量定义域表达式中存在二个以上的变量时得用\',\'分隔!
#
100*(x1^2-x2)^2+(1-x1)^2; -2.048<=x1,x2<=2.048;
100*(x1^2-x2)^2+(1-x1)^2; -10.0<=x1,x2<=10.0;
100*(x1^2-x2)^2+(1-x1)^2; -100.0<=x1,x2<=100.0;
#1-2. De jong 函数F3
# min f3(x1,x2,...,x5)=sum(integer(xi));
# -5.12<=xi<=-5.12 i=1,2,...,5 这是一个不连续函数,
# 该函数参数多,不可导,是五参数的阶梯函数,
# 在 -5.12<=xi<=-5.0 区域内的每一点,它都取全局极小值:
# f3(x1,x2,x3,x4,x5)= -30。
# 摘自:《遗传算法原理及应用》p125
#
floor(x1)+ floor(x2)+floor(x3)+floor(x4)+floor(x5); -5.12<=x1,x2,x3,x4,x5<=5.12;
sum(1, 5, floor(xi)); -5.12<=xi<=5.12;
sumx(1, 5, i, floor(xi)); -5.12<=xi<=5.12;
#1-3 De Jong 函数F4
# min f4(x1,x2,...,x30)=sum(i*xi^4)+rnd;
# -1.28<=xi<=1.28, i=1,2,...,30;
# 这是一个含噪声rnd的4次函数,当不考虑噪声的影响时,它具有
# 一个全局极小值f4(0,0,...,0)=0。
# 摘自:《遗传算法原理及应用》p125
# 原De Jong 函数,该噪声是分布为N(0,1)的高斯随机变量
# RandG(0,1)。据文献介绍,当函数不存在全局最小值时,该函数
# 是有缺陷的。
# 为此,有人建议以均匀分布的[0,1)的随机变量代替之。这可保证
# 最小值定位于0。
# Quartic [F4] is a simple unimodal function padded with noise.
# The gaussian noise makes sure that the algorithm never gets
# the same value on the same point.Algorithms that do not do
# well on this test function will do poorly on noisy data.
#
sum(1,30,i*xi^4)+RandG(0,1); -5.12<=xi<=5.12;
sum(1,30,i*xi^4)+rand(0,1); -5.12<=xi<=5.12;
#1-4 De Jong 函数F5
# min f5(x1,x2)=1/(1/500+sum(1/(j+sum((xi-aij)^6)))),
# -65.536<=xi<=65.536, j=1,2,...,25; i=1,2;
# a1j= -32,-16,0,16,32, -32,-16,...,0,16,32
# a2j= -32,-32,-32,-32,-32, -16,-16,...,32,32,32
# 它总共有25个局部极小值,其中有一个是全局极小值:
# f5(-32,-32)=0.998。
# 摘自:《遗传算法原理及应用》p125
# 该函数是具有 2 5 个稀疏尖峰的多模态函数。
# xu注: 本程序规定常数项一维数组命名为c, 二维数组命名为a,
# 即分别以c[j]和a[i,j]表示。
# 它们的二组数据即可记录在同一txt文件中,也可分别记
# 录在二个不同的txt文件中。文件应保存在本地文件夹内。
# 该数学表达式的常数项数组可调用1-4 ConstTermsData.txt
# 给予输入。
# xu注:min f( -31.97833, -31.97833 ) = 0.998003840
# 若是f5(x1,x2)=0.002+sum(1/(j+sum((xi-aij)^6)))
# min f = 0.00200
1/(1/500+sumx(1,25,j,1/(j+sumx(1,2,i,(xi-a[i,j])^6)))); -65.536<=xi<=65.536;
1/(0.002+sumx(1,25,j,1/(j+sumx(1,2,i,(xi-a[i,j])^6)))); -65.536<=xi<=65.536;
0.002+sumx(1,25,j,1/(j+sumx(1,2,i,(xi-a[i,j])^6))); -65.536<=xi<=65.536;
#2. Schaffer函数
# min f(x1, x2), 该函数在(x[1], x[2])=(0,0)处有一个全局最小值0。
#
0.5+((sin(sqrt(x[1]^2+x[2]^2))*sin(sqrt(x[1]^2+x[2]^2))-0.5)/((1.0+0.001*(x[1]^2+x[2]^2))*(1.0+0.001*(x[1]^2+x[2]^2)))); -100<=x[1],x[2]<=100;
0.5+((sin(sqrt(x1^2+x2^2)))^2-0.5)/(1.0+0.001*(x1^2+x2^2))^2; -100<=x1,x2<=100;
0.5+((sin(sqrt(pow(x1,2)+pow(x2,2))))^2-0.5)/(1.0+0.001*(pow(x1,2)+pow(x2,2)))^2; -100<=x1,x2<=100;
#3. * Schaffer函数
# 在其定义域内只有一个全局极小点min f(0,0)=0, -100<=x1,x2<=100;
#
((x^2+y^2)^0.25)*((sin(50*(x^2+y^2)^0.1)^2)+1.0); -5.12<=x,y<=5.12;
((x1^2+x2^2)^0.25)*((sin(50*(x1^2+x2^2)^0.1)^2) +1.0); -10<=x1,x2<=10;
pow(pow(x1,2)+pow(x2,2), 0.25)*(pow(sin(50*pow((x1^2+x2^2),0.1)),2)+1.0); -100<=x1,x2<=100;
#3-1 min f=sum(1, D-1, pow(x[i+1]^2+x[i]^2, 0.25)
# *(1.0+pow(sin(50.0*pow(x[i+1]^2+x[i]^2, 0.1)), 2))),
# -100<=x[i],x[i+1]<=100, i=1,2,...,D-1;
# 其min f(0,0,...,0)=0; 其全局极小点与邻近的局部极小点之间
# 有High barrier height.是演化算法的典型测试函数。
# 摘自:《快速演化算法研究》 高飞等。
sum(1, 9, pow(x[i+1]^2+x[i]^2, 0.25)*(1.0+pow(sin(50.0*pow(x[i+1]^2+x[i]^2, 0.1)), 2))); -100<=x[i],x[i+1]<=100;
sum(1, 29, pow(x[i+1]^2+x[i]^2, 0.25)*(1.0+pow(sin(50.0*pow(x[i+1]^2+x[i]^2, 0.1)), 2))); -100<=x[i],x[i+1]<=100;
#4. * Schaffer\'s 函数
# 此函数只有一个最小值点min f(0,0)=-1;
# 该最小值点周围有很多局部极值点,形成二圈圈沟,其函数值分别为
# -0.990283和-0.962776,因此很容易陷入在这些极小点处。
# 注:也可按多峰值函数处理,效果亦佳。
#
(sin(sqrt(x^2+y^2))^2-0.5)/(1+0.001*(x^2+y^2))^2 -0.5; -100<x,y<100;
#4-1 Schaffer 函数, 此函数有一个全局最大值解 max f(0,0)=1.0 。
# 该最大值点周围有两圈圈脊,取值分别为0.990284 和0.962776,
# 而且这些局部极值与最大值间的值差很小,因此,优化过程中极易
# 停滞在这些局部极值点处。因而,该函数可以很好地衡量进化算法
# 的性能.
#
0.5-((sin(sqrt(x^2+y^2)))^2-0.5)/(1.0+0.001*(x^2+y^2))^2;-100<x,y<100;
#4-2 Multimodal sine envelope sine wave function.
# min f=sum(1, D-1, 0.5+((sin(sqrt(x[i+1]^2+x[i]^2)))^2
# -0.5)/(1.0+0.001*(x[i+1]^2+x[i]^2))^2),
# -100<=x[i],x[i+1]<=100, i=1,2,...,D-1;
# 该函数有一个全局极小值 min f(0, 0,..., 0)=0, 该全局极小点
# 被无数的局部极小点所围绕, 并且全局极小点与这些局部极小点之
# 间存在极大值点。该函数是评价演化算法全局收敛性及搜索性能的
# 经典函数。
# 摘自:快速演化算法研究 高飞等.
#
sum(1, 9, 0.5+((sin(sqrt(x[i+1]^2+x[i]^2)))^2-0.5)/(1.0+0.001*(x[i+1]^2+x[i]^2))^2); -100<=x[i],x[i+1]<=100;
sum(1, 29, 0.5+((sin(sqrt(x[i+1]^2+x[i]^2)))^2-0.5)/(1.0+0.001*(x[i+1]^2+x[i]^2))^2); -100<=x[i],x[i+1]<=100;
#4-3 min f(x1,x2)=(((sin(sqr(x1^2+x2^2))^2-0.5)
# /(1+0.001*(x1^2+x2^2))^2))-0.5; -4<=x1,x2<=4;
# 其全局最优值在点(0,0).在全局最优值附近有无穷个取值相同的局部
# 最优值,且性态震荡强烈,一般的优化算法很难找到其全局最优解, 因
# 此常常被国内外很多学者用于对优化问题的测试.
# 摘自: Tang W, Guo ZM, Tang JH, Li DP. Optimizing complex
# functions by chaos genetic algorithm. Journal of Harbin
# Engineering University, 2000,21(5):1~5 (in Chinese with
# English abstract).
# 其全局最优的精确解为(f=0.3679, x1=0, x2=0 ?);
# xu注:f(x1,x2) = -1.00000, x1=0, x2=0;
#
(((sin(sqrt(x1^2+x2^2)))^2-0.5)/(1.0+0.001*(x1^2+x2^2))^2)-0.5; -4<=x1,x2<=4;
#5. * Shubert函数
# min f(x,y)=(sum(i*cos((i+1)*x)+i))*(sum(i*cos((i+1)*y)+i)),
# i=1:5, -10<=x,y<=10
# 该函数是一个多模态函数, 在其定义域内共有760个局部最小点,
# 其中的18 个点是全局最小点f = -186. 731 ,
# 因而该函数对于测试小生境遗传算法性能是非常适合的.
# 摘自: MICHALEWICZ Z.
# Genetic Algorithms + Data Structures = Evolution Programs [M] .
# Beijing :Science Press ,2000 :1 - 128.
# xu注:取小生境距=0.50~0.80, 最优保存数=22
(cos(2*x[1]+1)+2*cos(3*x[1]+2)+3*cos(4*x[1]+3)+4*cos(5*x[1]+4)+5*cos(6*x[1]+5))*(cos(2*x[2]+1)+2*cos(3*x[2]+2)+3*cos(4*x[2]+3)+4*cos(5*x[2]+4)+5*cos(6*x[2]+5)); -10<= x[1],x[2]<=10;
sum(1,5,i*cos((i+1)*x1+i))*sum(1,5,i*cos((i+1)*x2+i)); -10<=x1,x2<=10;
sum(1,5,i*cos((i+1)*x+i))*sum(1,5,i*cos((i+1)*y+i)); -10<=x,y<=10;
#5-1 f(x)=sum(1,5,i*cos((i+1)*x1+i))*sum(1,5,i*cos((i+1)*x2+i))
+(x1+1.42513)^2+(x2+0.80032)^2;
# where -10 ≤ xi ≤ 10, i = 1, 2. There are about 760 local minima
# and one global minimum f* = -176.1375 at x* = (-1.3068,-1.4248).
# Levy No. 5-1 is identical to Levy No. 5 except for the addition
# of a quadratic term. The large number of local optimizers makes
# it extremely difficult for any approximation method to find the
# global minimizer.
# 摘自:《An Evolutionary Algorithm for Minimizing Multimodal
# Functions》D.G. Sotiropoulos, V.P. Plagianakos and M.N.
# Vrahatis University of Patras, Department of Mathematics,
# Division of Computational Mathematics & Informatics,
# xu注:f( -1.42513, -0.80032 ) = -186.730911255 ?
sum(1, 5, i*cos((i+1)*x1+i))*sum(1,5,i*cos((i+1)*x2+i))+(x1+1.42513)^2+(x2+0.80032)^2; -10<=x1,x2<=10;
#6. Shubert函数
# 该函数有9个全局最小值-24.062499,位于(x,y):
# (-6.774576,-6.774576)、(-6.774576,-0.491391)、
# (-6.774576,5.791794)、(-0.491391,-6.774576)、
# (-0.491391,-0.491391)、(-0.491391,5.791794)、
# (5.791794,-6.774576)、(5.791794,-0.491391)、
# (5.791794,5.791794)
# 取最优保存数=10~12, 其余默认值。
#
-(sin(2*x+1)+2*sin(3*x+2)+3*sin(4*x+3)+4*sin(5*x+4)+5*sin(6*x+5))-(sin(2*y+1)+2*sin(3*y+2)+3*sin(4*y+3)+4*sin(5*y+4)+5*sin(6*y+5)); -10<=x,y<=10;
-sum(1,5,i*sin((i+1)*x+i))-sum(1,5,i*sin((i+1)*y+i)); -10<=x,y<=10;
#7. Easom函数
# min f(x1,x2) = -cos(x1)*cos(x2)*exp(-((x1-pi)^2)-(x2-pi)^2);
# -10<x1,x2<10 ;
# 在(x1,x2)=(pi, pi)处有全局最小值-1。
#
-cos(x1)*cos(x2)*exp(-((x1-pi)^2)-(x2-pi)^2); -10<x1,x2<10 ;
-cos(x1)*cos(x2)*exp(-((x1-pi)^2)-(x2-pi)^2); -100<=x1,x2<=100;
-cos(x1)*cos(x2)*exp(-pow((x1-pi),2)-pow((x2-pi),2)); -500<=x1,x2<=500;
#7-1 min f(x,y) = sin(x)*sin(y); -pi<=x,y<=pi;
# 有二个全局最小值:
# 1. f( 1.57080, -1.57080 ) = -1.000000000
# 2. f( -1.57080, 1.57080 ) = -1.000000000
# 来源:一种基于多群体搜索的实数遗传算法 程之刚等 国防科技大学。
#
sin(x)*sin(y); -pi<=x,y<=pi;
#8. Branin RCOS函数 在三个不同点:
# (x[1],x[2])=(-pi,12.275) 、(pi, 2.2750)和(9.42478, 2.4750)
# 处有全局最小值 0.397887
# xu注:当有二个以上的变量定义域表达式时,表达式之间得用\'&&\'分隔。
# 如下式有 0<=x[2]<=15 && -5<=x[1]<=10;
#
(x[2]-(5.1/(4*3.14159265359^2))*x[1]^2+(5/3.14159265359)*x[1]-6)*(x[2]-(5.1/(4*3.14159265359^2))*x[1]^2+(5/3.14159265359)*x[1]-6)+10*(1-1/(8*3.14159265359))*cos(x[1])+10; 0<=x[2]<=15 && -5<=x[1]<=10;
(x[2]-(5.1/(4*3.14159265359^2))*x[1]^2+(5/3.14159265359)*x[1]-6)*(x[2]-(5.1/(4*3.14159265359^2))*x[1]^2+(5/3.14159265359)*x[1]-6)+10*(1-1/(8*3.14159265359))*cos(x[1])+10; -5<=x[1]<=10 && 0<=x[2]<=15;
(x[2]-(5.1/(4*pi*pi))*x[1]*x[1]+(5/pi)*x[1]-6)*(x[2]-(5.1/(4*pi*pi))*x[1]*x[1]+(5/pi)*x[1]-6)+10*(1-1/(8*pi))*cos(x[1])+10; -5<=x[1]<=10 && 0<=x[2]<=15;
#9. Six-hump Camel Back Function 六峰驼返回函数
# 该函数共有六个局部极小点,其中
# f(-0.089842,0.71266)=f(0.089842,-0.71265)=-1.031628489
# 为二个全局最小点。
# 来源: MICHALEWICZ Z.
# Genetic Algorithms + Data Structures = Evolution Programs [M] .
# Beijing :Science Press ,2000 :1 - 128.
# xu注:当有二个以上的变量定义域表达式时,表达式之间得用\'&&\'分隔。
# 如0<=x[2]<=15 && -5<=x[1]<=10;
#
(4.0-2.1*x[1]^2+(1/3.0)*x[1]^4)*x[1]^2+x[1]*x[2]+(-4.0+4.0*x[2]^2)*x[2]^2; -3<=x[1]<=3 && -2<=x[2]<=2;
(4.0-2.1*pow(x1,2)+(1/3.0)*pow(x1,4))*pow(x1,2)+x1*x2+(-4.0+4.0*pow(x2,2))*pow(x2,2); -3<=x1<=3 && -2<=x2<=2;
#10. 在定义域内有200个极大和极小值
#
fabs((1-x)*x^2*sin(200*pi*x)); 0<x<1;
#11 * Rosenbrock\'s函数:
# sum(1, D-1, 100*(x[i]^2-x[i+1])^2+(1-x[i])^2)
# -5.12<=x[i]<=5.12 i=1:D
# De jong 函数F2 的高维函数。
# 最优解 min f(1,1,1, ..., 1,1)=0.0;
# 文献[10]中采用传统GA求解了n=2时的问题.在Rosenbrock函数曲面山谷
# 中的点的最速下降方向几乎与到函数最小值的最好方向垂直,因而传统算
# 法(如最速下降法)较难求解此问题.在高维情况下传统GA难以高效地求
# 解该问题.
#
# xu注:D=30, 小生境初距=0.3 终止代数=1000,其余参数取默认值;
# (090408)
#
sum(1,3,100*(x[i]^2-x[i+1])^2+(1-x[i])^2); -5.12<=x[i],x[i+1]<=5.12;
sum(1,5,100*(x[i]^2-x[i+1])^2+(1-x[i])^2); -5.12<=x[i],x[i+1]<=5.12;
sum(1,10,100*(x[i]^2-x[i+1])^2+(1-x[i])^2); -5.12<=x[i],x[i+1]<=5.12;
sum(1,30,100*(x[i]^2-x[i+1])^2+(1-x[i])^2); -5.12<=x[i],x[i+1]<=5.12;
sum(1,30,100*(x[i+1]-x[i]^2)^2+(x[i]-1)^2); -30<=x[i],x[i+1]<=30;
#11-1.Rosenbrock\'s 函数 A widely used multimodal test function
# sum(1, D-1, 100*(x[i+1]-xi^2)^2+(1-xi)^2);
# =sum(1, D-1, 100*(x[i]-x[i-1]^2)^2+(1-x[i-1])^2;
# global minimum f(x) = 0 x(i) = 1.0, i=1:D
# Rosenbrock 函数是一个经典复杂优化问题,可被当成多模优化函数,
# 它的全局最优点位于一个平滑、狭长的抛物线形山谷内.由于函数仅
# 为优化算法提供了少量信息,使算法很难辨别搜索方向,找到全局最小
# 点的机会微乎其微,该函数通常用于评价优化算法的执行效率.
# 在下一节的实验测试过程中,我们也发现优化算法一般只能获得该函
# 数的局部极值.其全局最优解:f(1,1,1,...,1)=0.
# 摘自:《多点交叉学习组织进化算法》 吕艳萍1,2, 李绍滋1+, 周昌乐1
# Journal of Software 软件学报 Vol.18, Supplement, December 2007
#
sum(1, 30, 100*(x[i+1]-x[i]^2)^2+(1-x[i])^2);-2.048<=x[i],x[i+1]<=2.048;
sum(1, 50, 100*(x[i+1]-x[i]^2)^2+(1-x[i])^2);-2.048<=x[i],x[i+1]<=2.048;
sum(1, 100, 100*(x[i+1]-x[i]^2)^2+(x[i]-1)^2);-2.048<=x[i],x[i+1]<=2.048;
#11-2 Min f(x)=(sin(pi*y1))^2+sum(1, n-1, (y1-1)^2
# *(1+10*(sin(pi*y[i+1]))^2))+(y[n]-1)^2
# where yi=1+(xi-1)/4, (i = 1, . . . , n) and xi ∈ [-10, 10],
# i = 1, 2, 3. There are about 125 local minima and one global
# minimum f* = 0 at x* = (1, 1, 1). No. 5-2 is difficult
# due to the combinations of diffirent periods of the sine
# function.
# 摘自:《An Evolutionary Algorithm for Minimizing Multimodal
# Functions》D.G. Sotiropoulos, V.P. Plagianakos and M.N.
# Vrahatis University of Patras, Department of Mathematics,
# Division of Computational Mathematics & Informatics,
#
(sin(pi*(1+(x[1]-1)/4)))^2+sum(1, 2, ((1+(x[1]-1)/4)-1)^2*(1+10*(sin(pi*(1+(x[i+1]-1)/4)))^2))+((1+(x[3]-1)/4)-1)^2; -10<=x[1],x[3],x[i+1]<=10;
(sin(pi*(1+(x[1]-1)/4)))^2+sum(1, 9, ((1+(x[1]-1)/4)-1)^2*(1+10*(sin(pi*(1+(x[i+1]-1)/4)))^2))+((1+(x[10]-1)/4)-1)^2; -10<=x[1], x[10],x[i+1]<=10;
(sin(pi*(1+(x[1]-1)/4)))^2+sum(1, 29, ((1+(x[1]-1)/4)-1)^2*(1+10*(sin(pi*(1+(x[i+1]-1)/4)))^2))+((1+(x[30]-1)/4)-1)^2; -10<=x[1],x[30],x[i+1]<=10;
(sin(pi*(1+(x[1]-1)/4)))^2+sum(1, 99, ((1+(x[1]-1)/4)-1)^2*(1+10*(sin(pi*(1+(x[i+1]-1)/4)))^2))+((1+(x[100]-1)/4)-1)^2; -10<=x[1],x[100],x[i+1]<=10;
#12. * X.FenXiang函数 这是一个多峰函数,有四个全局最小点:
# f(1,1)=0, f(-1,1)=0, f(1,-1)=0, f(-1,-1)=0
# 较难完全同时搜索到全局极小化点,很有代表性。
#
100*(x[1]^2-x[2]^2)^2+(1-x[1]^2)^2; -2.048<=x[1],x[2]<=2.048;
#13. Goldstein and Price function (GP) 该函数在其定义域内
# 只有一个全局极小值 f(0,-1)=3.0 。
#
(1+(x1+x2+1)^2*(19-14*x1+3*x1^2-14*x2+6*x1*x2+3*x2^2))*(30+(2*x1-3*x2)^2*(18-32*x1+12*x1^2+48*x2-36*x1*x2+27*x2^2)); -2<=x1,x2<=2;
#14. Hump function(HM) 该函数有二个全局最小值:
# f(0.0898,-0.7126)=f(-0.0898,0.7126) = 0.0
#
1.0316285+4*x1^2-2.1*pow(x1,4)+1/3*pow(x1,6)+x1*x2-4*x2^2+4*pow(x2,4); -5<x1,x2<5;
#15 * Rastrigin\'s Function
# A widely used multimodal test function Minimize:
# min f(x)=10.0*n+sum(x[i]^2 - 10.0*cos(2*Pi*x[i]))
# -5.12<= x[i]<=5.12
# global minimum f(x)=0 x[i]=0, i=1:n
# Rastrigin’s 函数是一个复杂的多模问题, 具有大量的
# 局部极值点, 主要用于检验算法的群体多样性.
#
10.0*2+x1^2+x2^2-10*(cos(2*pi*x1)+cos(2*pi*x2));-5.12<=x1,x2<=5.12;
10.0*10+sum(1,10,x[i]^2-10.0*cos(2*pi*x[i])); -5.12<=x[i]<=5.12;
#15-1.* Rastrigin\'s函数
# min f5=sum(1, D, xi^2-10*cos(2*pi*xi)+10);
# -5.12<=xi<=5.12; min f5(0, 0, ... , 0)=0;
# 函数是一个复杂的多模问题, 在xi=0(i=1,2,...,n)时达到全局极小点,
# 存在10D个的局部极值点(0.995,1.990,2.985,3.980,4.985 等).
# 主要用于检验算法的群体多样性.
#
sum(1, 30, xi^2-10*cos(2*pi*xi)+10); -5.12<=xi<=5.12;
sum(1, 50, xi^2-10*cos(2*pi*xi)+10); -5.12<=xi<=5.12;
sum(1, 80, xi^2-10*cos(2*pi*xi)+10); -5.12<=xi<=5.12;
sum(1, 100, xi^2-10*cos(2*pi*xi)+10); -5.12<=xi<=5.12;
#16. Bohachevsky函数#1 有一个f(0,0)=0.0 全局最小值。
#
x1^2+2*x2^2-0.3*cos(3*pi*x1)-0.4*cos(4*pi*x2)+0.7; -50<=x1,x2<=50;
#17. Bohachevsky 函数 #2 有f(0,0)=0 全局最小值。
#
x1^2+2*x2^2-0.3*cos(3*pi*x1)*cos(4*pi*x2)+0.3; -50<=x1,x2<=50;
#18. Bohachevsky 函数 #3 有f(0,0)=0 全局最小值。
#
x1^2+2*x2^2-0.3*cos(3*pi*x1+4*pi*x2)+0.3; -50<=x1,x2<=50;
#19. Bohachevsky测试函数 3,最优解为-0.24,分布在[0,-0.24]
# 和[0,0.24]。
# xu注:取小生境距=0.2(取小于两峰值间距,变量定义域也不大),
# 其余默认值;
#
x^2+y^2-0.3*cos(3*pi*x)+0.3*cos(4*pi*y)+0.3; -1.0<=x,y<=1.0;
#20. 多峰函数,有四个全局最大值2.118,对称分布于
# (+0.64,+0.64),(-0.64,-0.64),(+0.64,-0.64),
# (-0.64,+0.64),存在大量局部极大值,
# 尤其是在中间区域有一取值与全局最大值很接近的局部极大值
# 2.077)凸台。
# xu注:
# 最小值:
# f( -0.64097, -0.64097 ) = -2.118763447
# f( -0.64097, 0.64097 ) = -2.118763447
# f( 0.64097, -0.64097 ) = -2.118763447
# f( 0.64097, 0.64097 ) = -2.118763447
# 最大值:
# f( -0.88118, -0.88118 ) = 0.632694185
# f( -0.88118, 0.88118 ) = 0.632694185
# f( 0.88118, -0.88118 ) = 0.632694185
# f( 0.88118, 0.88118 ) = 0.632694185
#
-(1+x*sin(4*pi*x)-y*sin(4*pi*y+pi)+sin(6*sqrt(x^2+y^2))/(6*sqrt(x^2+y^2+10^(-15)))); -1<=x,y<=1;
#21. 函数6,有四个全局最小值-2.260,分布在:
# (0.63492,0.63492),(-0.63492,0.63492),
# (0.63492,-0.63492),(-0.63492,-0.63492)
# xu注:
# f( 0.63492, 0.63492 ) = -2.259986401
# f( -0.63492, 0.63492 ) = -2.259986401
# f( -0.63492, -0.63492 ) = -2.259986401
# f( 0.63492, -0.63492 ) = -2.259986401
#
-(1+x*sin(4*pi*x)-y*sin(4*pi*y+pi)); -1<=x,y<=1;
#22. Needle-in-a-haystack问题,当a=0.05;b=3,其最优解近似
# 为-3600,分布在(0,0)。
# 4个局部极值点为(+5.12,+5.12),(-5.12,-5.12),
# (+5.12,-5.12),(-5.12,+5.12)。
# xu注:
# 1. f( 0.00000, 0.00000 ) = -3600.000000000
# 2. f( -5.12000, -5.12000 ) = -2748.782226563
# 3. f( -5.12000, 5.12000 ) = -2748.782226563
# 4. f( 5.12000, -5.12000 ) = -2748.782226563
# 5. f( 5.12000, 5.12000 ) = -2748.782226563
#
-((3/(0.05+(x^2+y^2)))^2+(x^2+y^2)^2); -5.12<=x,y<=5.12;
#23. Camel函数,有6个局部极小点:
# (1.607105, 0.568651),(-1.607105, -0.568651)、
# (1.703607, -0.796084),(-1.703607, 0.796084)、
# (-0.0898,0.7126), (0.0898,-0.7126),
# 其中(-0.0898,0.7126)和(0.0898,-0.7126)
# 为两个全局最小点,最小值为-1.031628。
# xu注:
# 1. f( -0.08984, 0.71266 ) = -1.031628489
# 2. f( 0.08984, -0.71266 ) = -1.031628489
#
(4-2.1*(x^2)+x^4/3)*x^2+x*y+(-4+4*y^2)*y^2; -5.12<=x,y<=5.12;
#24. Rastrigrin 函数,全局最小值为0,分布在(0,0)处。
#
20+x^2-10*cos(2*pi*x)+y^2-10*cos(2*pi*y); -5.12<=x,y<=5.12;
#25. Sphere Model函数,全局最小值为0,分布在(0,0)。
#
x^2+y^2; -5.12<=x,y<=5.12;
#26. * Rana函数:
# min f = x*sin(sqrt(fabs(y+1-x)))*cos(sqrt(fabs(y+1+x)))
# +(y+1)*cos(sqrt(fabs(y+1-x)))*sin(sqrt(fabs(y+1+x)));
# -512<=x,y<=512; 全局最优解约为-511.708,分布在(-512,-512)。
# The Rana function is a non-separable, highly multimodal
# function.The left figure shows the two dimensional landscape of
# the non-rotated version. The best solutions are at the corners.
# Applying a simple parameter shift makes this function
# non-symmetric.
# 来源:Genitor Colorado State University.
# xu注:较难找到最优解,其实最优解还不是-511.708892822,但经常找到
# 的是它。
# f( -512.00000, -511.99540 ) = -511.708892822 多数情况
# f( -512.00000, -511.99560 ) = -511.708892822
# f( -488.63258, 512.00000 ) = -511.732879639
# 小生境初距=500~1000,其余默认值
# f( 487.50042, 504.22052 ) = -552.609375000
# f( 505.20298, 486.14774 ) = -564.045166016
# 采用多峰值函数寻优方式,同时得到:
# 1. f( -488.63258, 512.00000 ) = -511.732879639
# 2. f( -512.00000, -511.99560 ) = -511.708892822
#
x*sin(sqrt(fabs(y+1-x)))*cos(sqrt(fabs(y+1+x)))+(y+1)*cos(sqrt(fabs(y+1-x)))*sin(sqrt(fabs(y+1+x))); -512<=x,y<=512;
x*sin(sqrt(fabs(y+1-x)))*cos(sqrt(fabs(y+1+x)))+(y+1)*cos(sqrt(fabs(y+1-x)))*sin(sqrt(fabs(y+1+x))); -512<=x,y<=512;
#27. 函数16,全局最小值f(0,0)=0
#
fabs(x)+fabs(y)+fabs(x)*fabs(y); -10<=x,y<=10;
#28. Michalewicz\'s 函数,函数有1个全局极小值点取值近似为
# -1.8013,在(2.0230,2.0230)处。
# xu注:f( 2.20291, 1.57080 ) = -1.801303387
#
-sin(x)*(sin(x^2/pi))^20-sin(y)*(sin(2*y^2/pi))^20; 0<=x,y<=pi;
-sin(x)*pow((sin(x^2/pi)),20)-sin(y)*pow((sin(2*y^2/pi)),20); 0<=x,y<=pi;
#28-1 Michalewicz\'s function
# min f(...)=-sum(1, N, sin(xi)*pow(sin(i*xi^2/pi),20));
# 0<=xi<=pi; 最小值:-99.2784。
# 摘自:《用于函数优化的正交Multi-Agent遗传算法》,薛明志等,
# 系统工程与电子技术,第26卷第9期,2004年9月。
#
# The Michalewicz function is a multimodal test function
# (owns n! local optima).The parameter m defines the "steepness"
# of the valleys or edges.Larger m leads to more difficult search.
# For very large m the function behaves like a needle in the
# haystack(the function values for points in the space outside the
# narrow peaks give very little information on the location of the
# global optimum). Function has the following definition
# f(x) = -sum( sin(x(i)) * (sin(i*x(i)^2/pi))^(2*m) ),
# i=1:n, m=10 0<=x(i)<=pi. global minimum:
# f(x)=-4.687 (n=5); x(i)=???, i=1:n.
# f(x)=-9.66 (n=10); x(i)=???, i=1:n.
# 摘自:GEATbx: Example Functions (single and multi-objective
# functions) 2 Parametric Optimization
# xu注:从该函数3D图可见,随维数增加,该函数出现\'平台\'和狭长的\'山谷\',
# \'平台\'的出现不利于靠目标函数值(适应度)的变化进行的寻优,
# \'平台\'上的搜索点很难起导向性的搜索,而是呈现盲目性随机的搜索。
# 只有搜索点随机地落入\'山谷\',才有可能朝最优解方向搜索。这是造成
# 高维的该函数寻优的难度,使其寻优偶然性很大,取得最优解成功率不高。
# n<=10很容易得到最优解,再高后难度增加。
# n=5, 群体个体数=30,最优保存数=10,其它取默认值。
# f( 2.20291, 1.57080, 1.28499, 1.92306, 1.72047 )
# = -4.687658310
# n=10, 群体个体数=30,最优保存数=10,其它取默认值。
# f( 2.20291, 1.57080, 1.28499, 1.92306, 1.72047,
# 1.57080, 1.45441, 1.75609, 1.65572, 1.57080 )
# = -9.660151482
# n=30, 群体个体数=15 最优保存数=15 其余取默认值。
# 当迭代数到10左右,解要达到27~28时,才有希望达到最优解!
# 得到最优解的成功率不如n<=10.
# f( 2.20291, 1.57080, 1.28499, 1.92306, 1.72047, 1.57080,
# 1.45441, 1.75609, 1.65572, 1.57080, 1.49773, 1.69662,
# 1.63008, 1.57080, 1.51755, 1.66606, 1.61633, 1.57080,
# 1.52891, 1.64746, 1.60776, 1.57080, 1.53627, 1.63493,
# 1.60190, 1.57080, 1.54144, 1.62593, 1.59765, 1.57080 )
# = -29.630884171
#
# n=50 终止代数=1000,其余取默认值。
# f( 2.20291, 1.57080, 1.28499, 1.92306, 1.72047, 1.57080,
# 1.45441, 1.75609, 1.65572, 1.57080, 1.49773, 1.69662,
# 1.63008, 1.57080, 1.51755, 1.66606, 1.61633, 1.57080,
# 1.52891, 1.64746, 1.60776, 1.57080, 1.53627, 1.63493,
# 1.60190, 1.57080, 1.54144, 1.62593, 1.59765, 1.57080,
# 1.54525, 1.61914, 1.59442, 1.57080, 1.54819, 1.61384,
# 1.59188, 1.57080, 1.55053, 1.60959, 1.58984, 1.57080,
# 1.55242, 1.60610, 1.58815, 1.57080, 1.55400, 1.60319,
# 1.58674, 1.57080 ) = -49.624832153
#
-sum(1, 5, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
-sum(1, 10, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
-sum(1, 30, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
-sum(1, 50, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
-sum(1, 100, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
#28-2 Michalewicz’s function
# max f(...) = sum(1, N, sin(xi)*(sin(i*xi^2/pi))^20)
# 0.0<=xi<=3.14;
# 当N=100时,据介绍,最大值为99.2784,
# 来源作者的计算结果为99.61630365;
# 摘自:《适用于高维优化问题的改进进化策略》王湘中,喻寿益
#
#
sum(1, 10, sin(xi)*pow(sin(i*xi^2/pi),20)); 0<=xi<=pi;
sum(1, 10, sin(xi)*(sin(i*xi^2/pi))^20); 0.0<=xi<=pi;
sum(1, 30, sin(xi)*(sin(i*xi^2/pi))^20); 0.0<=xi<=pi;
sum(1, 100, sin(xi)*(sin(i*xi^2/pi))^20); 0.0<=xi<=pi;
#29. Schwefel\'s函数,是一个典型的欺骗问题,有1个全局极小值点
# 取值近似为-837.9658,在(420.96875,420.96875)处,距离另
# 一个局部最优点很远,因此如果陷入局部最优就很难跳出。
# xu注:f( 420.96875, 420.96875 ) = -837.965759277
#
-x*sin(sqrt(fabs(x)))-y*sin(sqrt(fabs(y))); -500<=x,y<=500;
#30. Schwefel\'s function
# sum(1, D, -x(i)·sin(sqrt(abs(x(i)))));
# i=1:D; -500<=x(i)<=500;
# global minimum: f(x) = -D·418.9829;
# x(i)=420.9687, i=1:D.
# xu注: 基本同#31
# D=2, f( 420.96875, 420.96875 ) = -837.965759277
# D=3, f( 420.96875, ..., 420.96875)=-1256.948608398;
# D=10, f( 420.96875, ..., 420.96875)=-4189.829101563;
# D=30,f( 420.96875, ..., 420.96875)=-12569.486328125
#
-x1*sin(sqrt(fabs(x1)))-x2*sin(sqrt(fabs(x2)));-500<=x1,x2<=500;
sum(1,2,-xi*sin(sqrt(fabs(xi))));-500<=xi<=500;
sum(1,2,-x[i]*sin(sqrt(fabs(x[i]))));-500<=x[i]<=500;
sum(1,3,-x[i]*sin(sqrt(fabs(x[i]))));-500<=x[i]<=500;
sum(1,10,-x[i]*sin(sqrt(fabs(x[i]))));-500<=x[i]<=500;
sum(1,30,-x[i]*sin(sqrt(fabs(x[i]))));-500<=x[i]<=500;
-sum(1,30,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
# *31. Schwefel\'s 函数 (Sine Root)function,
# A widely used multimodal test function:
# f(x) = 418.9829*n + sum(1, n, -x(i)*sin(sqrt(abs(x(i))));
# -500 <= x(i) <= 500;
# global minimum f(x) = 0, x(i)=420.9687, i=1:n
# Schwefel\'s function [7] is deceptive in that the global
# minimum is geometrically distant from the next best local
# minima.
# 由于其全局最优解点周围存在局部极值点,因此搜索难以抵达全局
# 最优解点,主要用于检验算法的种群多样性.
#
# http://www.aridolan.com/ga/gaa/Schwefel.html
#
# xu注:常数418.9829精度不过,为418.982887272433799才有足过精度,
# 即 418.982887272433799*D + sum(1,D, -x(i)*sin(sqrt(abs(x(i))));
# 才能global minimum f(x) = 0
#
# 118.439及228.765,236.877,473.753 ,592.192等是其局部极值?
# 容易停滞在这些点上.
#
#
#
418.9829*2+sum(1,2,-xi*sin(sqrt(fabs(xi)))); -500<=xi<=500;
418.982887272433*2-sum(1,2,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433*2-sum(1,2,xi*sin(sqrt(fabs(xi))));-500<=xi<=500;
418.982887272433*3-sum(1,3, xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433*3-sum(1,3, xi*sin(sqrt(fabs(xi))));-500<=xi<=500;
418.982887272433*5-sum(1,5,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433*5-sum(1,5, xi*sin(sqrt(fabs(xi))));-500<=xi<=500;
418.982887272433*10-sum(1,10,xi*sin(sqrt(fabs(xi))));-500<=xi<=500;
418.982887272433*30-sum(1,30,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433*30-sum(1,30,xi*sin(fabs(xi)^(1/2)));-512<=xi<=512;
418.982887272433*30-sum(1,30,xi*sin(fabs(xi)^(1/2)));-520<=xi<=520;
418.982887272433*40-sum(1,40,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*50-sum(1,50,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*60-sum(1,60,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*70-sum(1,70,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*80-sum(1,80,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*90-sum(1,90,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
418.982887272433799*100-sum(1,100,xi*sin(fabs(xi)^(1/2)));-500<=xi<=500;
#32. Ackley\'s Path function ,函数有1个全局极小值点取值为0,
# 在(0,0)处。Ackley’s 函数在狭长的全局极值点周围拥有很多
# 的局部极值.主要用以测试算法的收敛率.
#
-20*exp(-0.2*sqrt(0.5*(x^2+y^2)))-exp(0.5*(cos(2*pi*x)+cos(2*pi*y)))+exp(1)+20; -30<=x,y<=30;
20+e-20*exp(-0.2*sqrt(1/30*sum(1,30,xi^2)))-exp(1/30*sum(1,30,cos(2*pi*xi))); -32.768<=x,y<=32.768;
20+e-20*exp(-0.2*sqrt(1/100*sum(1,100,xi^2)))-exp(1/100*sum(1,100,cos(2*pi*xi))); -32.768<=x,y<=32.768;
#32-1 玄光男的遗传算法讲稿,有图. 有一最小值:
# Optimal solution(x*,y*)=(0,0) f(x*,y*)=0
#
-20*exp(-0.2*sqrt(0.5*(x^2+y^2)))-exp(0.5*(cos(2*pi*x)+cos(2*pi*y)))+exp(1)+20; -5<=x,y<=5;
#32-2. Ackley\'s函数
# f2=20+e-20*exp(-0.2*sqrt(1/D*sum(1,D,xi^2)))
# -exp(1/D*sum(1,D,cos(2*pi*xi));-32.768<=xi<=32.768;
# min f2(0,0,...,0) = 0;
# Ackley’s 函数在狭长的全局极值点周围拥有很多的局部极值,
# 它是6个基准测试函数中最容易得到最优解的,主要用以测试算法的
# 收敛率。
# 摘自:《多点交叉学习组织进化算法》 吕艳萍1,2, 李绍滋1+, 周昌乐1
# Journal of Software 软件学报 Vol.18, Supplement, December 2007
#
20+e-20*exp(-0.2*sqrt(1/30*sum(1,30,xi^2)))-exp(1/30*sum(1,30,cos(2*pi*xi))); -32.768<=xi<=32.768;
20+e-20*exp(-0.2*sqrt(1/100*sum(1,100,xi^2)))-exp(1/100*sum(1,100,cos(2*pi*xi))); -32.768<=xi<=32.768;
#33. Hansen函数,函数有一个全局最小值-176.541793,在下面九
# 个点处取值:
# (-7.589893,-7.708314)、(-7.589893,-1.425128)、
# (-7.589893,4.858057)、(-1.306708,-7.708314)、
# (-1.306708,-1.425128)、(-1.306708,4.858057)、
# (4.976478,-7.708314)、(4.976478,-7.708314)、
# (4.976478,4.858057) 函数共有760个局部极小值。
#
(cos(1)+2*cos(x+2)+3*cos(2*x+3)+4*cos(3*x+4)+5*cos(4*x+5))*(cos(2*y+1)+2*cos(3*y+2)+3*cos(4*y+3)+4*cos(5*y+4)+5*cos(6*y+5)); -10<=x,y<=10;
#34. Griewangk\'s 函数(similar to Rastrigin\'s function)函数
# 有1个全局极小值点取值为0,在(0,0)处。
#
(x^2+y^2)/4000-cos(x)*cos(y/sqrt(2))+1; -600<=x,y<=600;
sum(1,2,xi^2)/4000-prod(1,2, cos(xi/sqrt(i)))+1; -600<=xi<=600;
sum(1,5,xi^2)/4000-prod(1,5, cos(xi/sqrt(i)))+1; -10<=xi<=10;
#35. Griewangk\'s function is similar to Rastrigin\'s
# function. It has many widespread local minima.However,
# the location of the minima are regularly distributed.
# global minimum:
# f(x)=0; x(i)=0, i=1:n.
# f8(x)=sum(x(i)^2/4000)-prod(cos(x(i)/sqrt(i)))+1, i=1:n
# -600<=x(i)<=600.
#
x1^2/4000+x2^2/4000-cos(x1/sqrt(1.0))*cos(x2/sqrt(2.0))+1; -600<=x1,x2<=600;
x1^2/4000+x2^2/4000-cos(x1/sqrt(1.0))*cos(x2/sqrt(2.0))+1; -10<=x1,x2<=10;
#36. min. F=(X[1]-1)*(X[1]-1)+(X[2]-1/2)*(X[2]-1/2)
# +(X[3]-1/3)*(X[3]-1/3)+...+(X[100]-1/100)
# *(X[100]-1/100)
# s.t. -10<=X[I]<=10,I=1,2,...,100
# 全局最小值 0
# 10维:f( 1.00000, 0.50000, 0.33333, 0.25000, 0.20000, 0.16667,
# 0.14286, 0.12500, 0.11111, 0.10000 ) = 0.000000000
# 20维:f( 1.000
请发表评论