Web links to reference definitions of test functions.
Changed "TestFunction.DIFF_POW" to match the definition.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java
index 44ebc4f..798ada1 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java
@@ -24,6 +24,7 @@
* Multivariate scalar functions for testing an optimizer.
*/
public enum TestFunction {
+ // https://www.sfu.ca/~ssurjano/spheref.html
SPHERE(dim -> {
return x -> {
double f = 0;
@@ -87,12 +88,12 @@
return 1 - elli.value(x);
};
}),
+ // https://www.sfu.ca/~ssurjano/sumpow.html
DIFF_POW(dim -> {
- final double A = 10d / (dim - 1);
return x -> {
double f = 0;
for (int i = 0; i < dim; i++) {
- f += AccurateMath.pow(Math.abs(x[i]), A * i + 2);
+ f += AccurateMath.pow(Math.abs(x[i]), i + 2);
}
return f;
};
@@ -104,6 +105,7 @@
return f;
};
}),
+ // https://www.sfu.ca/~ssurjano/ackley.html
ACKLEY(dim -> {
final double A = 20;
final double B = 0.2;