Add (back) "POwELL" standard test function for optimizers.

This commit is contained in:
Gilles Sadowski 2021-08-26 23:56:42 +02:00
parent f58da4abf5
commit ca826ba76b
4 changed files with 49 additions and 8 deletions

View File

@ -154,16 +154,23 @@ public enum TestFunction {
return 1 - Math.cos(2 * Math.PI * sqrtSum) + 0.1 * sqrtSum; return 1 - Math.cos(2 * Math.PI * sqrtSum) + 0.1 * sqrtSum;
}; };
}), }),
// https://scholarship.rice.edu/handle/1911/16304
ROSENBROCK(dim -> { ROSENBROCK(dim -> {
final int last = dim - 1; if (dim % 2 != 0) {
throw new IllegalArgumentException("Must be a multiple of 2 (was: " + dim + ")");
}
final int last = dim / 2;
return x -> { return x -> {
double f = 0; double f = 0;
for (int i = 0; i < last; i++) { for (int i = 1; i <= last; i++) {
final double xi = x[i]; final int twoI = 2 * i;
final double xiP1 = x[i + 1]; final int i0 = twoI - 1;
final double a = xiP1 - xi * xi; final int i1 = twoI;
final double b = xi - 1; final double x2iM1 = x[i0 - 1];
f += 1e2 * a * a + b * b; final double x2i = x[i1 - 1];
final double t2iM1 = x2i - x2iM1 * x2iM1;
final double t2i = 1 - x2iM1;
f += 100 * t2iM1 * t2iM1 + t2i * t2i;
} }
return f; return f;
}; };
@ -286,6 +293,35 @@ public enum TestFunction {
} }
return A * sum; return A * sum;
}; };
}),
// https://scholarship.rice.edu/handle/1911/16304
POWELL(dim -> {
if (dim % 4 != 0) {
throw new IllegalArgumentException("Must be a multiple of 4 (was: " + dim + ")");
}
final int last = dim / 4;
return x -> {
double sum = 0;
for (int i = 1; i <= last; i++) {
final int fourI = 4 * i;
final int i0 = fourI - 3;
final int i1 = fourI - 2;
final int i2 = fourI - 1;
final int i3 = fourI;
final double x4iM3 = x[i0 - 1];
final double x4iM2 = x[i1 - 1];
final double x4iM1 = x[i2 - 1];
final double x4i = x[i3 - 1];
final double t4iM3 = x4iM3 + 10 * x4iM2;
final double t4iM2 = x4iM1 - x4i;
final double t4iM1 = x4iM2 - 2 * x4iM1;
final double sqT4iM1 = t4iM1 * t4iM1;
final double t4i = x4iM3 - x4i;
final double sqT4i = t4i * t4i;
sum += t4iM3 * t4iM3 + 5 * t4iM2 * t4iM2 + sqT4iM1 * sqT4iM1 + 10 * sqT4i * sqT4i;
}
return sum;
};
}); });
/** Template for variable dimension. */ /** Template for variable dimension. */

View File

@ -32,10 +32,11 @@
# #
PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 900, true PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 900, true
ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 160, true ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 160, true
POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 400, true
CIGAR, 2, 0 0, 2, 3, 5e-5, 140, true CIGAR, 2, 0 0, 2, 3, 5e-5, 140, true
SPHERE, 2, 0 0, 2, 3, 5e-4, 110, true SPHERE, 2, 0 0, 2, 3, 5e-4, 110, true
ELLI, 2, 0 0, 3, 4, 1e-4, 150, true ELLI, 2, 0 0, 3, 4, 1e-4, 150, true
TWO_AXES, 2, 0 0, 3, 4, 1e-4, 160, true TWO_AXES, 2, 0 0, 3, 4, 1e-4, 170, true
CIG_TAB, 2, 0 0, 3, 4, 1e-3, 150, true CIG_TAB, 2, 0 0, 3, 4, 1e-3, 150, true
TABLET, 2, 0 0, 3, 4, 2e-4, 160, true TABLET, 2, 0 0, 3, 4, 2e-4, 160, true
SUM_POW, 2, 0 0, 3, 4, 1e-2, 110, true SUM_POW, 2, 0 0, 3, 4, 1e-2, 110, true

Can't render this file because it contains an unexpected character in line 6 and column 8.

View File

@ -33,6 +33,8 @@
PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 1500, false PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 1500, false
PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 2500, true PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 2500, true
ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 650, true ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 650, true
POWELL, 4, 0 0 0 0, 4, 5, 5e-2, 11800, false
POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 2000, true
CIGAR, 2, 0 0, 2, 3, 5e-5, 240, false CIGAR, 2, 0 0, 2, 3, 5e-5, 240, false
SPHERE, 2, 0 0, 2, 3, 5e-4, 200, false SPHERE, 2, 0 0, 2, 3, 5e-4, 200, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false ELLI, 2, 0 0, 3, 4, 1e-4, 350, false

Can't render this file because it contains an unexpected character in line 6 and column 8.

View File

@ -34,6 +34,8 @@ PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 700, false
PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 6000, true PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 6000, true
ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 110, false ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 110, false
ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 140, true ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 140, true
POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 290, false
POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 380, true
CIGAR, 2, 0 0, 2, 3, 5e-5, 100, false CIGAR, 2, 0 0, 2, 3, 5e-5, 100, false
SPHERE, 2, 0 0, 2, 3, 5e-4, 80, false SPHERE, 2, 0 0, 2, 3, 5e-4, 80, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false ELLI, 2, 0 0, 3, 4, 1e-4, 350, false

Can't render this file because it contains an unexpected character in line 6 and column 8.