###############################################
# 測試函數 #
###############################################
#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.00000, 0.50000, 0.33333, 0.25000, 0.20000, 0.16667,
# 0.14286, 0.12500, 0.11111, 0.10000, 0.09091, 0.08333,
# 0.07692, 0.07143, 0.06667, 0.06250, 0.05882, 0.05556,
# 0.05263, 0.05000 ) = 0.000000000
# 100維:f( 1.00000, 0.50000, 0.33333, 0.25000, 0.20000,
# 0.16667, 0.14286, 0.12500, 0.11111, 0.10000, 0.09091,
# 0.08333, 0.07692, 0.07143, 0.06667, 0.06250, 0.05882,
# 0.05556, 0.05263, 0.05000, 0.04762, 0.04545, 0.04348,
# 0.04167, 0.04000, 0.03846, 0.03704, 0.03571, 0.03448,
# 0.03333, 0.03226, 0.03125, 0.03030, 0.02941, 0.02857,
# 0.02778, 0.02703, 0.02632, 0.02564, 0.02500, 0.02439,
# 0.02381, 0.02326, 0.02273, 0.02222, 0.02174, 0.02128,
# 0.02083, 0.02041, 0.02000, 0.01961, 0.01923, 0.01887,
# 0.01852, 0.01818, 0.01786, 0.01754, 0.01724, 0.01695,
# 0.01667, 0.01639, 0.01613, 0.01587, 0.01562, 0.01538,
# 0.01515, 0.01493, 0.01471, 0.01449, 0.01429, 0.01408,
# 0.01389, 0.01370, 0.01351, 0.01333, 0.01316, 0.01299,
# 0.01282, 0.01266, 0.01250, 0.01235, 0.01219, 0.01205,
# 0.01190, 0.01176, 0.01163, 0.01149, 0.01136, 0.01124,
# 0.01111, 0.01099, 0.01087, 0.01075, 0.01064, 0.01053,
# 0.01042, 0.01031, 0.01020, 0.01010, 0.01000 )
# = 0.000000000
#
sum(1,10,(xi-1/i)^2);-10<=xi<=10;
sum(1,20,(xi-1/i)^2);-10<=xi<=10;
sum(1,100, (xi-1/i)^2);-10<=xi<=10;
#*37. min.F=Abs(X[1]-1)+Abs(X[2]-2)+Abs(X[3]-3)+...
# +Abs(X[100]-100)
# s.t. -100<=X[I]<=100,I=1,2,...100
# 全局最小值 0。不易達到高精度的零值!
#
sum(1,100,fabs(xi-i));-100<=xi<=100;
#38. min.F=-(X[1]+X[2]+X[3]+...+X[100])
# s.t. X[1]*X[1]+X[2]*X[2]+...+X[100]*X[100]<=100
# 0<=X[I]<=2, I=1,2,...,100
# 有不等式約束的函數優化!
# 全局最小值-100
#
-sum(1,100,xi); 0<=xi<=2;
#39. min.F=Exp(-X[1])*Sin(X[1])+Exp(-X[2])*Sin(2*X[2])
# +Exp(-X[3])*Sin(3*X[3])+...+Exp(-X[10])*Sin(10*X[10])
# s.t. 0<=X[I]<=10,I=1,2,...,10
# f( 3.92699, 2.12437, 1.46355, 1.11685, 0.90300, 0.75787,
# 0.65293, 0.57350, 0.51130, 0.46127 ) = -3.815545082
# f( 3.92788, 2.12437, 1.46355, 1.11685, 0.90300, 0.75787,
# 0.65293, 0.57350, 0.51130, 0.46127 ) = -3.815545082
# f( 3.92621, 2.12437, 1.46355, 1.11685, 0.90300, 0.75787,
# 0.65293, 0.57350, 0.51130, 0.46127 ) = -3.815545082
#
sum(1,10, exp(-xi)*sin(i*xi)); 0<=xi<=10;
#40. min.F(x1,x2,...,x10) = Exp(-(X[1]+X[2]))*Sin(X[1]*X[2])
# + Exp(-(X[2]+X[3]))*Sin(2*X[2]*X[3])
# + Exp(-(X[3]+X[4]))*Sin(3*X[3]*X[4])
# + ...
# + Exp(-(X[10]+X[1]))*Sin(10*X[10]*X[1])
# s.t. 0<=X[I]<=10,I=1,2,...,10
# 全局最小值:
# f(0.66911, 4.37878, 1.28379, 1.14085, 0.98864, 0.90701,
# 0.83424,0.77432, 0.73665, 0.68502 ) = -1.430215716;
# f(0.66065, 9.75233, 1.30341, 1.13164, 0.99241, 0.90636,
# 0.83268, 0.77762, 0.73170, 0.69156 ) = -1.430215716;
#
sum(1,9,exp(-(x[i]+x[i+1]))*sin(i*x[i]*x[i+1]))+exp(-(x[10]+x[1]))*sin(10*x[10]*x[1]); 0<=x[i],x[i+1],x[10]<=10;
#41. * min.F=sum(sin(x[i]*sin(i*x[11-i])))
# -prod(cos(x[i]*cos(i*x[11-i])));
# 0<=xi<=10; i=1:n;
# 該函數的極值如麥田的麥芒一樣不計其數,要找出其中最矮的
# 一株其難度是可想而知的,基礎遺傳算法和一些改進遺傳算法
# 都搜索不到全局最小值。
# 二維:f( 5.68795, 8.44250 ) = -2.999561787
# 三維:f( 3.44036, 8.44916, 9.90141 ) = -3.984106541(幾率最高)
# f( 3.44787, 8.44916, 9.88799 ) = -3.992382526 (090308)
# f( 5.63505, 8.44916, 8.44181 ) = -3.998083591 (090308)
#
# xu注:以多峰值函數方式尋優,會取得更好的效果。
#
sum(1,2,sin(x[i]*sin(i*x[3-i])))-prod(1,2,cos(x[i]*cos(i*x[3-i])));0<=x[i],x[3-i]<=10;
sum(1,3,sin(x[i]*sin(i*x[4-i])))-prod(1,3,cos(x[i]*cos(i*x[4-i])));0<=x[i],x[4-i]<=10;
#42 Salomon's function
# min f(x)=- cos(2*pi*sqrt(sum(1,D,xi^2)))
# + 0.1*sqrt(sum(1,D,xi^2))+1
# min f(0,0,...,0)=0.0;
# 來源:http://www.it.lut.fi/ip/evo/functions/node12.html
-cos(2*pi*sqrt(sum(1,10,xi^2))) + 0.1*sqrt(sum(1,10,xi^2))+1; -10<=xi<=10;
#43. min f(x1,x2)=exp(sin(50.x1))+sin(60*exp(x2))+sin(70*sin(x1))
# +sin(sin(80*x2))-sin(10*(x1+x2))+(x1^2+x2^2)/4;
# f(x1=-0.0244030794174338178, x2=0.210612427162285371)
# = -3.30686864747523535
# 來源:《NONLINEAR OPTIMIZATION IN MODELING ENVIRONMENTS》
# xu注:f( -0.02440, 0.21061 ) = -3.306868553
#
exp(sin(50*x1))+sin(60*exp(x2))+sin(70*sin(x1))+sin(sin(80*x2))-sin(10*(x1+x2))+(x1^2+x2^2)/4; -3<=x1,x2<=3;
exp(sin(50*x1))+sin(60*exp(x2))+sin(70*sin(x1))+sin(sin(80*x2))-sin(10*(x1+x2))+(x1^2+x2^2)/4; -100<=x1,x2<=30;
#44. Shekel SQRN5
# 帶有一維數組c[j]和二維數組a[i,j], 它們的二組數據放在本地
# 文件夾的#44 ConstTermsData.txt。
# D=5, Min f(x1,x2,x3,x4) = f(4,4,4,4) = -10.15320;
# D=7, Min f(x1,x2,x3,x4) = f(4,4,4,4) = -10.402820;
# D=10, Min f(x1,x2,x3,x4) = f(4,4,4,4) = -10.53628;
# 摘自:<演化程序-遺傳算法和數據編碼的結合> p258
# xu注: 本程序規定常數項一維數組命名為c, 二維數組命名為a,
# 即分別以c[j]和a[i,j]表示。
# 它們的二組數據即可拷貝在同一txt文件中,也可分別記
# 錄在二個不同的txt文件中。文件應保存在本地文件夾內。
# 該數學表達式的常數項數據拷貝在#44 D5 常數項數據.txt
# 、#44 D7 常數項數據.txt和#44 D10 常數項數據.txt
# xu注:
# D=5
# f( 4.00004, 4.00013, 4.00004, 4.00013 ) = -10.152723312
# D=7,
# f( 4.00057, 4.00069, 3.99949, 3.99960 ) = -10.402464867
# D=10, 參數取默認值。
# f( 4.00075, 4.00059, 3.99966, 3.99951 ) = -10.535933495
#
-sumx(1, 5, j, 1/(sumx(1,4,i,(xi-a[i,j])^2)+c[j])); 0<=xi<=10;
-sumx(1, 7, j, 1/(sumx(1,4,i,(xi-a[i,j])^2)+c[j])); 0<=xi<=10;
-sumx(1, 10, j, 1/(sumx(1,4,i,(xi-a[i,j])^2)+c[j])); 0<=xi<=10;
#46
# max f(x,y)=(a/(b+(x^2+y^2)))^2+(x^2+y^2); -5.12<=x,y<=5.12;
# 其中,a=3.0, b= 0.05, max f(0,0) =3600, 4個局部極值點為
# (-5.12,5.12),(-5.12, -5.12),(5.12, -5.12)和(5.12, 5.12),
# 函數值為2748.78 ,這是一類全局最優解被次優解所包圍,隔斷了模式
# 的重組過程,使得GA搜索長期陷入局部極值點,隨着參數a ,b的變化,
# 該函數將形成不同嚴重程度的GA欺騙問題。
# 摘自:李敏強, 寇紀淞. 遺傳算法的模式欺騙性. 中國科學(E緝),
# 2002, 構造的一類大海撈針問題
# xu注: f( 0.00000, -0.00000 ) = 3600.000000000
#
(3.0/(0.05+(x^2+y^2)))^2+(x^2+y^2); -5.12<=x,y<=5.12;
#47 max f1=-sum(1,D,sin(xi)+sin(2*xi/3)); 3<=xi<=13;
# Optimum 1.21598D
# xu注:
# 3維: f( 5.36225, 5.36225, 5.36225 ) = 3.647946596
# 10維:f( 5.36225, ...,5.36225, 5.36225 ) = 12.159821510
# 30維:f( 5.36225, ..., 5.36225, 5.36225 ) = 36.479465485
# 100維:f( 5.36225, ...,5.36225, 5.36225 ) = 120.306587219
#
-sum(1, 3, sin(xi)+sin(2*xi/3)); 3<=xi<=13;
-sum(1, 10, sin(xi)+sin(2*xi/3)); 3<=xi<=13;
-sum(1, 30, sin(xi)+sin(2*xi/3)); 3<=xi<=13;
-sum(1, 100, sin(xi)+sin(2*xi/3)); 3<=xi<=13;
#48 max f2=-sum(1,D-1,sin(x[i]+x[i+1])+sin(2*x[i]*x[i+1]/3));
# 3<=x[i],x[i+1]<=13 Optimum ~2D(max)
# D=5時,采用多峰值函數尋優方式,
# 取最有保存數=20,其余取默認值。
# 1.f( 5.31950, 11.95926, 5.31950, 11.95926, 5.31950 )=8.000000000
# 2.f( 11.95926, 5.31950, 11.95926, 5.31950, 11.95926 )=8.000000000
# 3.f( 3.42233, 7.57324, 3.42233, 7.57324, 3.42233 )=8.000000000
# 4.f( 7.37571, 9.90305, 7.37571, 9.90305, 7.37571 )=8.000000000
#
-sum(1,4,sin(x[i]+x[i+1])+sin(2*x[i]*x[i+1]/3)); 3<=x[i],x[i+1]<=13;
#49 max f6=sum(1,D,xi*sin(10*pi*xi));
# -1.0<=xi<=2.0; Optimum 1.85D(max)
# xu注:f( 1.85055, 1.85055 ) = 3.700547457
#
sum(1,2,xi*sin(10*pi*xi)); -1.0<=xi<=2.0;
#50 求Max f(x)=10+sin(1/x)/((x-0.16)^2+0.1) 0<x<1
# 全局最優值f(x)=19.8949; x=0.1275
# 該函數引自文獻: 張講社,徐宗本,梁怡.整體退火遺傳算法及其收斂充
# 要條件.
# 中國科學(E輯),1997,27(2):154~164.
# xu注:f( 0.12749 ) = 19.894897461
10+sin(1/x)/((x-0.16)^2+0.1); 0.01<x<1;
# 注:以下#52~#57六個函數來源於:
# 《多點交叉學習組織進化算法》 呂艷萍1,2, 李紹滋1+, 周昌樂1
# Journal of Software 軟件學報 Vol.18, Supplement, December 2007
#53 Ackley’s 函數
#54. * Griewank's函數
# min f(...)=1/4000*sum(1,D,xi^2)-prod(1,D,cos(xi/sqrt(i)))+1;
# -600<=xi<=600; min f3(0,0,...,0)=0;
# 該函數由於其各維上的變量是密切相關的,互相作用,因此很難取得最
# 優解。
# 摘自:《多點交叉學習組織進化算法》 呂艷萍1,2, 李紹滋1+, 周昌樂1
# Journal of Software 軟件學報 Vol.18, Supplement, December 2007
# xu注:參數取默認值(090318).
1/4000*sum(1,2,xi^2)-prod(1,2,cos(xi/sqrt(i)))+1; -600<=xi<=600;
1/4000*sum(1,10,xi^2)-prod(1,10,cos(xi/sqrt(i)))+1; -600<=xi<=600;
1/4000*sum(1,30,xi^2)-prod(1,30,cos(xi/sqrt(i)))+1; -600<=xi<=600;
1/4000*sum(1,100,xi^2)-prod(1,100,cos(xi/sqrt(i)))+1; -600<=xi<=600;
#55. *Weierstrass's函數
# min f=sum(1, D, sum(0, kmax, a^k*cos(2*pi*b^k*(xi+0.5))))
# -D*sum(0, kmax, a^k*cos(2*pi*b^k*0.5));
# a=0.5, b=3, kmax=20; -0.5<=xi<=0.5;
# min f4(0,0,...,0) = 0;
# Weierstrass's 是一個處處連續又只在有限的幾個點可微分的函數。
# 摘自:《多點交叉學習組織進化算法》 呂艷萍1,2, 李紹滋1+, 周昌樂1
# Journal of Software 軟件學報 Vol.18, Supplement, December 2007
# D=30 小生境初距=0.1,衰減參數=8.0,終止代數=50;
#
sumx(1, 10, i, sumx(0, 20, k, 0.5^k*cos(2*pi*3^k*(xi+0.5))))-10*sumx(0,20, k, 0.5^k*cos(2*pi*3^k*0.5)); -0.5<=xi<=0.5;
sumx(1, 30, i, sumx(0, 20, k, 0.5^k*cos(2*pi*3^k*(xi+0.5))))-30*sumx(0, 20, k, 0.5^k*cos(2*pi*3^k*0.5)); -0.5<=xi<=0.5;
sumx(1, 100, i, sumx(0, 20, k, 0.5^k*cos(2*pi*3^k*(xi+0.5))))-100*sumx(0, 20, k, 0.5^k*cos(2*pi*3^k*0.5)); -0.5<=xi<=0.5;
#56 Rastrigin’s 函數
#57 Schwefel’s 函數
#58 max f(x1,x2)= 21.5+ x1*sin(4*pi*x1) + x2*sin(20*pi*x2)
# s.t. -3.0<=x1<=12.1; 4.1<=x2<=5.8;
# 函數有許多極值點。
# 全局最大值解 f(11.622766, 5.624329)=38.737524;
# 來源:tw01-IntroGA-v1.1ray.ppt
# xu注: 應是max f( 11.62554, 5.72504 ) = 38.850296021;
#
21.5+ x1*sin(4*pi*x1) + x2*sin(20*pi*x2); -3.0<=x1<=12.1 && 4.1<=x2<=5.8;
#59 max f(x,y)=6-4.5*x+4*y-x^2-2*y^2+2*x*y-x^4+2*x^2*y;
# -8<=x,y<=8; f(-1.09326171875,1.01171875)=10.5020508424479
# 來源:xoBox算法
# xu注: 應是:max f( -1.05274, 1.02776 ) = 10.513409615;
#
6-4.5*x+4*y-x^2-2*y^2+2*x*y-x^4+2*x^2*y; -8<=x,y<=8;
#60 Bobachevsky 函數
# x1^2+2*x2^2-0.3*cos(3*pi*x1)-0.4*cos(4*pi*x2)+0.7;
# x1^2+2*x2^2-0.3*cos(3*pi*x1)*cos(4*pi*x2)+0.3;
# x1^2+2*x2^2-0.3*cos(3*pi*x1+4*pi*x2)+0.3;
# -50<=x1,x2<=50;
# 3個函數在(x1,x2)=(0,0)處有全局最小值0.0;
# References: MICHALEWICZ Z.
# Genetic Algorithms + Data Structures = Evolution Programs [M] .
# Beijing :Science Press ,2000 :1 - 128.
x1^2+2*x2^2-0.3*cos(3*pi*x1)-0.4*cos(4*pi*x2)+0.7; -50<=x1,x2<=50;
x1^2+2*x2^2-0.3*cos(3*pi*x1)*cos(4*pi*x2)+0.3; -50<=x1,x2<=50;
x1^2+2*x2^2-0.3*cos(3*pi*x1+4*pi*x2)+0.3; -50<=x1,x2<=50;
#61 Zakharov's Function
# Min f(xi) = sum(1, D, xi^2)+(sum(1, D, i/2*xi))^2
# + (sum(1, D, i/2*xi))^4;
# -5.12<=xi<=5.12;
# 來源:一種高效Multi-agent仿生算法用於設計優化
# 梁昌勇,張俊嶺,楊善林
# (合肥工業大學計算機網絡系統研究所,合肥 230009)
#
sum(1, 30, xi^2)+(sum(1, 30, i/2*xi))^2+(sum(1, 30, i/2*xi))^4; -5.12<=xi<=5.12;
sum(1, 100, xi^2)+(sum(1, 100, i/2*xi))^2+(sum(1, 100, i/2*xi))^4; -5.12<=xi<=5.12;
#62 max f(...)= -1/N*sum(1, N, xi^4-16*xi^2+5*xi);
# -5.0<=xi<=5.0, 當N=100時,理論最大值=78.33236;
# 摘自:《適用於高維優化問題的改進進化策略》王湘中,喻壽益
# xu注:采用單峰值函數尋優方式
# f( -2.90353,..., -2.90353 ) = 78.332328796
# 采用多峰值函數方式:
# f( ) = 78.332328796
#
-1/100*sum(1, 100, xi^4-16*xi^2+5*xi);-5.0<=xi<=5.0;
#63 max f(...)= -(sum(1, N, fabs(xi))+prod(1, N, fabs(xi)));
# -10<=xi<=10, 當N=100時,理論最大值=0;
# 摘自:《適用於高維優化問題的改進進化策略》王湘中,喻壽益
-(sum(1, 50, fabs(xi))+prod(1, 50, fabs(xi)));-10<=xi<=10;
#64 max f(x)=20+x+10*sin(4*pi)+8*cos(3*x); 0<=x<=10;
# 該函數有多個極大值點,其全局最大點:f(8.291484)=45.865 953;
# xu注:f(8.39147) = 36.384525299
# 摘自:《一種求解參數優化問題的引導交叉算子》 陳喬禮等,
# 計算機工程, 2008 年1 月。
#
20+x+10*sin(4*pi)+8*cos(3*x); 0<=x<=10;
#65 max f(x,y)=sin(sqrt(x^2+y^2))-cos(sqrt(fabs(x^2-y^2)))
# -0.02*(y-4.96)^2-0.02*(x-5.87)^2;
# -10<=x,y<=10;
# 該函數是一個多峰的非線性函數,一般的遺傳算法很容易陷入局部極值。
# xu注: f( 5.97715, 5.08469 ) = 1.999437094
# 摘自:《基於立隊競爭的演化算法》黃樟燦等 有圖!
sin(sqrt(x^2+y^2))-cos(sqrt(fabs(x^2-y^2)))-0.02*(y-4.96)^2-0.02*(x-5.87)^2; -10<=x,y<=10;
#66 min f(x)=1/D*sum(1, D, xi^2)-4*D*prod(1, D, cos(xi));
# -5<=xi<=5; i=1,2,...,D 多峰性質的函數,
# 這個函數在全局最小值周圍有大量的局部極小值.全局最小值點為
# (0,0,...,0),相應最小值為-4D.
# 摘自:<一種函數優化問題的混合遺傳算法> 彭偉 盧錫城
1/10*sum(1, 10, xi^2)-4*10*prod(1, 10, cos(xi)); -5<=xi<=5;
1/100*sum(1, 100, xi^2)-4*100*prod(1, 100, cos(xi)); -5<=xi<=5;
#67 Himmelblau's function
# Max f(x,y)=200-(x^2+y-11)^2-(x+y^2-7)^2;
# This is a funtion of two variabes, x,y,(which Deb modified to
# a maximization problem) given by f(x,y).
# This has four maxima of equal heigh(200) approximately
# (3.58, -1.86),(3.0, 2.0), (-2.815, 3.125) and (-3.78, -3.28).
# A 30-bit chromosome is used to represent two 15-bit, binary-coded
# parameters, in the range -6<=x,y<=+6. The distance metric is the
# Eucidian distance in x-y space.
# 摘自:《A Sequential Niche Technique for Multimodal Function
# Optimization》 David Beasley Department of Computing
# Mathematics, University of Wales etc.
# xu注:
# 單峰值函數尋優,小生境初距=2.0,其余默認值;
# 多峰單峰值函數尋優,小生境初距=
# 1. f( -3.77931, -3.28319 ) = 200.000000000
# 2. f( -2.80512, 3.13131 ) = 200.000000000
# 3. f( 3.00000, 2.00000 ) = 200.000000000
# 4. f( 3.58443, -1.84813 ) = 200.000000000
# 5. f( -2.81439, 3.18689 ) = 199.871505737
#
200-(x^2+y-11)^2-(x+y^2-7)^2; -6<=x,y<=6;
#67-1 Himmelbau 函數
# max f(x,y)=660-(x^2+y-11)^2-(x+y^2-7); -6<=x,y<=6;
# 此函數為線性不可分的等高、不等距多峰函數,有4個極大值點,理論值
# 為660.0.
# 摘自:多模態函數優化的多種群進化策略 王湘中 ,喻壽益
# xu注:
# 1. f( 3.00000, 2.00000 ) = 660.000000000
# 2. f( -3.77931, -3.28319 ) = 660.000000000
# 3. f( -2.80512, 3.13131 ) = 660.000000000
# 4. f( 3.58443, -1.84813 ) = 660.000000000
#
660-(x^2+y-11)^2-(x+y^2-7)^2; -6<=x,y<=6;
#68 max f(x,y)=f(x,y)=21.5+x*sin(4*PI*x)+y*sin(20*PI*y)
# 定義域 D: -3<=x<=12.1 , 4.1<=y<=5.8
# 該函數是典型的多峰(震動劇烈)的函數。
# 目前最好結果:f(11.6255448,5.7250441)=38.8502944790207
# xu注:f(11.62554, 5.72504) = 38.850296021
#
21.5+x*sin(4*pi*x)+y*sin(20*pi*y); -3<=x<=12.1 && 4.1<=y<=5.8;
#69 min f(x,y)=-(x*sin(9*pi*y)+y*cos(25*pi*x)+20);
# -10<=x<=10, -10<=y<=10;
# 使其滿足非線性不等式 x^2+y^2<=9^2;
# 因為 D的面積很大 ,所以sin (9 πy) 與cos (25 πx) 分別在不同方向
# 上高頻振盪。 函數的深谷密集在圓 x^2+y^2<=9^2上的4個點
# (9/sqrt(2),,9/sqrt(2)) , (9/sqrt(2) , - 9/sqrt(2)) ,
# (-9/sqrt(2) ,9/sqrt(2)) , ( - 9/sqrt(2),- 9/sqrt(2)的附近。
# 求解這個函數的優化問題不僅傳統的算法無能為力 ,而且即使采用最新的
# 演化算法(遺傳算法或演化策略等)也很難求解。
# 采用郭濤算法獲得的精確到小數點后 14 位的最優解是
# minf(x,y)=f(- 6.440025882216888 , - 6.27797201362437)
# = - 32.71788780688353 ,
# 這個最優解在10次運算中只得到了1~3次。在此應注明的是,該問題的真
# 正最優解是未知的,認為它可能就是最優解。
# 摘自:郭濤算法及應用 李艷 康卓 劉溥 (武漢大學計算中心)
# xu注:不考慮非線性不等式時,
# f( 9.96002, -9.94457 ) = -39.904514313;
# f( -10.00000, 9.94457 ) = -39.944507599;
# 取-6.5<=x<=6.5&&-6.3<=y<=6.3時很快得
# (本程序還未實現有約束尋優):
# f( -6.44003, -6.27797 ) = -32.717887878;
#
-(x*sin(9*pi*y)+y*cos(25*pi*x)+20);-10<=x,y<=10;
-(x*sin(9*pi*y)+y*cos(25*pi*x)+20);-6.5<=x<=6.3 && -6.3<=y<=6.3;
#70 max f(x1, x2, x3, x4)=
# fabs(prod(1, 2, xi*sin(xi)))*prod(3, 4, xi*sin(xi));
# 0<=xi<=3*pi, i=1, 2, 3, 4; 最優解:3926.3
# 來源:基於搜索空間信息的新型遺傳算法
# 李 航,李敏強,寇紀淞 (天津大學系統工程研究所)
# xu注:f( 7.97867, 7.97867, 7.97867, 7.97867 ) = 3928.102050781
#
fabs(prod(1, 2, x[i]*sin(x[i])))*prod(1, 2, x[i+2]*sin(x[i+2])); 0<=x[i], x[i+2]<=9.42468;
fabs(prod(1, 2, x[i]*sin(x[i])))*prod(3, 4, x[i]*sin(x[i])); 0<=x[i]<=9.42468;
#71 max f(x1, ..., x5)=0.5+((sin(sqrt(x1^2+x2)))^2-0.5)
# /(1+0.0001*(x1^2+x2^2))^2+(x3^2+x4^2+x5^2)/12000;
# -20<=xi<=20, i=1, 2, 3, 4, 5;
# 最優解:1.0072
# 來源:基於搜索空間信息的新型遺傳算法
# 李 航,李敏強,寇紀淞 (天津大學系統工程研究所)
# xu注:文中公式可能有誤:sqrt(x1^2+x2)似應為sqrt(x1^2+x2^2)!
# 下式可能為正確的表達式。
# 最大值
# f( 0.63695, 1.43569, 20.00000, 20.00000, 20.00000 )
# = 1.099753380;
#
# 1. f( -1.56924, -0.06635, 20.00000, -20.00000, -20.00000 )
# = 1.099753380
# 2. f( -1.41341, 0.68497, 20.00000, -20.00000, -20.00000 )
# = 1.099753380
# 3. f( -1.40904, 0.69392, 20.00000, -20.00000, 20.00000 )
# = 1.099753380
# 最小值 f(0, 0, ..., 0)=0.0;
#
0.5+((sin(sqrt(x1^2+x2^2)))^2-0.5)/(1.0+0.0001*(x1^2+x2^2))^2+(x3^2+x4^2+x5^2)/12000; -20.0<=x1,x2, x3, x4, x5<=20.0;
#72 Leung&Wang’s Function9:
# Min f(xi) = 1/D*sum(1, D, xi^4-16*xi^2+5*xi);
# -5<=xi<=5;
# 全局最小值=-78.33236;
# 來源:一種高效Multi-agent仿生算法用於設計優化
# 梁昌勇,張俊嶺,楊善林
# (合肥工業大學計算機網絡系統研究所,合肥 230009)
# xu注: 終止代數=100,其余默認值。
# D=10
# f( -2.90353, -2.90353, ..., -2.90353 ) = -7.833233356
# D=30
# f( -2.90353, -2.90353, ..., -2.90353 ) = -78.332328796
# D=100
# f( -2.90353, -2.90353, ..., -2.90353 ) = -78.332328796
#
1/30*sum(1, 30, xi^4-16*xi^2+5*xi); -5.0<=xi<=5.0;
1/100*sum(1, 100, xi^4-16*xi^2+5*xi); -5.0<=xi<=5.0;
#73 Hwang&He's Function15
# Max f(xi) = sum(1, D, ((-1)^(i+1))*xi^2);
# -100<=xi<=100;
# 來源:一種高效Multi-agent仿生算法用於設計優化
# 梁昌勇,張俊嶺,楊善林
# (合肥工業大學計算機網絡系統研究所,合肥 230009)
# xu注:
# D=30
# f( -100.00000, 0.00000, -100.00000, 0.00000, -100.00000,
# ..., 0.00000, -100.00000, 0.00000 ) = 150000.000000000
# D=100
# f( -100.00000, 0.00000, 100.00000, 0.00000, -100.00000,
# ..., 0.00000, -100.00000, 0.00000 ) = 500000.000000000
#
sum(1, 30, (-1)^(i+1)*xi^2); -100<=xi<=100;
sum(1, 30, pow(-1.0, i+1)*pow(xi, 2)); -100<=xi<=100;
sum(1, 100, (-1)^(i+1)*xi^2); -100<=xi<=100;
#74 Ellipsoidal Function:
# Min f(xi) = sum(1, D, (xi-i)^2);
# -100<=xi<=100;
# 來源:一種高效Multi-agent仿生算法用於設計優化
# 梁昌勇,張俊嶺,楊善林
# (合肥工業大學計算機網絡系統研究所,合肥 230009)
# xu注:
# D=30 f(1,2,3,...,29,30)=0.000000000
# D=100 f(1,2,3,...,99,100)=0.000000000
#
sum(1, 30, (xi-i)^2); -100<=xi<=100;
sum(1, 100, (xi-i)^2); -100<=xi<=100;
#75 max f(x1, x2)=(a/(b+x1^2+x2^2))^2+(x1^2+x2^2)^2;
# -5.12<=x1,x2<=5.12;
# 在函數中,a=3.0, b=0.05, max f(0, 0)=3600,
# 4個局部極值為(-5.12 5.12), (-5.12, -5.12), (5.12 -5.12)
# 和(5.12, 5.12) ,函數值則為2748.78,這是一類全局最優解
# 被次優解所包圍,隔斷了模式的重組過程,使得搜索長期陷入
# 局部極值點.
# 來源:求解多峰函數的改進粒子群算法的研究 江寶釧, 胡俊溟
#
(3.0/(0.05+x1^2+x2^2))^2+(x1^2+x2^2)^2; -5.12<=x1,x2<=5.12;
#76 Simple Test Function with 16 Global Optima
# Min f(x) = fabs((x-3)*(x-6)*(x-9)*(x-12))
# +fabs((y-4)*(y-8)*(y-12)*(y-16));
# -20<=x, y<=20;
# 具有16個全局最小值。
# 來源:A Simple, Powerful Differential Evolution Algorithm
# for Finding Multiple Global Optima.pdf
# xu注:最優保存數=20~22,其余默認值。
# 1. f( 3.00000, 4.00000 ) = 0.000000000
# 2. f( 3.00000, 8.00000 ) = 0.000000000
# 3. f( 3.00000, 12.00000 ) = 0.000000000
# 4. f( 3.00000, 16.00000 ) = 0.000000000
# 5. f( 6.00000, 4.00000 ) = 0.000000000
# 6. f( 6.00000, 8.00000 ) = 0.000000000
# 7. f( 6.00000, 12.00000 ) = 0.000000000
# 8. f( 6.00000, 16.00000 ) = 0.000000000
# 9. f( 9.00000, 4.00000 ) = 0.000000000
# 10. f( 9.00000, 8.00000 ) = 0.000000000
# 11. f( 9.00000, 12.00000 ) = 0.000000000
# 12. f( 9.00000, 16.00000 ) = 0.000000000
# 13. f( 12.00000, 4.00000 ) = 0.000000000
# 14. f( 12.00000, 8.00000 ) = 0.000000000
# 15. f( 12.00000, 12.00000 ) = 0.000000000
# 16. f( 12.00000, 16.00000 ) = 0.000000000
#
fabs((x-3)*(x-6)*(x-9)*(x-12))+fabs((y-4)*(y-8)*(y-12)*(y-16)); -20<=x, y<=20;
#77 Branin's Function 變型
# Min f(x) = (x2-5/(4*pi^2)*x1^2+5/pi*x1-6)^2+10*(1-1/(8*pi))*cos(x1)+10;
# -5<=x1<=10 && 0<=x2<=15; 將其中cos(x1)改為cos(x2).
# 有全局極小值4個:
# 1. f( 10.39528, 3.14159 ) = 0.397887349
# 2. f( 14.43913, 9.42478 ) = 0.397887349
# 3. f( -1.87276, 9.42478 ) = 0.397887349
# 4. f( 2.17109, 3.14159 ) = 0.397887349
#
(x2-5/(4*pi^2)*x1^2+5/pi*x1-6)^2+10*(1-1/(8*pi))*cos(x2)+10; -5<=x1,x2<=15;
#78 Rosenbrock's Saddle function
# Min f(x) = sum(1, n/2, 100*(x[2*i]-x[2*i-1])^2+(1-x[2*i-1])^2);
# -10<=xi<=10; for i=1,2,...,n;
# This equation has only one global optimal solution.
# 來源:A Simple, Powerful Differential Evolution Algorithm
# for Finding Multiple Global Optima.pdf
# xu:
# f( 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
# 1.00000, 1.00000, 1.00000, 1.00000 ) = 0.000000000
# xu注:注意,含下標的變量在變量定義域表達式的表示形式要和數學表達式
# 中的一致!
#
sum(1, 5, 100*(x[2*i]-x[2*i-1])^2+(1-x[2*i-1])^2); -10<=x[2*i],x[2*i-1]<=10;
sum(1, 10, 100*(x[2*i]-x[2*i-1])^2+(1-x[2*i-1])^2); -10<=x[2*i],x[2*i-1]<=10;
sum(1, 30, 100*(x[2*i]-x[2*i-1])^2+(1-x[2*i-1])^2); -10<=x[2*i],x[2*i-1]<=10;
#79 Branin's function is defined as:
# f(x)=(1-2*x2+1/20*sin(4*pi*x2)-x1)^2+(x2-1/2*sin(2*pi*x1))^2;
# -10<=x1,x2<=10; which has five solutions:
# f(1, 0)=0;
# f(0.148696, 0.402086)=0;
# f(0.402537, 0.287408)=0;
# f(1.59746, -0.287408)=0;
# f(1.85130, -0.402086)=0;
# 來源:http://www.staff.brad.ac.uk/jpli/research/scga/function/branin.htm
# xu注:
# 單峰值函數尋優方式,默認值。運行100次人為終止;
# 多峰值函數尋優方式,小生境初距=0.15,最優保存數=8,其余默認值;
# 1. f( 0.14870, 0.40209 ) = 0.000000000
# 2. f( 0.40254, 0.28741 ) = 0.000000000
# 3. f( 1.00000, 0.00000 ) = 0.000000000
# 4. f( 1.59746, -0.28741 ) = 0.000000000
# 5. f( 1.85130, -0.40209 ) = 0.000000000
#
(1-2*x2+1/20*sin(4*pi*x2)-x1)^2+(x2-1/2*sin(2*pi*x1))^2; -10<=x1,x2<=10;
#80 Test tube holder function(a):
# min f(x) = -4*fabs(sin(x1)*cos(x2)*exp(fabs(cos((x1^2+x2^2)/200))));
# -10<=x1,x2<=10;
# 這是多模式函數. 我們在定義域中的最優解:-10.8723。
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India). 有圖!
# xu注:取默認值
# 1. f( 1.57060, 0.00000 ) = -10.872300148
# 2. f( -1.57060, 0.00000 ) = -10.872300148
#
-4*fabs(sin(x1)*cos(x2)*exp(fabs(cos((x1^2+x2^2)/200)))); -10<=x1,x2<=10;
#81 Holder table function
# This 'tabular holder' function has multiple local minima with
# four global minima at f(x*)=26.92. This function is geven as:
# f(x) = -fabs(cos(x1)*cos(x2)*exp(fabs(1-((x1^2+x2^2)^0.5)/pi)));
# -10<=x1,x2<=10;
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India). 有圖!
# xu注:多峰值函數尋優方式,最優保存數=6 ,其余默認值。
# 1. f( -9.64617, -9.64617 ) = -26.920335770
# 2. f( -9.64617, 9.64617 ) = -26.920335770
# 3. f( 9.64617, -9.64617 ) = -26.920335770
# 4. f( 9.64617, 9.64617 ) = -26.920335770
#
-fabs(cos(x1)*cos(x2)*exp(fabs(1-((x1^2+x2^2)^0.5)/pi))); -10<=x1,x2<=10;
# 82. Egg holder function: This function is in m (m>=2) variable and
# given as:
# Min f(x)= sum(1, m-1, -(x[i+1]+47)*sin(sqrt(fabs(x[i+1]+x[i]/2+47)))
# +sin(sqrt(fabs(x[i]-(x[i+1]+47))))*(-x[i]));
# -512<=x[i], x[i+1]<=512;
# We obtain Min f(512, 404.2319)=959.64. It is a difficult function
# to optimize.
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India). 有圖!
# xu注:
# m=2 取默認值
# f( 512.00000, 404.23181 ) = -959.640686035
# m=3 取默認值 采用多峰值函數尋優方式成功率更高!
# f( 481.46189, 436.93043, 451.77073 ) = -1888.321289063
# m=10 群體個體數=15, 最優保存數=30, 小生境初距=10
# 終止代數=300;
# f( 480.85241, 431.37422, 444.90869, 457.54722, 471.96252,
# 427.49729, 442.09134, 455.11942, 469.42931, 424.94060
# ) = -8291.240234375
#
sum(1, 1, -(x[i+1]+47)*sin(sqrt(fabs(x[i+1]+x[i]/2+47)))+sin(sqrt(fabs(x[i]-(x[i+1]+47))))*(-x[i])); -512<=x[i], x[i+1]<=512;
sum(1, 2, -(x[i+1]+47)*sin(sqrt(fabs(x[i+1]+x[i]/2+47)))+sin(sqrt(fabs(x[i]-(x[i+1]+47))))*(-x[i])); -512<=x[i], x[i+1]<=512;
sum(1, 9, -(x[i+1]+47)*sin(sqrt(fabs(x[i+1]+x[i]/2+47)))+sin(sqrt(fabs(x[i]-(x[i+1]+47))))*(-x[i])); -512<=x[i], x[i+1]<=512;
#83. Pen holder function: This is a multi-modal function with
# f(x*) = -0.96354 in search domain -11<=x1,x2<=11, given as
# min f(x) = -exp(-1/fabs(cos(x1)*cos(x2)
# *exp(fabs(1-((x1^2+x2^2)^0.5/pi)))));
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India). 有圖!
# xu注:取默認值
# 1. f( -9.64617, -9.64617 ) = -0.963534832
# 2. f( 9.64617, -9.64617 ) = -0.963534832
# 3. f( -9.64617, 9.64617 ) = -0.963534832
# 4. f( 9.64617, 9.64617 ) = -0.963534832
#
-exp(-1/fabs(cos(x1)*cos(x2)*exp(fabs(1-((x1^2+x2^2)^0.5/pi))))); -11<=x1,x2<=11;
#84. Bird function: This is a bi-modal function with f(x*)=-106.764637
# in the search domain -pi<=x1,x2<=pi; give as
# min f(x) = sin(x1)*exp((1-cos(x2))^2)+cos(x2)*exp((1-sin(x1))^2)
# +(x1-x2)^2;
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India)。 有圖!
# xu注:取默認值
# f( -1.58214, -3.13025 ) = -106.764533997
#
sin(x1)*exp((1-cos(x2))^2)+cos(x2)*exp((1-sin(x1))^2)+(x1-x2)^2; -pi<=x1,x2<=pi;
#85. Giunta function: In the search domain -1<=x1,x2<=1 this function is
# defined as follows and has min f(0.45834282, 0.45834282)=0.0602472184.
# f(x) = 0.6+sum(1, 2, sin(16/15*xi-1)+sin(16/15*xi-1)^2
# +1/50*sin(4*(16/15*xi-1)));
# We have obtained min f(0.4673199, 0.4673183)=0.06447.
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India)。 有圖!
# xu注:取默認值
# f( 0.46732, 0.46732 ) = 0.064470418
#
0.6+sum(1, 2, sin(16/15*xi-1)+sin(16/15*xi-1)^2+1/50*sin(4*(16/15*xi-1))); -1<=xi<=1;
#86. Crowned cross function: This function is the negative form of the
# cross in tray function. It has f(x*) = 0 in search domain
# -10<=x1, x2<=10. It is a difficult function to optimize. The minimal
# value obtained by us is approximately 0.1. This function is given as:
# f(x) = 0.0001*pow(fabs(sin(x1)*sin(x2)
# *exp(fabs(100-((x1^2+x2^2)^0.5)/pi)))+1.0),0.1);
# 來源:Some New Test Functions for Global Optimization
# and Performance of Repulsive Particle Swarm Method
# SK Mishra Dept. of Economics North-Eastern Hill University
# Shillong (India)。 有圖!
# xu注:采用多峰值函數尋優方式。群體個體數=20, 最優保存數=30,
# 其余默認值。
# 全局最小值:無數個,呈+字分布,符合該函數的圖形情況。
# 全局最大值:
# 1. f( -1.34941, -1.34941 ) = 2.062611818
# 2. f( -1.34941, 1.34941 ) = 2.062611818
# 3. f( 1.34941, -1.34941 ) = 2.062611818
# 4. f( 1.34941, 1.34941 ) = 2.062611818
#
0.0001*pow(fabs(sin(x1)*sin(x2)*exp(fabs(100-((x1^2+x2^2)^0.5)/pi))+1.0), 0.1); -10<=x1, x2<=10;
#87. min f(x,y)=-0.2*(sin(x+4*y)-2*cos(2*x+3*y)-3*sin(2*x-y)+4*cos(x-2*y));
# -5<=x, y<=5;
# 最小值:
# 1. f( 2.84989, -4.99798 ) = -1.937273502
# 2. f( -3.43330, 1.28520 ) = -1.937273502
# 3. f( -3.43330, -4.99798 ) = -1.937273502
# 4. f( 2.84989, 1.28520 ) = -1.937273502
# 最大值:
# f( -0.29171, 4.42680 ) = 1.937273502
# f( -0.29171, -1.85639 ) = 1.937273502
#
-0.2*(sin(x+4*y)-2*cos(2*x+3*y)-3*sin(2*x-y)+4*cos(x-2*y)); -5<=x, y<=5;
#88. min f(x) = 1/N*sum(1, N, xi^4-16*xi^2-5*xi); -5<=xi<=10;
# 全局最優值 -78.33236
# 來源:用於全局優化的混合正交遺傳算法 江中央,蔡自興,王 勇
# (中南大學信息科學與工程學院,長沙 410083)
#
1/100*sum(1, 100, xi^4-16*xi^2-5*xi); -5<=xi<=10;