-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcollection.cpp
More file actions
142 lines (129 loc) · 3.46 KB
/
testcollection.cpp
File metadata and controls
142 lines (129 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <vector>
#include <random>
#include <utils.h>
#include <testcollection.h>
real F00_simpleSum::operator()(const real *x)
{
std::vector<real> v(x, x + this->getDimension());
return sum(v);
}
InterceptedSet FI00_simpleSum::intercept(const real *x)
{
std::vector<real> v(x, x + this->getDimension());
InterceptedSet res {sum(v), v};
return res;
}
InterceptedSet FI01_MorCaf1::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (const auto x : v) f *= (1 + 1.0 / d) * std::pow(x, 1.0 / d);
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI02_NormalDensity::intercept(const real *x)
{
real mean = 0.5;
real mult = 0.3829249;
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (const auto x : v) f *= dnorm(x - mean) / mult;
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI03_PieceLin::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real value = 0.0;
real total = 0.0;
for (int j = 0; j < d; j++)
{
if (v[j] <= 0.5 - double(j) / 2 / (j + 10)) {total = 0.0;}
else if (v[j] >= 0.5 + double(j) / 2 / (j + 10)) {total = 1.0;}
else {total = v[j] * (10 + (double)j) / j - 5.0 / j;}
value += total * 2;
}
InterceptedSet res {value, v};
return res;
}
InterceptedSet FI04_PieceLinEx::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real value = 0.0;
real total = 1.0;
for (int j = 0; j < d; j++)
{
if (v[j] <= 0.5 - double(j) / 2 / (j + 10)) {total = 0.0;}
else if (v[j] >= 0.5 + double(j) / 2 / (j + 10)) {total = 1.0;}
else {total = v[j] * (10 + (double)j) / j - 5.0 / j;}
value *= total * 2;
}
InterceptedSet res {value, v};
return res;
}
InterceptedSet FI05_CubicPolynomial::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (const auto x : v) f *= (x * x * x + 0.75);
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI06_Oscillatory::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (int j = 0; j < d; j++)
{
f *= (j + 1) * (cos((j + 1) * v[j]) / sin(j + 1));
}
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI07_Singular::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (int j = 0; j < d; j++)
{
f *= 1.0 / (j + 1) * (pow(v[j], 1.0 / (j + 1) - 1));
}
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI08_InfVariation::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real rad = pow(tgamma((double) d / 2 + 1) / (2 * pow(M_PI, (double) d / 2)), 1.0 / d);
real r = 0;
for (int j = 0; j < d; j++)
{
r += (v[j] - 0.5) * (v[j] - 0.5);
}
r = sqrt(r);
real f = 0;
if (r <= rad) f = 2; else f = 0;
InterceptedSet res {f, v};
return res;
}
InterceptedSet FI09_SingularFinVar::intercept(const real *x)
{
int d = this->getDimension();
std::vector<real> v(x, x + d);
real f = 1;
for (int j = 0; j < d; j++)
{
double t = (j + 2.0) / (2 * j);
f *= t * (pow(v[j], t - 1));
}
InterceptedSet res {f, v};
return res;
}