You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2021/08/27 15:31:30 UTC
[commons-math] branch master updated (f58da4a -> cc5ae51)
This is an automated email from the ASF dual-hosted git repository.
erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git.
from f58da4a Use default SA setup in "SimplexOptimizerTest" (unit test).
new ca826ba Add (back) "POwELL" standard test function for optimizers.
new f1ad9d1 Simplex search in higher-dimensional cases (unit test).
new cc5ae51 Favouring the "expanded" simplex over the "reflected" one.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../scalar/noderiv/MultiDirectionalTransform.java | 2 +-
.../optim/nonlinear/scalar/TestFunction.java | 50 ++++++++++++++++++---
.../scalar/noderiv/SimplexOptimizerTest.java | 2 +-
.../std_test_func.simplex.hedar_fukushima.csv | 14 ++++--
.../std_test_func.simplex.multidirectional.csv | 51 ++++++++++++++--------
.../noderiv/std_test_func.simplex.nelder_mead.csv | 14 +++---
6 files changed, 93 insertions(+), 40 deletions(-)
[commons-math] 02/03: Simplex search in higher-dimensional cases
(unit test).
Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit f1ad9d1b000e1535550aef452c07a92de602c573
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Fri Aug 27 05:37:49 2021 +0200
Simplex search in higher-dimensional cases (unit test).
---
.../nonlinear/scalar/noderiv/SimplexOptimizerTest.java | 2 +-
.../noderiv/std_test_func.simplex.hedar_fukushima.csv | 11 ++++++++---
.../noderiv/std_test_func.simplex.multidirectional.csv | 13 ++++++++++++-
.../scalar/noderiv/std_test_func.simplex.nelder_mead.csv | 16 ++++++----------
4 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerTest.java
index 33d6190..38d0f13 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerTest.java
@@ -112,7 +112,7 @@ public class SimplexOptimizerTest {
*/
public static class Task {
/** Function evaluations hard count (debugging). */
- private static final int FUNC_EVAL_DEBUG = 80000;
+ private static final int FUNC_EVAL_DEBUG = 500000;
/** Default convergence criterion. */
private static final double CONVERGENCE_CHECK = 1e-9;
/** Default cooling factor. */
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
index 2030e0c..bebc135 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
@@ -31,18 +31,23 @@
# Caveat: Some tests are commented out (cf. JIRA: MATH-1552).
#
PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 900, true
+PARABOLA, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 5e-4, 5200, true
ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 160, true
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 1e-4, 500, true
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 2e-4, 2200, true
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-1, 9000, true
POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 400, true
-CIGAR, 2, 0 0, 2, 3, 5e-5, 140, true
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 2e-2, 1760, true
+CIGAR, 2, 0 0, 2, 3, 5e-5, 150, true
SPHERE, 2, 0 0, 2, 3, 5e-4, 110, true
ELLI, 2, 0 0, 3, 4, 1e-4, 150, 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, 2e-3, 160, true
TABLET, 2, 0 0, 3, 4, 2e-4, 160, true
SUM_POW, 2, 0 0, 3, 4, 1e-2, 110, true
ACKLEY, 2, 0 0, 2, 4, 1e-6, 170, true
RASTRIGIN, 2, 0 0, 6, 10, 5e-5, 130, true
-GRIEWANK, 2, 0 0, 2, 3, 1e-1, 100, true
+GRIEWANK, 2, 0 0, 2, 3, 1e-1, 120, true
LEVY, 2, 1 1, 0.9, 1.1, 1e-3, 110, true
SCHWEFEL, 2, 420.9687 420.9687, 9, 11, 1, 110, true
ZAKHAROV, 2, 0 0, 3, 4, 1e-4, 130, true
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
index 806e083..acc5e2f 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
@@ -32,9 +32,20 @@
#
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, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 5800, false
+PARABOLA, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 10260, true
+ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 11000, false
ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 650, true
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 45000, false
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 1850, true
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 4e-3, 130000, false
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-3, 8000, true
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 2e-1, 430000, false
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-1, 29000, 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
+POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 2200, true
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 7e-2, 37000, false
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 4e-2, 8500, true
CIGAR, 2, 0 0, 2, 3, 5e-5, 240, false
SPHERE, 2, 0 0, 2, 3, 5e-4, 200, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
index b70eb6b..15dcfcc 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
@@ -31,29 +31,25 @@
# Caveat: Some tests are commented out (cf. JIRA: MATH-1552).
#
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, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 5e-4, 3600, 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
-POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 290, false
-POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 380, true
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 1e-4, 400, false
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-4, 2200, false
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 5e-1, 7500, false
+POWELL, 4, 0 0 0 0, 4, 5, 5e-3, 290, false
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 3e-2, 1300, false
CIGAR, 2, 0 0, 2, 3, 5e-5, 100, false
SPHERE, 2, 0 0, 2, 3, 5e-4, 80, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false
TWO_AXES, 2, 0 0, 3, 4, 1e-4, 120, false
CIG_TAB, 2, 0 0, 3, 4, 1e-3, 100, false
-CIG_TAB, 2, 0 0, 3, 4, 1e-3, 115, true
TABLET, 2, 0 0, 3, 4, 2e-4, 100, false
SUM_POW, 2, 0 0, 3, 4, 1e-2, 75, false
ACKLEY, 2, 0 0, 2, 4, 1e-6, 145, false
-ACKLEY, 2, 0 0, 2, 4, 1e-6, 160, true
RASTRIGIN, 2, 0 0, 6, 10, 5e-5, 105, false
-RASTRIGIN, 2, 0 0, 6, 10, 5e-5, 140, true
GRIEWANK, 2, 0 0, 2, 3, 1e-1, 75, false
-GRIEWANK, 2, 0 0, 2, 3, 1e-1, 90, true
LEVY, 2, 1 1, 0.9, 1.1, 1e-3, 75, false
-LEVY, 2, 1 1, 0.9, 1.1, 1e-3, 80, true
SCHWEFEL, 2, 420.9687 420.9687, 9, 11, 1, 85, false
-SCHWEFEL, 2, 420.9687 420.9687, 9, 11, 1, 90, true
ZAKHAROV, 2, 0 0, 3, 4, 1e-4, 85, false
PERM, 2, 1 2, 0.9, 1.1, 2e-3, 110, false
STYBLINSKI_TANG, 2, -2.903534 -2.903534, 1, 2, 1e-4, 85, false
[commons-math] 03/03: Favouring the "expanded" simplex over the
"reflected" one.
Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit cc5ae51f98d82863ff6ae37fc393297bb7f1daa3
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Fri Aug 27 17:24:51 2021 +0200
Favouring the "expanded" simplex over the "reflected" one.
This modification decreases the number of function evaluations in several
test cases. Note however that the original description of the algorithm
uses the strict inequality...
---
.../scalar/noderiv/MultiDirectionalTransform.java | 2 +-
.../std_test_func.simplex.multidirectional.csv | 62 +++++++++++-----------
2 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/MultiDirectionalTransform.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/MultiDirectionalTransform.java
index bdd53e0..778ff3c 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/MultiDirectionalTransform.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/MultiDirectionalTransform.java
@@ -90,7 +90,7 @@ public class MultiDirectionalTransform
evaluationFunction);
final PointValuePair expandedBest = expandedSimplex.get(0);
- if (comparator.compare(expandedBest, reflectedBest) < 0 ||
+ if (comparator.compare(expandedBest, reflectedBest) <= 0 ||
(sa != null &&
sa.test(expandedBest.getValue() - reflectedBest.getValue()))) {
return expandedSimplex;
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
index acc5e2f..1e8f88e 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
@@ -31,36 +31,36 @@
# Caveat: Some tests are commented out (cf. JIRA: MATH-1552).
#
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, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 5800, false
-PARABOLA, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 10260, true
+PARABOLA, 8, 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 2600, true
+PARABOLA, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 5500, false
+PARABOLA, 16, 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0, 20, 40, 1e-4, 10000, true
ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 11000, false
-ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 650, true
-ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 45000, false
-ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 1850, true
-ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 4e-3, 130000, false
-ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-3, 8000, true
-ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 2e-1, 430000, false
-ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-1, 29000, true
-POWELL, 4, 0 0 0 0, 4, 5, 5e-2, 11800, false
-POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 2200, true
-POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 7e-2, 37000, false
-POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 4e-2, 8500, true
-CIGAR, 2, 0 0, 2, 3, 5e-5, 240, false
-SPHERE, 2, 0 0, 2, 3, 5e-4, 200, false
-ELLI, 2, 0 0, 3, 4, 1e-4, 350, false
-TWO_AXES, 2, 0 0, 3, 4, 1e-4, 400, false
-CIG_TAB, 2, 0 0, 3, 4, 1e-3, 280, false
-TABLET, 2, 0 0, 3, 4, 2e-4, 340, false
-SUM_POW, 2, 0 0, 3, 4, 1e-2, 190, false
-ACKLEY, 2, 0 0, 2, 4, 1e-6, 310, false
-RASTRIGIN, 2, 0 0, 6, 10, 1e-3, 650, false
-GRIEWANK, 2, 0 0, 2, 3, 1e-1, 500, false
-LEVY, 2, 1 1, 0.9, 1.1, 1e-3, 200, false
-SCHWEFEL, 2, 420.9687 420.9687, 9, 11, 1, 200, false
-ZAKHAROV, 2, 0 0, 3, 4, 1e-4, 1000, false
+ROSENBROCK, 2, 1 1, 0.9, 1.1, 3e-3, 500, true
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 31000, false
+ROSENBROCK, 4, 1 1 1 1, 0.9, 1.1, 3e-3, 1900, true
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 4e-3, 115000, false
+ROSENBROCK, 8, 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-3, 8100, true
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 2e-1, 420000, false
+ROSENBROCK, 16, 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, 0.9, 1.1, 3e-1, 30000, true
+POWELL, 4, 0 0 0 0, 4, 5, 5e-2, 11700, false, target/debug__, 0 1 LAST 0
+POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 1900, true
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 7e-2, 46000, false
+POWELL, 8, 0 0 0 0 0 0 0 0, 4, 5, 4e-2, 9000, true
+CIGAR, 2, 0 0, 2, 3, 5e-5, 160, false
+SPHERE, 2, 0 0, 2, 3, 5e-4, 120, false
+ELLI, 2, 0 0, 3, 4, 1e-4, 150, false
+TWO_AXES, 2, 0 0, 3, 4, 1e-4, 180, false
+CIG_TAB, 2, 0 0, 3, 4, 1e-3, 170, false
+TABLET, 2, 0 0, 3, 4, 2e-4, 150, false
+SUM_POW, 2, 0 0, 3, 4, 1e-2, 120, false
+ACKLEY, 2, 0 0, 2, 4, 1e-6, 220, false
+RASTRIGIN, 2, 0 0, 6, 10, 1e-3, 160, false
+GRIEWANK, 2, 0 0, 2, 3, 1e-1, 110, false
+LEVY, 2, 1 1, 0.9, 1.1, 1e-3, 120, false
+SCHWEFEL, 2, 420.9687 420.9687, 9, 11, 1, 120, false
+ZAKHAROV, 2, 0 0, 3, 4, 1e-4, 130, false
PERM, 2, 1 2, 0.9, 1.1, 2e-3, 24000, false
-PERM, 2, 1 2, 0.9, 1.1, 2e-3, 650, true
-STYBLINSKI_TANG, 2, -2.903534 -2.903534, 1, 2, 1e-4, 210, false
-#HAPPY_CAT, 2, -1 -1, 2, 3, 1e-4, 500, false
-#SALOMON, 2, 0 0, 2, 3, 1e-4, 500, false
+PERM, 2, 1 2, 0.9, 1.1, 2e-3, 400, true
+STYBLINSKI_TANG, 2, -2.903534 -2.903534, 1, 2, 1e-4, 120, false
+#HAPPY_CAT, 2, -1 -1, 2, 3, 1e-4, 50, false
+#SALOMON, 2, 0 0, 2, 3, 1e-4, 50, false
[commons-math] 01/03: Add (back) "POwELL" standard test function
for optimizers.
Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit ca826ba76bccec6d8cade6a0a660230b180b4555
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Thu Aug 26 23:56:42 2021 +0200
Add (back) "POwELL" standard test function for optimizers.
---
.../optim/nonlinear/scalar/TestFunction.java | 50 +++++++++++++++++++---
.../std_test_func.simplex.hedar_fukushima.csv | 3 +-
.../std_test_func.simplex.multidirectional.csv | 2 +
.../noderiv/std_test_func.simplex.nelder_mead.csv | 2 +
4 files changed, 49 insertions(+), 8 deletions(-)
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 f28bf11..a82d47a 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
@@ -154,16 +154,23 @@ public enum TestFunction {
return 1 - Math.cos(2 * Math.PI * sqrtSum) + 0.1 * sqrtSum;
};
}),
+ // https://scholarship.rice.edu/handle/1911/16304
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 -> {
double f = 0;
- for (int i = 0; i < last; i++) {
- final double xi = x[i];
- final double xiP1 = x[i + 1];
- final double a = xiP1 - xi * xi;
- final double b = xi - 1;
- f += 1e2 * a * a + b * b;
+ for (int i = 1; i <= last; i++) {
+ final int twoI = 2 * i;
+ final int i0 = twoI - 1;
+ final int i1 = twoI;
+ final double x2iM1 = x[i0 - 1];
+ 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;
};
@@ -286,6 +293,35 @@ public enum TestFunction {
}
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. */
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
index d6c0d66..2030e0c 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.hedar_fukushima.csv
@@ -32,10 +32,11 @@
#
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
+POWELL, 4, 0 0 0 0, 4, 5, 4e-3, 400, true
CIGAR, 2, 0 0, 2, 3, 5e-5, 140, true
SPHERE, 2, 0 0, 2, 3, 5e-4, 110, 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
TABLET, 2, 0 0, 3, 4, 2e-4, 160, true
SUM_POW, 2, 0 0, 3, 4, 1e-2, 110, true
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
index bff4421..806e083 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.multidirectional.csv
@@ -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, 2500, 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
SPHERE, 2, 0 0, 2, 3, 5e-4, 200, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false
diff --git a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
index 5ee1cae..b70eb6b 100644
--- a/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
+++ b/commons-math-legacy/src/test/resources/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/std_test_func.simplex.nelder_mead.csv
@@ -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
ROSENBROCK, 2, 1 1, 0.9, 1.1, 1e-4, 110, false
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
SPHERE, 2, 0 0, 2, 3, 5e-4, 80, false
ELLI, 2, 0 0, 3, 4, 1e-4, 350, false