Multi Variable Function Test Function
Multi Variable Function Test Function
Contents
1 MVF, a library of test functions in C
2 Test functions
2.1 Ackley function . . . . . . . . . . . .
2.2 Beale function . . . . . . . . . . . . .
2.3 Bohachevsky functions . . . . . . . .
2.4 Booth function . . . . . . . . . . . .
2.5 Box-Betts exponential quadratic sum
2.6 Branin function . . . . . . . . . . . .
2.7 Camel functions . . . . . . . . . . .
2.8 Chichinadze function . . . . . . . . .
2.9 Cola function . . . . . . . . . . . . .
2.10 Colville function . . . . . . . . . . .
2.11 Corana function . . . . . . . . . . . .
2.12 Easom function . . . . . . . . . . . .
2.13 Egg holder function . . . . . . . . .
2.14 Exp2 function . . . . . . . . . . . . .
2.15 Gear function . . . . . . . . . . . . .
2.16 Goldstein-Price function . . . . . . .
2.17 Griewank function . . . . . . . . . .
2.18 Hansen function . . . . . . . . . . .
2.19 Hartman function . . . . . . . . . . .
2.20 Himmelblau function . . . . . . . . .
2.21 Hyperellipsoid function . . . . . . . .
2.22 Kowalik function . . . . . . . . . . .
2.23 Holzman functions . . . . . . . . . .
2.24 Hosaki function . . . . . . . . . . . .
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
3
3
4
4
4
4
4
5
5
5
5
6
6
6
6
6
6
7
7
7
7
8
8
2.25
2.26
2.27
2.28
2.29
2.30
2.31
2.32
2.33
2.34
2.35
2.36
2.37
2.38
2.39
2.40
2.41
2.42
2.43
2.44
2.45
2.46
2.47
2.48
2.49
2.50
2.51
2.52
2.53
2.54
2.55
2.56
2.57
2.58
Katsuuras function . . . . . . . .
Langerman function . . . . . . .
Lennard-Jones potential function
Leon function . . . . . . . . . . .
Levy functions . . . . . . . . . .
Matyas function . . . . . . . . .
MaxMod function . . . . . . . . .
McCormick function . . . . . . .
Michalewitz function . . . . . . .
Multimod function . . . . . . . .
Neumaier test functions . . . . .
Odd square function . . . . . . .
Paviani function . . . . . . . . .
Plateau function . . . . . . . . .
Powell function . . . . . . . . . .
Price function . . . . . . . . . . .
Quartic with noise functions . . .
Rana function . . . . . . . . . . .
Rastrigin function . . . . . . . .
Rosenbrock saddle functions . . .
Schaffer functions . . . . . . . . .
Schubert function . . . . . . . . .
Schwefel functions . . . . . . . .
Shekel foxholes functions . . . . .
Sphere (harmonic) functions . . .
Step function . . . . . . . . . . .
Strectched V function . . . . . .
SumSquares function . . . . . . .
Trecanni function . . . . . . . . .
Trefethen4 function . . . . . . . .
Watson function . . . . . . . . .
Xor function . . . . . . . . . . .
Zettl function . . . . . . . . . . .
Zimmerman function . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
8
9
9
9
10
10
10
10
10
10
11
11
11
12
12
12
12
12
13
13
13
13
14
16
16
16
16
16
17
17
17
17
17
A Source codes
19
A.1 mvf.h header file . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
A.2 MVF.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
B Random number routines
51
B.1 rnd.h header file for random number generator . . . . . . . . . . 51
B.2 rnd.c, basic random number routines . . . . . . . . . . . . . . . . 52
C Creating Python bindings with SWIG
55
Test functions
2.1
Ackley function
2.2
Beale function
with domain 4.5 xi 4.5. The global minimum is 0 at the point (3, 0.5).
2.3
Bohachevsky functions
2.4
Booth function
2.5
n1
X
g(xi )2
i=0
2.6
Branin function
2
5x0
1
5.1x20
+
+
10
1
cos(x0 ) + 10
6
x1
4 2
with domain 5 < x0 10, 0 x1 15. It has a global minimum function value of 0.398 at the points (3.142, 12.275), (3.142, 2.275), (9.425, 2.425).
mvfBranin2 computes the value
f (n, x) = (1.02.0x[1]+sin(4.0x[1])/20.0x[0]) 2+(x[1]sin(2.0x[0])/2.0)2 ;
with test domain |xi | = 10. The global minimum is 0 at the point (0.402357, 0.287408).
2.7
Camel functions
2.8
Chichinadze function
(x1 1/2)2
1
2.9
Cola function
X
j<i
(ri,j di,j )2
...
1.27 . . .
1.69 1.43 . . .
given by
...
2.85
2.88
2.59
3.12
3.17
1.94
...
1.55
3.12
1.31
1.70
2.85
...
3.06
1.64
1.36
2.81
...
3.00 . . .
2.95 1.32 . . .
2.56 2.91 2.97 . . .
2.10
Colville function
2.11
Corana function
3
X
0.15(zi 0.05 sgn(zi ))2 di
di x2i
i=0
where zi = b|xi /0.2| + 0.49999csgn(xi )0.2 and d = (1, 1000, 10, 100).
2.12
Easom function
2.13
n2
X
i=0
2.14
Exp2 function
9
2
X
eix0 /10 5eix1 /10 ei/10 + 5ei
i=0
with domain 0 xi 20. It has a global minimum of 0 at the point (1, 10).
2.15
Gear function
2.16
Goldstein-Price function
2.17
Griewank function
(x20 + x21 )
cos(x0 ) cos(x1 / 2) + 1
200
with test domain |xi | 100 while the 10-dimensional Griewank[G] function
mvfGriewank10 computes the value
f (n, x) =
n1
n1
Y
xi 100
1 X
cos
(xi 100)2
+1
4000 i=0
i+1
i=0
with test domain |xi | 600. The global minimum for both functions is 0 at
xi = 0.
2.18
Hansen function
4
X
(i + 1) cos(ix0 + i + 1)
4
X
(j + 1) cos((j + 2)x1 + j + 1)
j=0
i=0
2.19
Hartman function
n1
3
X
X
Ai,j (xj pi,j )2
ci exp
f (n, x) =
j=0
i=0
3 10 30
0.1 10 35
t
For n = 3, we have A =
3 10 30 , c = (1, 1.2, 3, 3.2) and
0.1 10 35
p=
0.1091 0.8732 0.5547 and the global minimum is f 3.86 at
0.03815 0.5743 0.8828
x? = (0.114, 0.556, 0.852).
10
3
17 3.5 1.7 8
0.05 10
17 0.1
8 14
, c = (1, 1.2, 3, 3.2)t ,
For n = 6, we have A =
3 3.5
1.7 10 17 8
17
8 , 0.05 10 0.1 14
p=
0.2348 0.1451 0.3522 0.2883 0.3047 0.6650 and the global min0.4047 0.8828 0.8732 0.5743 0.1091 0.0381
imum is 3.32 at the point (0.201, 0.150, 0.477, 0.275, 0.311, 0.657).
2.20
Himmelblau function
2.21
Hyperellipsoid function
2.22
Kowalik function
10
X
i=0
where a and b are defined as a = (0.1957, 0.1947, 0.1735, 0.1600, 0.0844, 0.0627,
0.0456, 0.0342, 0.0323, 0.0235, 0.0246) with b = (4, 2, 1, 1/2, 1/4, 1/6, 1/8, 1/10, 1/12,
1/14, 1/16). The Kowalik function has domain |x i | < 5.
Global minimum is f ? = 0.00030748610 at x? = (0.192833, 0.190836, 0.123117, 0.135766).
2.23
Holzman functions
where
n1
X
ix4i
i=0
2.24
Hosaki function
2.25
Katsuuras function
k=1
2.26
Langerman function
29
X
i=0
ci exp(
(x Ai )t (x Ai )
) cos((x Ai )t (x Ai ))
with domain 0 xj 10, j [0, n 1]. The matrix A and column vector c
are identical for Shekels foxhole mvfFoxhole function except that c 2 = 1.5 for
Langermans function. Langermans function has a global minimum value of
-1.4.
2.27
1
N
2 N
X
X
i=0 j>i
1
1
6
12
rij
rij
The variables are the coordinates of the atoms. Tables of the putative minimum
potential and the corresponding configuration of the atoms are listed in the
Cambridge database with url http://brian.ch.cam.ac.uk/CCD.html
2.28
Leon function
2.29
Levy functions
n2
X
(xi 1)
i=0
1 + sin2 (3xi+1 ) +(xn1 1)(1+sin2 (2xn1 ))
4
4
X
X
(j + 1) cos((j + 2)x1 + j + 1)
(i + 1) cos((i + 2)x0 + i + 1)
j=0
i=0
n2
X
i=0
where yi = 1 +
0 at xi = 1.
xi 1
4 .
2.30
Matyas function
2.31
MaxMod function
2.32
McCormick function
2.33
Michalewitz function
n
X
sin(xi ) sin20 (
i=0
ix2i
)
2.34
Multimod function
n1
X
i=0
|xi |
n1
Y
i=0
|xi |
2.35
The following functions were introduced by Neumaier for testing global optimization software. The url http://www.mat.univie.ac.at/ neum/glopt/my problems.html
should be consulted for further information.
The function mvfNeumaierPerm is computed as
P ERM (n, beta) : f (n, x) =
n1
X n1
X
k=0 i=0
n1
X
k=0
k+1
(sumn1
(1/(i + 1))( k + 1)])2
i=0 [i + 1 + beta][(xi )
i=0
Pn1
k+1
for a target solution z, then the global minimum
If the bk =
i=0 zi
f = 0. Suggested test instance for b = (8, 18, 44, 114) with x i [0, 4]. This has
the solution (1, 2, 2, 3).
The fourth Neumaier test function mvfNeumaierTrid is calculated as
f (n, x) = [
n1
X
i=0
(xi 1)2 ] [
n1
X
xi xi1 ]
i=1
2.36
This function mvfOddSquare has domain |xi | 5 and the dimension usually
is 5 or 10. Let d22 = ||x a||22 and d2 = ||x a||2 .
f (n, x) = exp(cos(d2 )/(2)) cos(d2 ) (1 + cd22 )/(d1 + 0.01))
The constant c is set at 0.2 and the vector a = (1, 1.3, 0.8, 0.4, 1.3, 1.6, 0.2, 0.6, 0.5, 1.4).
2.37
Paviani function
n1
X
i=0
n1
Y
i=0
xi
!0.2
2.38
Plateau function
4
X
i=0
bxi c
11
2.39
Powell function
n/4
X
i=1
2.40
Price function
2.41
n1
X
xi 4 + N (0, 1)
i=0
where N (0, 1) is a normal random variate with zero mean and standard deviation
1. The related mvfQuarticNoiseU a uniform random variate in the interval
[0, 1].
2.42
Rana function
n2
X
i=0
where t1 =
2.43
p
p
|xi+1 + xi + 1.0| and t2 = |xi+1 xi + 1.0|.
Rastrigin function
n1
X
i=0
x2i 10 cos(2xi ) + 10
12
2.44
f (n, x) =
i=0
n1
X
i=1
Both functions have test domain |xi 10. The global minimum is 0 at xi = 1.
2.45
Schaffer functions
There are two 2-dimensional Schaffer functions in the mvf library. Both have
the same global minimum f = 0 at xi = 0. The first schaffer function mvfSchaffer1 computes
p
{sin( x20 + x21 )}2 0.5
f (n, x) = 0.5 +
{1.0 + 0.001(x20 + x21 )}2
and it has domain |xi | 100. The second function mvfSchaffer2 computes
f (n, x) = (x20 + x21 )1/4 (50(x20 + x21 )0.1 + 1)
2.46
Schubert function
j<5
n1
XX
i=0 j=0
with domain |xi | 10.0. It has global minimum -24.062499 at some points
(6.774576, 6.774576), . . . , (5.791794, 5.791794).
2.47
Schwefel functions
j<i
n1
X X
xi
f (n, x) =
i=0
j=0
with domain |xi | < 10. The global minimum function value is 0 at x i = 0. The
function mvfSchwefel2 21 computes the value
f (n, x) = max(|xi |)
13
with domain |xi | < 10. The global minimum is 0 at xi = 0. The function
mvfSchwefel2 22 computes the value
f (n, x) =
n1
X
i=0
|xi | +
n1
Y
i=0
|xi |
with domain |xi | < 10 and the global minimum function value 0 occurs at
xi = 0. The function mvfSchwefel2 26 returns the value
f (n, x) =
n1
X
xi sin( xi )
i=0
with domain |xi | < 500 and the global minimum is -12569.5 at xi = 420.9687
for n = 3.
The 3-dimensional function mvfSchwefel3 2 computes
f (n, x) =
n1
X
i=1
(x0 xi )2 + (1 xi )2 ;
with domain |xi | < 10. The global minimum function value is 0 at the point
(1,1,1).
2.48
X
1
1
1
=
+
P1
f (n, z)
500 j=0 cj + i=0 (xi Ai,j )6
with domain |xi | <= 65.536. The global minimum is 1 at the point (32, 32).
The matrix A is given by
32 16
0
16
32 32 . . . 0 16 32
A=
32 32 32 32 32 16 . . . 32 32 32
Shekel 4-dimensional foxhole is a 4-dimensional function which computes the
value of
m
X
1
f (n, x) =
t (x A ) + c
(x
A
)
i
i
i
i=0
with domain 0 xi 10. The most common values for m are 5,7 and 10,
giving rise to the corresponding functions mvfShekel4 5, mvfShekel4 7, and
mvfShekel4 10. The (10 4) matrix A is given by
4 4 4 4
1 1 1 1
8 8 8 8
6 6 6 6
3 7 3 7
A=
2 9 2 9
5 5 3 3
8 1 8 1
6 2 6 2
7 3.6 7 3.6
The column vector c is given by
c = (0.1, 0.2, 0.2, 0.4, 0.4, 0.6, 0.3, 0.7, 0.5, 0.5) t
The Shekel4 function has the following behavior for m = 5, 7, 10:
14
m
5
7
10
Global Minimum
-10.1532
-10.403
-10.5364
Points
(4.00004, 4.00013, 4.00004, 4.00013)
(4.00057,4.00069,3.99949,3.99961)
(4.00075,4.00059,3.99966,3.99951)
29
X
i=0
1
(x Ai )t (x Ai ) + ci
where Ai is the ith row of a (30 10) matrix and ci is the (i + 1)th element of a
30-rowed column vector c. This function has domain 0 x j 10, j [0, n 1].
The matrix A is given by
2
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
A=6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
4
9.681
9.400
8.025
2.196
8.074
7.650
1.256
8.314
0.226
305
0.652
2.699
8.327
2.132
4.707
8.304
8.632
4.887
2.440
6.306
0.652
5.558
3.352
8.798
1.460
0.432
0.679
4.263
9.496
4.138
0.667
2.041
9.152
0.415
8.777
5.658
3.605
2.261
8.858
2.228
7.027
3.516
3.897
7.006
5.579
7.559
4.409
9.112
6.686
8.583
2.343
1.272
7.549
0.880
8.057
8.645
2.800
1.074
4.830
2.562
4.783
3.788
5.114
5.649
3.467
0.720
8.623
4.224
1.420
1.242
0.508
5.874
2.017
7.136
4.080
8.567
4.832
0.170
4.299
6.084
1.370
5.756
9.817
2.370
1.336
8.774
5.523
7.286
3.150
2.532
9.095
7.931
7.621
6.979
1.863
2.764
6.905
1.781
0.945
5.928
4.876
4.119
9.570
2.641
0.581
0.322
5.768
8.967
1.007
1.138
0.821
9.857
9.437
0.168
7.217
0.249
3.049
5.599
8.270
9.661
3.517
2.882
4.564
9.510
6.708
3.278
0.584
4.124
1.622
9.133
8.807
4.461
9.825
1.882
9.698
7.128
7.050
9.693
7.008
4.350
1.310
2.279
8.687
1.701
7.914
8.081
2.968
8.291
5.079
5.611
9.325
2.672
4.711
9.166
6.349
5.283
8.133
0.932
4.698
1.826
4.632
7.496
1.150
5.943
8.542
8.392
6.715
9.867
1.427
3.134
1.063
2.764
4.167
3.680
3.615
7.461
7.225
5.200
1.231
5.500
6.544
3.568
2.996
6.304
4.534
7.474
6.071
8.129
6.228
4.060
5.808
8.817
1.395
7.273
8.077
1.472
1.711
7.508
9.398
7.853
0.689
1.284
2.570
1.231
9.981
4.416
6.730
9.214
5.731
6.886
0.211
1.284
6.126
6.054
0.276
6.274
6.888
8.658
9.096
5.204
6.937
0.690
3.885
7.691
8.515
8.524
4.323
7.770
8.480
6.061
8.819
1.677
6.540
2.390
9.198
0.652
4.199
8.272
9.494
2.341
5.122
7.033
0.734
9.377
7.633
1.409
4.187
1.208
0.972
8.713
3.291
6.593
6.354
2.880
9.231
2.277
4.405
8.382
9.950
7.457
8.833
1.244
0.228
2.499
5.292
4.002
9.614
4.398
1.883
9.699
2.020
7.374
4.982
1.426
1.567
8.208
5.448
5.762
7.637
8.247
7.016
9.789
0.109
0.564
4.670
7.826
4.591
6.740
1.675
2.258
9.070
1.234
0.027
0.064
1.224
4.644
9.229
4.506
9.732
6.500
3
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
5
15
2.49
n1
X
x2i
i=0
n1
X
X j<=i
i=0
xj }2
j=0
2.50
Step function
n1
X
i=0
(bxi c + 0.5)
in the domain |x| = 100. It has a global minimum 0 at x i = 0.5. The presence
of many flat plateus and steep ridges presents difficulties for algorithms based
on gradient information.
Another step function mvfStep2 is given by
f (n, x) = 6n +
n1
X
i=0
bxi c
2.51
Strectched V function
n2
X
i=0
where t =
2.52
x2i+1
x2i .
SumSquares function
n1
X
ix2i
i=0
2.53
Trecanni function
2.54
Trefethen4 function
The 2-dimensional function mvfTrefethen4 appeared as an global minimization problem in an international contest for obtaining 100 accurate digits.
f (n, x) =exp(sin(50.0 x[0])) + sin(60.0 exp(x[1])) + sin(70.0 sin(x[0]))
+ sin(sin(80 x[1])) sin(10.0 (x[0] + x[1]))
+ 1.0/4.0 (x[0] x[0] + x[1] x[1])
The domain is 6.5 < x[0] < 6.5, 4.5 < x[0] < 4.5 and the global minimum
is attained at (0.0244031, 0.2106124) with value 3.30686865.
2.55
Watson function
5
4
29 X
X
X
aji xj+1 1}2 + x20
{ ((j 1)aji xj+1 )
j=0
i=0 j=0
2.56
Xor function
2.57
Zettl function
2.58
Zimmerman function
17
References
[BH] Bjorkman, Mattias Kenneth Holmstrom, Global optimization using the
Direct algorithm in Matlab, URL:http://www.ima.mdh.se/tom
[CDG99] Corne, Dorigo Glover, New Ideas in Optimization, McGraw-Hill,
1999
[DS] L. C. W. Dixon and G. P. Szego, Eds., Towards Global Optimization 2,
Amsterdam, North Holland, 1978.
[DTU] URL:http://www.imm.dtu.dk/ km/GlobOpt/testex/testproblems.html
[GP] A. A. Goldstein I. F. Price, On descent from local minima, Math. Comput. 25 (July 1971).
[G] A. O. Griewank, Generalized Descent for global optimization, Journal of
optimization theory and applications, Vol 34, No. 1, pp. 11-39, 1981
[H] J. K. Hartman, Tech. Rept. NP55HH72051A, Naval Postgraduate School,
Monterey, CA, 1972
[I]
18
Source codes
19
A.1
#ifndef _MVF_H
#define _MVF_H
double
double
double
double
double
double
sqr (double x );
dmax (int n ,double * x );
sgn (double x );
dist2 (int n ,double * x ,double * y );
distInf (int n ,double * x ,double * y );
prod (int n ,double * x );
20
_Zh1 (double * x );
_Zh2 (double * x );
_Zh3 (double * x );
_Zp (double x );
mvfZimmerman (int n ,double * x );
A.2
MVF.c
The code listings for the functions are in the mvf.c file. Feel free to use
them for research purposes.
/*
21
File
mvf.c
Original compiled by Ernie.
Revisions:
2003.01.30 Ver 0.1
2004.03.05 Added EggHolder, StretchedV, Rana functions
from http://www.ft.utb.cz/people/zelinka/soma/
2004.04.19 http://www.mat.univie.ac.at/~neum/glopt/janka/funcs.html
Bohachevsky1, Bohachevsky2, Easom
Hyperellipsoid, Neumaier2, Neumaier3,
Oddsquare, Schaffer1, Schaffer2, Zimmerman
- LennardJones
Corana
Xor
*/
#include <stdio.h>
#include <math.h>
#include "rnd.h"
#include "mvf.h"
// ============================================== //
double sqr( double x )
{
return x*x;
};
double dmax(int n, double *x)
{
int i;
double m = x[0];
for (i = 1; i < n; i++) {
if (x[i] > m) m = x[i];
}
return m;
}
double sgn(double x)
{
if (x < 0.0) return -1.0;
return 1.0;
}
double dist2(int n, double *x, double *y)
{
register int i;
double s, t;
s = 0.0;
for (i = 1; i < n; i++) {
t = (x[i]-y[i]);
s += t * t;
22
}
return s;
}
double distInf(int n, double *x, double *y)
{
register int i;
double t,m;
m = fabs(x[0] - y[0]);
for (i = 1; i < n; i++) {
t = fabs(x[i]-y[i]);
if (t > m) {
m = t;
}
}
return m;
}
= 0; i < n; i++) {
= x[i];
+= t * t;
+= cos(2.0*M_PI * x[i]);
-20.0 * exp(-0.2 * sqrt(s1/n)) - exp(s2 / n) +
20.0 + M_E;
23
*/
{
int i;
double x0=x[0],x1=x[1],x2=x[2] ;
double sum=0.0 ;
for (i=1; i<=10 ; i++)
sum+=pow(exp(-0.1*i*x0)-exp(-0.1*i*x1)(exp(-0.1*i)-exp(-1.0*i))*x2,2.0);
return sum ;
}
double mvfBranin(int n, double *x)
/*
n = 2;
Domain: -5.0 < x[0] <= 10.0,
0 <= x[1] <= 15
Minimum: 0.397889 at (-3.142, 12.275),
(3.142, 2.275),
(9.425, 2.425)
*/
{
double s, x0;
x0 = x[0];
s = x[1] ( 5.1/(4.0*M_PI*M_PI) * x0 - 5.0/M_PI) * x0 - 6.0;
return s*s + 10*(1.0 - 1.0/(8.0*M_PI)) * cos(x0) + 10.0;
}
*/
{
double x1=x[0],x2=x[1] ;
return 4.0*x1*x1-0.21E1*pow(x1,4.0)
+ pow(x1,6.0)/3+x1*x2-4.0*x2*x2
+ 4.0*pow(x2,4.0);
}
double mvfChichinadze(int n, double *x)
/*
- Dimension: 2
- Domain: x[0] <= 30, x[1] <= 10
- f* = 43.3159
- x* = (5.90133, 0.5)
*/
{
return x[0]*x[0]-12 *x[0]+11+10*cos(M_PI/2.0*x[0])
+ 8 * sin(5 * M_PI * x[0])
- exp ( -(x[1] - 0.5) * 0.5) / sqrt(5.0);
}
static double dis[46] = {
1.27,
1.69,1.43,
2.04,2.35,2.43,
3.09,3.18,3.26,2.85,
3.20,3.22,3.27,2.88,1.55,
2.86,2.56,2.58,2.59,3.12,3.06,
3.17,3.18,3.18,3.12,1.31,1.64,3.00,
3.21,3.18,3.18,3.17,1.70,1.36,2.95,1.32,
2.38,2.31,2.42,1.94,2.85,2.81,2.56,2.91,2.97
};
double mvfCola( int n, double * x )
{
double sum = 0.0, temp;
int i, j, t, k = 1;
double mt[20] = {0, 0, 0, 0};
for( i = 4; i < 20; i++)
mt[i] = x[i-3];
for( i = 1; i < 10; i++)
for( j = 0; j < i; j++) {
temp = 0.0;
for( t = 0; t < 2; t++ )
temp += sqr( mt[i*2+t]-mt[j*2+t] );
sum += sqr( dis[k-1] - sqrt(temp) );
k++;
}
return sum;
}
26
/*
- Dimension: n
- Domain: | x_i | < 512
*/
{
int i;
double sum;
sum = 0.0;
for (i = 0; i < n-1; i++) {
sum += -(x[i+1] + 47.0) * sin(sqrt(fabs(x[i+1] + x[i] * 0.5 + 47.0))) +
sin(sqrt(fabs(x[i] - (x[i+1] + 47.0)))) * (-x[i]);
}
return sum;
}
int
i, j;
double s, t, t1;
1.2, 3,
{
0.5569,
0.8307,
0.3522,
0.8732,
3.2};
0.0124,
0.3736,
0.2883,
0.5743,
30
0.8283,
0.1004,
0.3047,
0.1091,
0.5886},
0.9991},
0.6650},
0.0381}
n = 6; // forced check
s = 0.0;
for (i = 0; i < 4; i++) {
t = 0.0;
for (j = 0; j < n; j++) {
t1 = x[j]-p[i][j];
t += a[i][j] * (t1*t1);
}
s += c[i] * exp(-t);
};
return -s;
}
double mvfHimmelblau(int n, double *x)
/*
- Dimension: 2
- Domain: | x[i] | < 5.0
- Global minimum: 0 at (3,2).
*/
{
return sqr(x[0]*x[0]+x[1]-11.0) + sqr(x[0]+x[1]*x[1]-7);
}
double mvfHolzman1(int n, double *x)
/*
Dimension: 3
Domain: 0.1 <= x[0] <= 100.0
0 <= x[1] <= 25.6
0 <= x[2] <= 5
Global minimum: 0 at (50, 25, 1.5)
*/
{
int
i;
double sum = 0.0;
double ui;
for (i = 0; i < 100; i++) {
ui = 25 + pow(-50.0*log(0.01*(i+1)),2.0/3.0);
sum += -0.1 * (i+1)
+exp(1/ x[0] * pow(ui-x[1], x[2]));
}
return sum;
}
double mvfHolzman2(int n, double *x)
/*
Dimension: n
Domain: | x[i] | <= 10
Global minimum: 0 at x[i] = 0
*/
{
int i;
double sum = 0.0;
31
}
prod *= 1.0 + (i+1) * s;
}
return prod;
}
double mvfKowalik(int n, double *x)
/*
-n = 4
-Domain: | x_i | < 5.0
-Global minimum is 0.0 at x_i = 0.00
*/
{
static double b[] = {
4.0, 2.0, 1.0, 1/2.0,1/4.0,1/6.0,1/8.0,
1/10.0,1/12.0,1/14.0, 1/16.0 };
static double a[] = {
0.1957, 0.1947, 0.1735, 0.1600, 0.0844,
0.0627, 0.0456, 0.0342, 0.0323, 0.0235,
0.0246 };
int
i;
double sum;
double bb, t;
sum = 0.0;
for (i = 0; i < 11; i++) {
bb = b[i] * b[i];
t = a[i]-(x[0]*(bb+b[i]*x[1])/(bb+b[i]*x[2]+x[3]));
sum += t * t;
}
return sum;
}
double afox10[30][10] = {
{ 9.681,0.667,4.783, 9.095, 3.517, 9.325, 6.544, 0.211, 5.122, 2.020},
{9.400, 2.041, 3.788, 7.931, 2.882, 2.672, 3.568, 1.284, 7.033, 7.374},
{8.025, 9.152, 5.114, 7.621, 4.564, 4.711, 2.996, 6.126, 0.734, 4.982},
{2.196, 0.415, 5.649, 6.979, 9.510, 9.166, 6.304, 6.054, 9.377, 1.426},
{8.074, 8.777, 3.467, 1.863, 6.708, 6.349, 4.534, 0.276, 7.633, 1.567},
{7.650, 5.658, 0.720, 2.764, 3.278, 5.283, 7.474, 6.274, 1.409, 8.208},
{1.256, 3.605, 8.623, 6.905, 0.584, 8.133, 6.071, 6.888, 4.187, 5.448},
{8.314, 2.261, 4.224, 1.781, 4.124, 0.932, 8.129, 8.658, 1.208, 5.762},
{0.226, 8.858, 1.420, 0.945, 1.622, 4.698, 6.228, 9.096, 0.972, 7.637},
{7.305, 2.228, 1.242, 5.928, 9.133, 1.826, 4.060, 5.204, 8.713, 8.247},
{0.652, 7.027, 0.508, 4.876, 8.807, 4.632, 5.808, 6.937, 3.291, 7.016},
{2.699, 3.516, 5.874, 4.119, 4.461, 7.496, 8.817, 0.690, 6.593, 9.789},
{8.327, 3.897, 2.017, 9.570, 9.825, 1.150, 1.395, 3.885, 6.354, 0.109},
{2.132, 7.006, 7.136, 2.641, 1.882, 5.943, 7.273, 7.691, 2.880, 0.564},
{4.707, 5.579, 4.080, 0.581, 9.698, 8.542, 8.077, 8.515, 9.231, 4.670},
{8.304, 7.559, 8.567, 0.322, 7.128, 8.392, 1.472, 8.524, 2.277, 7.826},
{8.632, 4.409, 4.832, 5.768, 7.050, 6.715, 1.711, 4.323, 4.405, 4.591},
{4.887, 9.112, 0.170, 8.967, 9.693, 9.867, 7.508, 7.770, 8.382, 6.740},
33
{2.440, 6.686, 4.299, 1.007, 7.008, 1.427, 9.398, 8.480, 9.950, 1.675},
{6.306, 8.583, 6.084, 1.138, 4.350, 3.134, 7.853, 6.061, 7.457, 2.258},
{0.652, .343, 1.370, 0.821, 1.310, 1.063, 0.689, 8.819, 8.833, 9.070},
{5.558, 1.272, 5.756, 9.857, 2.279, 2.764, 1.284, 1.677, 1.244, 1.234},
{3.352, 7.549, 9.817, 9.437, 8.687, 4.167, 2.570, 6.540, 0.228, 0.027},
{8.798, 0.880, 2.370, 0.168, 1.701, 3.680, 1.231, 2.390, 2.499, 0.064},
{1.460, 8.057, 1.336, 7.217, 7.914, 3.615, 9.981, 9.198, 5.292, 1.224},
{0.432, 8.645, 8.774, 0.249, 8.081, 7.461, 4.416, 0.652, 4.002, 4.644},
{0.679, 2.800, 5.523, 3.049, 2.968, 7.225, 6.730, 4.199, 9.614, 9.229},
{4.263, 1.074, 7.286, 5.599, 8.291, 5.200, 9.214, 8.272, 4.398, 4.506},
{9.496, 4.830, 3.150, 8.270, 5.079, 1.231, 5.731, 9.494, 1.883, 9.732},
{ 4.138, 2.562, 2.532, 9.661, 5.611, 5.500, 6.886, 2.341, 9.699, 6.500}
};
double cfox10[] = {
0.806,0.517,1.5,0.908,0.965,
0.669,0.524,0.902,0.531,0.876,
0.462,0.491,0.463,0.714,0.352,
0.869,0.813,0.811,0.828,0.964,
0.789,0.360,0.369,0.992,0.332,
0.817,0.632,0.883,0.608,0.326};
double mvfLangerman(int n, double *x)
{
int i;
double Sum, dist;
cfox10[2] = 1.5;
Sum = 0;
for ( i = 0; i < 5; i++ ){
dist = dist2(n, x, afox10[i]);
Sum -= cfox10[i] * (exp(-dist) / M_PI) * cos(M_PI * dist);
}
return Sum;
}
double mvfLennardJones(int n, double *x)
{
int i,j, i3, j3;
double z, dz, dzp, E;
int natoms;
natoms = n / 3;
for (i = 0; i < natoms; i++) {
i3 = i * 3;
for (j = i + 1; j < natoms; j++) {
dz = 0.0;
z
= x[i3] - x[j3=j*3];
dz += z*z;
z
= x[i3+1] - x[j3+1];
dz += z*z;
z
= x[i3+2] - x[j3+2];
34
dz
+= z*z;
36
int i;
double sum, t;
sum = 0.0;
for (i = 0; i < n; i++) {
t = x[i];
t = t*t;
sum += t*t + rndUniform(0.0, 1.0);
}
return sum;
}
double mvfQuarticNoiseZ(int n, double *x)
/*
-Test optimization function. Range is | x_i | < 1.28
-Global minimum is 0.0 at x_i = 0.00
*/
{
int i;
double sum, t;
sum = 0.0;
for (i = 0; i < n; i++) {
t = x[i];
t = t*t;
sum += (i*t*t + rndZ());
}
return sum;
}
{
x[i] + 1.0));
x[i] + 1.0));
cos(t2) * sin(t1) + cos(t1) * sin(t2) * x[i];
{
int
i;
double sum, t;
if (n > 20) {
n = 20;
}
sum = 0.0;
for (i = 0; i < n; i++) {
t
= x[i];
sum += t*t - cos(2.0 * M_PI * x[i]);
}
return sum + n*10;
}
double mvfRastrigin2(int n, double *x)
/*
n = 2 always
Domain = | x_i | < 5.12
Global minimum is 0.0 at x_i = 0.00
*/
{
double t;
t = x[0];
return 2.0 + t*t - cos(18 * t) - cos(18 * x[1]);
}
double mvfRosenbrock(int n, double * x)
{
double a = x[1]-x[0]*x[0] ;
double b = 1.0-x[0] ;
return 100.0*a*a + b*b ;
}
}
double mvfSchwefel1_2(int n, double *x)
/*
-n = 100 for testing
-Domain: | x_i | < 10.00
-Global minimum is 0.0 at x_i = 0.00
*/
{
int i, j;
double sum, sum1;
sum = 0.0;
for (i = 0; i < n; i++) {
sum1 = 0.0;
for (j = 0; j < i; j++) {
sum1 += x[i];
}
sum += sum1 * sum1;
}
return sum;
}
double mvfSchwefel2_21(int n, double *x)
/*
-n = 100 for testing
- Domain: | x_i | < 10.000
-Global minimum is 0.0 at x_i = 0.00
*/
{
int
i;
double s,t;
s = fabs(x[0]);
for (i = 1; i < n; i++) {
t = fabs(x[i]);
if (t > s) {
s = t;
}
}
return s;
}
double mvfSchwefel2_22(int n, double *x)
/*
-n = 30 for testing
-Domain: | x_i | < 10.00
-Global minimum is 0.0 at x_i = 0.00
*/
{
int i;
42
= 0; i < n; i++) {
+= fabs(x[i]);
*= fabs(x[i]);
sum + prod;
}
double mvfSchwefel2_26(int n, double *x)
/*
Domain is | x_i | < 500
Global minimum at fmin = -122569.5 at
*/
{
int
i;
double sum;
x_i = 420.9687
sum = 0.0;
for (i = 0; i < n; i++) {
sum += x[i] * sin(sqrt(x[i]));
}
return - sum;
}
double mvfShekel2(int n, double *x)
/*
n = 2 always
Domain:
| x_i | <= 65.536
Minimum 1 at x = (-32, -32)
*/
{
int
j;
double s, t0, t1;
static double a[2][25] = {
{-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}
};
s = 0.0;
for (j = 0; j < 25; j++) {
t0 = x[0] - a[0][j];
t1 = x[1] - a[1][j];
t0 = (t0 * t0 * t0);
t0 *= t0 * t0;
t1 = (t1 * t1 * t1);
t1 = t1 * t1;
s += 1.0/ ((double) j + t0 + t1);
}
return 1.0 / (1.0/500.0 + s);
43
}
static double afox4[10][4]={ { 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} };
static double cfox4[10]= {.1,.2,.2,.4,.4,.6,.3,.7,.5,.5 };
double mvfShekelSub4(int m, double *x)
{
double R=0.0, S;
int i,j;
for(i=0;i<m;i++) {
S=0;
for (j=0;j<4;j++) S+=pow(x[j]-afox4[i][j],2);
R-=1/(S+cfox4[i]);
}
return R;
}
double mvfShekel4_5(int n, double * x)
/*
Domain
0 <= x_j <= 10
Global minimum fmin = -10.1532,
at X = (4.00004, 4.00013, 4.00004, 4.00013)
Number of local optimizers = 5
*/
{
return mvfShekelSub4(5, x);
}
double mvfShekel4_7(int n, double * x)
/*
Domain
0 <= x_j <= 10
-Global minimum fmin = -10/4029 at
(4.00057,4.00069,3.99949,3.99961) \
Number of local minimum = 7
*/
{
return mvfShekelSub4(7, x);
}
double mvfShekel4_10(int n, double * x)
/*
Domain
0 <= x_j <= 10
Global minimum fmin = -10.5364 at
44
*/
{
(4.00075,4.00059,3.99966,3.99951)
Number of local minimum = 10
45
}
return s1;
}
47
48
s += x[0] * x[0];
for (i = 0; i < 30; i++) {
a = i / 29.0;
s1 = 0.0;
s2 = 0.0;
for (j = 0; j < 5; j++) {
s1 += (j+1)* pow(a, j) * x[j+1];
}
for (j = 0; j < 6; j ++) {
s2 += pow(a, j) * x[j];
}
t = (s1 - s2 * s2 - 1);
s += t * t;
};
return s;
}
_Zp(_Zh2(x)) * sgn(_Zh2(x)),
_Zp(_Zh3(x)) * sgn(_Zh3(x)),
_Zp(-x[0]) * sgn(x[0]),
_Zp(-x[1]) * sgn(x[1])
};
return dmax(5, px);
}
50
The MVF library requires some statistical functions which are found in
the file rnd.c. The routines uses the Mersenne Twister random number
generator developed in reference [MN]. For the latest versions, consult the
web site
http://www.math.keio.ac.jp/ matumoto/emt.html
rndSeed(seed)
Seeds the random number generator.
rnd()
Returns a uniform random number in [0, 1].
rnd0(N)
Returns a random integer in [0, N 1].
rndInt(a, b)
Returns a random integer in [a, b].
rndUniform(a, b)
Returns a uniform random number in the interval [a, b].
rndZ()
Returns a standardized normal random variate with mean 0 and variance 1.
rndNormal(mu, std)
Returns a normal random variate with given mu and standard deviation std.
B.1
#ifndef _RND_H
#define _RND_H
void
double
int
int
double
double
double
#endif
51
B.2
/*
File
rnd.c
Remarks.
This file needs updating with the latest versions of
the Mersenne Twister.
*/
#include
#include
#include
#include
<math.h>
<signal.h>
<string.h>
<time.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "rnd.h"
/* ********** Start of Mersenne Twister **********************
This section contains code for the Mersenne Twister
random number generator. Please refer to the web site
http://www.math.keio.ac.jp/~matumoto/emt.html
for the latest versions and more information. The authors of
Mersenne Twister have permitted the use of MT for commercial
purposes.
http://www.math.keio.ac.jp/~matumoto/eartistic.html
*/
/* Period parameters */
#define _N 624
#define _M 397
#define MATRIX_A 0x9908b0df
/* constant vector a */
#define UPPER_MASK 0x80000000 /* most significant w-r bits */
#define LOWER_MASK 0x7fffffff /* least significant r bits */
/* Tempering parameters */
#define TEMPERING_MASK_B 0x9d2c5680
#define TEMPERING_MASK_C 0xefc60000
#define TEMPERING_SHIFT_U(y) (y >>
#define TEMPERING_SHIFT_S(y) (y <<
#define TEMPERING_SHIFT_T(y) (y <<
#define TEMPERING_SHIFT_L(y) (y >>
11)
7)
15)
18)
static unsigned long mt[_N]; /* the array for the state vector */
static int mti=_N+1; /* mti==N+1 means mt[N] is not initialized */
52
int rnd0(int N)
/* returns a random integer from 0 to N-1 */
{
return (int) (rnd() * N);
}
int rndInt(int a, int b)
{
return (int) (rnd() * (b - a + 1)) + a;
}
double rndUniform(double a, double b)
{
return a + rnd() * (b - a);
}
double rndZ(void)
{
/* Unoptimized version */
return sqrt(-2.0*log(rnd())) * sin(2*M_PI*rnd());
}
double rndNormal(double mu, double std)
{
return rndZ() * std + mu;
}
54
56