commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1043078 [2/2] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/optimization/ main/java/org/apache/commons/math/optimization/direct/ main/java/org/apache/commons/math/optimization/fitting/ main/java/org/apache/commons/...
Date Tue, 07 Dec 2010 15:01:38 GMT
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
Tue Dec  7 15:01:37 2010
@@ -109,10 +109,9 @@ extends TestCase {
         LinearProblem problem =
             new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1 }, new double[]
{ 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[]
{ 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
         assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
@@ -125,10 +124,9 @@ extends TestCase {
                               new double[] { 4.0, 6.0, 1.0 });
 
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new
double[] { 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
@@ -148,10 +146,9 @@ extends TestCase {
                 { 0, 0, 0, 0, 0, 2 }
         }, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1,
1 },
                                new double[] { 0, 0, 0, 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         for (int i = 0; i < problem.target.length; ++i) {
@@ -167,10 +164,9 @@ extends TestCase {
                 {  0, -1, 1 }
         }, new double[] { 1, 1, 1});
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new
double[] { 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
@@ -190,10 +186,9 @@ extends TestCase {
         }, new double[] { 2, -9, 2, 2, 1 + epsilon * epsilon, 2});
 
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1,
1 },
                                new double[] { 0, 0, 0, 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals( 3.0, optimum.getPoint()[0], 1.0e-10);
@@ -213,10 +208,9 @@ extends TestCase {
                 { -3, 0, -9 }
         }, new double[] { 1, 1, 1 });
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         try {
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new
double[] { 0, 0, 0 });
             fail("an exception should have been caught");
         } catch (ConvergenceException ee) {
             // expected behavior
@@ -231,10 +225,9 @@ extends TestCase {
                 {  7.0, 5.0,  9.0, 10.0 }
         }, new double[] { 32, 23, 33, 31 });
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum1 =
-            optimizer.optimize(problem1, problem1.target, new double[] { 1, 1, 1, 1 },
+            optimizer.optimize(100, problem1, problem1.target, new double[] { 1, 1, 1, 1
},
                                new double[] { 0, 1, 2, 3 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.0, optimum1.getPoint()[0], 1.0e-10);
@@ -249,7 +242,7 @@ extends TestCase {
                 {  6.99, 4.99, 9.00, 9.98 }
         }, new double[] { 32, 23, 33, 31 });
         VectorialPointValuePair optimum2 =
-            optimizer.optimize(problem2, problem2.target, new double[] { 1, 1, 1, 1 },
+            optimizer.optimize(100, problem2, problem2.target, new double[] { 1, 1, 1, 1
},
                                new double[] { 0, 1, 2, 3 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(-81.0, optimum2.getPoint()[0], 1.0e-8);
@@ -268,10 +261,9 @@ extends TestCase {
         }, new double[] { 7.0, 3.0, 5.0 });
 
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         try {
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
                                new double[] { 7, 6, 5, 4 });
             fail("an exception should have been caught");
         } catch (ConvergenceException ee) {
@@ -288,10 +280,9 @@ extends TestCase {
                  { 0.0, 0.0,  0.0, -1.0, 1.0,  0.0 }
         }, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         try {
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1
},
                                new double[] { 2, 2, 2, 2, 2, 2 });
             fail("an exception should have been caught");
         } catch (ConvergenceException ee) {
@@ -307,10 +298,9 @@ extends TestCase {
         }, new double[] { 3.0, 1.0, 5.0 });
 
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
                                new double[] { 1, 1 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(2.0, optimum.getPoint()[0], 1.0e-8);
@@ -326,9 +316,8 @@ extends TestCase {
         }, new double[] { 3.0, 1.0, 4.0 });
 
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
-        optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 1, 1 });
+        optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 1, 1 });
         assertTrue(optimizer.getRMS() > 0.1);
 
     }
@@ -337,17 +326,16 @@ extends TestCase {
         LinearProblem problem =
             new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } }, new double[] { -1, 1
});
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
 
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1 }, new double[]
{ 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1 }, new double[]
{ 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(-1, optimum.getPoint()[0], 1.0e-10);
         assertEquals(+1, optimum.getPoint()[1], 1.0e-10);
 
         try {
-            optimizer.optimize(problem, problem.target,
+            optimizer.optimize(100, problem, problem.target,
                                new double[] { 1 },
                                new double[] { 0, 0 });
             fail("an exception should have been thrown");
@@ -356,7 +344,7 @@ extends TestCase {
         }
 
         try {
-            optimizer.optimize(problem, new double[] { 1 },
+            optimizer.optimize(100, problem, new double[] { 1 },
                                new double[] { 1 },
                                new double[] { 0, 0 });
             fail("an exception should have been thrown");
@@ -374,10 +362,9 @@ extends TestCase {
         circle.addPoint( 35.0,  15.0);
         circle.addPoint( 45.0,  97.0);
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialPointChecker(1.0e-30, 1.0e-30));
         try {
-            optimizer.optimize(circle, new double[] { 0, 0, 0, 0, 0 },
+            optimizer.optimize(100, circle, new double[] { 0, 0, 0, 0, 0 },
                                new double[] { 1, 1, 1, 1, 1 },
                                new double[] { 98.680, 47.345 });
             fail("an exception should have been caught");
@@ -394,10 +381,9 @@ extends TestCase {
         circle.addPoint( 35.0,  15.0);
         circle.addPoint( 45.0,  97.0);
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-13, 1.0e-13));
         VectorialPointValuePair optimum =
-            optimizer.optimize(circle, new double[] { 0, 0, 0, 0, 0 },
+            optimizer.optimize(100, circle, new double[] { 0, 0, 0, 0, 0 },
                                new double[] { 1, 1, 1, 1, 1 },
                                new double[] { 98.680, 47.345 });
         assertEquals(1.768262623567235,  FastMath.sqrt(circle.getN()) * optimizer.getRMS(),
 1.0e-10);
@@ -448,17 +434,16 @@ extends TestCase {
             circle.addPoint(points[i][0], points[i][1]);
         }
         GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
         try {
-            optimizer.optimize(circle, target, weights, new double[] { -12, -12 });
+            optimizer.optimize(100, circle, target, weights, new double[] { -12, -12 });
             fail("an exception should have been caught");
         } catch (ConvergenceException ee) {
             // expected behavior
         }
 
         VectorialPointValuePair optimum =
-            optimizer.optimize(circle, target, weights, new double[] { 0, 0 });
+            optimizer.optimize(100, circle, target, weights, new double[] { 0, 0 });
         assertEquals(-0.1517383071957963, optimum.getPointRef()[0], 1.0e-6);
         assertEquals(0.2074999736353867,  optimum.getPointRef()[1], 1.0e-6);
         assertEquals(0.04268731682389561, optimizer.getRMS(),       1.0e-8);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
Tue Dec  7 15:01:37 2010
@@ -113,7 +113,7 @@ public class LevenbergMarquardtOptimizer
             new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1 }, new double[]
{ 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[]
{ 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         try {
             optimizer.guessParametersErrors();
@@ -133,7 +133,7 @@ public class LevenbergMarquardtOptimizer
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new
double[] { 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
@@ -153,7 +153,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1,
1 },
                                new double[] { 0, 0, 0, 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         for (int i = 0; i < problem.target.length; ++i) {
@@ -170,7 +170,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 1, 1, 1});
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new
double[] { 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
@@ -190,7 +190,7 @@ public class LevenbergMarquardtOptimizer
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1,
1 },
                                new double[] { 0, 0, 0, 0, 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals( 3.0, optimum.getPoint()[0], 1.0e-10);
@@ -210,7 +210,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 1, 1, 1 });
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
-        optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0, 0 });
+        optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 0, 0, 0 });
         assertTrue(FastMath.sqrt(problem.target.length) * optimizer.getRMS() > 0.6);
         try {
             optimizer.getCovariances();
@@ -229,7 +229,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 32, 23, 33, 31 });
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum1 =
-            optimizer.optimize(problem1, problem1.target, new double[] { 1, 1, 1, 1 },
+            optimizer.optimize(100, problem1, problem1.target, new double[] { 1, 1, 1, 1
},
                                new double[] { 0, 1, 2, 3 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.0, optimum1.getPoint()[0], 1.0e-10);
@@ -244,7 +244,7 @@ public class LevenbergMarquardtOptimizer
                 {  6.99, 4.99, 9.00, 9.98 }
         }, new double[] { 32, 23, 33, 31 });
         VectorialPointValuePair optimum2 =
-            optimizer.optimize(problem2, problem2.target, new double[] { 1, 1, 1, 1 },
+            optimizer.optimize(100, problem2, problem2.target, new double[] { 1, 1, 1, 1
},
                                new double[] { 0, 1, 2, 3 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(-81.0, optimum2.getPoint()[0], 1.0e-8);
@@ -262,7 +262,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 7.0, 3.0, 5.0 });
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
-        optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 },
+        optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
                 new double[] { 7, 6, 5, 4 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
     }
@@ -278,7 +278,7 @@ public class LevenbergMarquardtOptimizer
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1
},
                                new double[] { 2, 2, 2, 2, 2, 2 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(3.0, optimum.getPointRef()[2], 1.0e-10);
@@ -296,7 +296,7 @@ public class LevenbergMarquardtOptimizer
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 },
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
                                new double[] { 1, 1 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(2.0, optimum.getPointRef()[0], 1.0e-10);
@@ -311,7 +311,7 @@ public class LevenbergMarquardtOptimizer
         }, new double[] { 3.0, 1.0, 4.0 });
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
-        optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 1, 1 });
+        optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[]
{ 1, 1 });
         assertTrue(optimizer.getRMS() > 0.1);
     }
 
@@ -321,13 +321,13 @@ public class LevenbergMarquardtOptimizer
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
 
         VectorialPointValuePair optimum =
-            optimizer.optimize(problem, problem.target, new double[] { 1, 1 }, new double[]
{ 0, 0 });
+            optimizer.optimize(100, problem, problem.target, new double[] { 1, 1 }, new double[]
{ 0, 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(-1, optimum.getPoint()[0], 1.0e-10);
         assertEquals(+1, optimum.getPoint()[1], 1.0e-10);
 
         try {
-            optimizer.optimize(problem, problem.target,
+            optimizer.optimize(100, problem, problem.target,
                                new double[] { 1 },
                                new double[] { 0, 0 });
             fail("an exception should have been thrown");
@@ -336,7 +336,7 @@ public class LevenbergMarquardtOptimizer
         }
 
         try {
-            optimizer.optimize(problem, new double[] { 1 },
+            optimizer.optimize(100, problem, new double[] { 1 },
                                new double[] { 1 },
                                new double[] { 0, 0 });
             fail("an exception should have been thrown");
@@ -370,8 +370,8 @@ public class LevenbergMarquardtOptimizer
                                                   parRelativeTolerance,
                                                   orthoTolerance,
                                                   MathUtils.SAFE_MIN);
-            optimizer.setMaxEvaluations(maxCostEval);
-            optimizer.optimize(problem, new double[] { 0, 0, 0, 0, 0 }, new double[] { 1,
1, 1, 1, 1 },
+            optimizer.optimize(maxCostEval, problem, new double[] { 0, 0, 0, 0, 0 },
+                               new double[] { 1, 1, 1, 1, 1 },
                                new double[] { 98.680, 47.345 });
             assertTrue(!shouldFail);
         } catch (DimensionMismatchException ee) {
@@ -390,7 +390,7 @@ public class LevenbergMarquardtOptimizer
         circle.addPoint( 45.0,  97.0);
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
-            optimizer.optimize(circle, new double[] { 0, 0, 0, 0, 0 }, new double[] { 1,
1, 1, 1, 1 },
+            optimizer.optimize(100, circle, new double[] { 0, 0, 0, 0, 0 }, new double[]
{ 1, 1, 1, 1, 1 },
                                new double[] { 98.680, 47.345 });
         assertTrue(optimizer.getEvaluations() < 10);
         assertTrue(optimizer.getJacobianEvaluations() < 10);
@@ -418,7 +418,7 @@ public class LevenbergMarquardtOptimizer
         Arrays.fill(target, 0.0);
         double[] weights = new double[circle.getN()];
         Arrays.fill(weights, 2.0);
-        optimizer.optimize(circle, target, weights, new double[] { 98.680, 47.345 });
+        optimizer.optimize(100, circle, target, weights, new double[] { 98.680, 47.345 });
         cov = optimizer.getCovariances();
         assertEquals(0.0016, cov[0][0], 0.001);
         assertEquals(3.2e-7, cov[0][1], 1.0e-9);
@@ -472,7 +472,7 @@ public class LevenbergMarquardtOptimizer
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         optimizer.setConvergenceChecker(new SimpleVectorialValueChecker(1.0e-8, 1.0e-8));
         VectorialPointValuePair optimum =
-            optimizer.optimize(circle, target, weights, new double[] { -12, -12 });
+            optimizer.optimize(100, circle, target, weights, new double[] { -12, -12 });
         Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
         assertTrue(optimizer.getEvaluations() < 25);
         assertTrue(optimizer.getJacobianEvaluations() < 20);
@@ -492,7 +492,7 @@ public class LevenbergMarquardtOptimizer
             problem.addPoint (4, 1.7785661310051026);
             LevenbergMarquardtOptimizer optimizer
                 = new LevenbergMarquardtOptimizer(100, 1e-10, 1e-10, 1e-10, 0);
-            optimizer.optimize(problem,
+            optimizer.optimize(100, problem,
                                new double[] { 0, 0, 0, 0, 0 },
                                new double[] { 0.0, 4.4e-323, 1.0, 4.4e-323, 0.0 },
                                new double[] { 0, 0, 0 });

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java
Tue Dec  7 15:01:37 2010
@@ -493,11 +493,10 @@ public class MinpackTest extends TestCas
           = new LevenbergMarquardtOptimizer(FastMath.sqrt(2.22044604926e-16),
                                             FastMath.sqrt(2.22044604926e-16),
                                             2.22044604926e-16);
-      optimizer.setMaxEvaluations(400 * (function.getN() + 1));
 //      assertTrue(function.checkTheoreticalStartCost(optimizer.getRMS()));
       try {
           VectorialPointValuePair optimum =
-              optimizer.optimize(function,
+              optimizer.optimize(400 * (function.getN() + 1), function,
                                  function.getTarget(), function.getWeight(),
                                  function.getStartPoint());
           assertFalse(exceptionExpected);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java
Tue Dec  7 15:01:37 2010
@@ -101,10 +101,9 @@ public class NonLinearConjugateGradientO
             new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0 });
         Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
         Assert.assertEquals(0.0, optimum.getValue(), 1.0e-10);
     }
@@ -117,10 +116,9 @@ public class NonLinearConjugateGradientO
 
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0 });
         Assert.assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
         Assert.assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
         Assert.assertEquals(0.0, optimum.getValue(), 1.0e-10);
@@ -139,10 +137,9 @@ public class NonLinearConjugateGradientO
         }, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0, 0,
0 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0,
0, 0 });
         for (int i = 0; i < problem.target.length; ++i) {
             Assert.assertEquals(0.55 * i, optimum.getPoint()[i], 1.0e-10);
         }
@@ -157,10 +154,9 @@ public class NonLinearConjugateGradientO
         }, new double[] { 1, 1, 1});
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
         Assert.assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
         Assert.assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
         Assert.assertEquals(3.0, optimum.getPoint()[2], 1.0e-10);
@@ -181,7 +177,6 @@ public class NonLinearConjugateGradientO
 
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setPreconditioner(new Preconditioner() {
             public double[] precondition(double[] point, double[] r) {
                 double[] d = r.clone();
@@ -197,7 +192,7 @@ public class NonLinearConjugateGradientO
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-13, 1.0e-13));
 
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0, 0,
0 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0,
0, 0 });
         Assert.assertEquals( 3.0, optimum.getPoint()[0], 1.0e-10);
         Assert.assertEquals( 4.0, optimum.getPoint()[1], 1.0e-10);
         Assert.assertEquals(-1.0, optimum.getPoint()[2], 1.0e-10);
@@ -216,10 +211,9 @@ public class NonLinearConjugateGradientO
         }, new double[] { 1, 1, 1 });
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-                optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
+                optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0,
0 });
         Assert.assertTrue(optimum.getValue() > 0.5);
     }
 
@@ -233,12 +227,11 @@ public class NonLinearConjugateGradientO
         }, new double[] { 32, 23, 33, 31 });
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(200);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-13, 1.0e-13));
         BrentSolver solver = new BrentSolver(1e-15, 1e-15);
         optimizer.setLineSearchSolver(solver);
         RealPointValuePair optimum1 =
-            optimizer.optimize(problem1, GoalType.MINIMIZE, new double[] { 0, 1, 2, 3 });
+            optimizer.optimize(200, problem1, GoalType.MINIMIZE, new double[] { 0, 1, 2,
3 });
         Assert.assertEquals(1.0, optimum1.getPoint()[0], 1.0e-4);
         Assert.assertEquals(1.0, optimum1.getPoint()[1], 1.0e-4);
         Assert.assertEquals(1.0, optimum1.getPoint()[2], 1.0e-4);
@@ -251,7 +244,7 @@ public class NonLinearConjugateGradientO
                 {  6.99, 4.99, 9.00, 9.98 }
         }, new double[] { 32, 23, 33, 31 });
         RealPointValuePair optimum2 =
-            optimizer.optimize(problem2, GoalType.MINIMIZE, new double[] { 0, 1, 2, 3 });
+            optimizer.optimize(200, problem2, GoalType.MINIMIZE, new double[] { 0, 1, 2,
3 });
         Assert.assertEquals(-81.0, optimum2.getPoint()[0], 1.0e-1);
         Assert.assertEquals(137.0, optimum2.getPoint()[1], 1.0e-1);
         Assert.assertEquals(-34.0, optimum2.getPoint()[2], 1.0e-1);
@@ -269,10 +262,9 @@ public class NonLinearConjugateGradientO
 
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 7, 6, 5, 4 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 7, 6, 5, 4
});
         Assert.assertEquals(0, optimum.getValue(), 1.0e-10);
 
     }
@@ -288,10 +280,9 @@ public class NonLinearConjugateGradientO
         }, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2, 2,
2 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2,
2, 2 });
         Assert.assertEquals(0, optimum.getValue(), 1.0e-10);
     }
 
@@ -305,10 +296,9 @@ public class NonLinearConjugateGradientO
 
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 1, 1 });
         Assert.assertEquals(2.0, optimum.getPoint()[0], 1.0e-8);
         Assert.assertEquals(1.0, optimum.getPoint()[1], 1.0e-8);
 
@@ -324,10 +314,9 @@ public class NonLinearConjugateGradientO
 
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
         RealPointValuePair optimum =
-            optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
+            optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 1, 1 });
         Assert.assertTrue(optimum.getValue() > 0.1);
 
     }
@@ -342,12 +331,11 @@ public class NonLinearConjugateGradientO
         circle.addPoint( 45.0,  97.0);
         NonLinearConjugateGradientOptimizer optimizer =
             new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
-        optimizer.setMaxEvaluations(100);
         optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-30, 1.0e-30));
         UnivariateRealSolver solver = new BrentSolver(1e-15, 1e-13);
         optimizer.setLineSearchSolver(solver);
         RealPointValuePair optimum =
-            optimizer.optimize(circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345 });
+            optimizer.optimize(100, circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345
});
         Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
         Assert.assertEquals(69.960161753, circle.getRadius(center), 1.0e-8);
         Assert.assertEquals(96.075902096, center.x, 1.0e-8);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java
Tue Dec  7 15:01:37 2010
@@ -37,16 +37,14 @@ public final class BrentOptimizerTest {
     public void testSinMin() {
         UnivariateRealFunction f = new SinFunction();
         UnivariateRealOptimizer optimizer = new BrentOptimizer(1e-10, 1e-14);
-        optimizer.setMaxEvaluations(200);
-        assertEquals(200, optimizer.getMaxEvaluations());
-        assertEquals(3 * Math.PI / 2, optimizer.optimize(f, GoalType.MINIMIZE, 4, 5).getPoint(),1e-8);
+        assertEquals(3 * Math.PI / 2, optimizer.optimize(200, f, GoalType.MINIMIZE, 4, 5).getPoint(),1e-8);
         assertTrue(optimizer.getEvaluations() <= 50);
-        assertEquals(3 * Math.PI / 2, optimizer.optimize(f, GoalType.MINIMIZE, 1, 5).getPoint(),
1e-8);
+        assertEquals(200, optimizer.getMaxEvaluations());
+        assertEquals(3 * Math.PI / 2, optimizer.optimize(200, f, GoalType.MINIMIZE, 1, 5).getPoint(),
1e-8);
         assertTrue(optimizer.getEvaluations() <= 100);
         assertTrue(optimizer.getEvaluations() >= 15);
-        optimizer.setMaxEvaluations(10);
         try {
-            optimizer.optimize(f, GoalType.MINIMIZE, 4, 5);
+            optimizer.optimize(10, f, GoalType.MINIMIZE, 4, 5);
             fail("an exception should have been thrown");
         } catch (TooManyEvaluationsException fee) {
             // expected
@@ -58,13 +56,12 @@ public final class BrentOptimizerTest {
         // The function has local minima at -0.27195613 and 0.82221643.
         UnivariateRealFunction f = new QuinticFunction();
         UnivariateRealOptimizer optimizer = new BrentOptimizer(1e-10, 1e-14);
-        optimizer.setMaxEvaluations(200);
-        assertEquals(-0.27195613, optimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2).getPoint(),
1.0e-8);
-        assertEquals( 0.82221643, optimizer.optimize(f, GoalType.MINIMIZE,  0.3,  0.9).getPoint(),
1.0e-8);
+        assertEquals(-0.27195613, optimizer.optimize(200, f, GoalType.MINIMIZE, -0.3, -0.2).getPoint(),
1.0e-8);
+        assertEquals( 0.82221643, optimizer.optimize(200, f, GoalType.MINIMIZE,  0.3,  0.9).getPoint(),
1.0e-8);
         assertTrue(optimizer.getEvaluations() <= 50);
 
         // search in a large interval
-        assertEquals(-0.27195613, optimizer.optimize(f, GoalType.MINIMIZE, -1.0, 0.2).getPoint(),
1.0e-8);
+        assertEquals(-0.27195613, optimizer.optimize(200, f, GoalType.MINIMIZE, -1.0, 0.2).getPoint(),
1.0e-8);
         assertTrue(optimizer.getEvaluations() <= 50);
     }
 
@@ -73,7 +70,6 @@ public final class BrentOptimizerTest {
         // The function has local minima at -0.27195613 and 0.82221643.
         UnivariateRealFunction f = new QuinticFunction();
         UnivariateRealOptimizer optimizer = new BrentOptimizer(1e-11, 1e-14);
-        optimizer.setMaxEvaluations(40);
 
         final DescriptiveStatistics[] stat = new DescriptiveStatistics[2];
         for (int i = 0; i < stat.length; i++) {
@@ -86,7 +82,7 @@ public final class BrentOptimizerTest {
         final double delta = (max - min) / nSamples;
         for (int i = 0; i < nSamples; i++) {
             final double start = min + i * delta;
-            stat[0].addValue(optimizer.optimize(f, GoalType.MINIMIZE, min, max, start).getPoint());
+            stat[0].addValue(optimizer.optimize(40, f, GoalType.MINIMIZE, min, max, start).getPoint());
             stat[1].addValue(optimizer.getEvaluations());
         }
 
@@ -97,16 +93,15 @@ public final class BrentOptimizerTest {
         assertEquals(23, (int) medianEval);
     }
 
-    @Test(expected = TooManyEvaluationsException.class)
+    @Test
     public void testQuinticMax() {
         // The quintic function has zeros at 0, +-0.5 and +-1.
         // The function has a local maximum at 0.27195613.
         UnivariateRealFunction f = new QuinticFunction();
         UnivariateRealOptimizer optimizer = new BrentOptimizer(1e-12, 1e-14);
-        assertEquals(0.27195613, optimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3).getPoint(),
1e-8);
-        optimizer.setMaxEvaluations(5);
+        assertEquals(0.27195613, optimizer.optimize(100, f, GoalType.MAXIMIZE, 0.2, 0.3).getPoint(),
1e-8);
         try {
-            optimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3);
+            optimizer.optimize(5, f, GoalType.MAXIMIZE, 0.2, 0.3);
             fail("an exception should have been thrown");
         } catch (TooManyEvaluationsException miee) {
             // expected
@@ -114,16 +109,15 @@ public final class BrentOptimizerTest {
     }
 
     @Test
-    public void testMinEndpoints() throws Exception {
+    public void testMinEndpoints() {
         UnivariateRealFunction f = new SinFunction();
         UnivariateRealOptimizer optimizer = new BrentOptimizer(1e-8, 1e-14);
-        optimizer.setMaxEvaluations(50);
 
         // endpoint is minimum
-        double result = optimizer.optimize(f, GoalType.MINIMIZE, 3 * Math.PI / 2, 5).getPoint();
+        double result = optimizer.optimize(50, f, GoalType.MINIMIZE, 3 * Math.PI / 2, 5).getPoint();
         assertEquals(3 * Math.PI / 2, result, 1e-6);
 
-        result = optimizer.optimize(f, GoalType.MINIMIZE, 4, 3 * Math.PI / 2).getPoint();
+        result = optimizer.optimize(50, f, GoalType.MINIMIZE, 4, 3 * Math.PI / 2).getPoint();
         assertEquals(3 * Math.PI / 2, result, 1e-6);
     }
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizerTest.java?rev=1043078&r1=1043077&r2=1043078&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizerTest.java
Tue Dec  7 15:01:37 2010
@@ -36,12 +36,11 @@ public class MultiStartUnivariateRealOpt
     public void testSinMin() {
         UnivariateRealFunction f = new SinFunction();
         UnivariateRealOptimizer underlying = new BrentOptimizer(1e-10, 1e-14);
-        underlying.setMaxEvaluations(300);
         JDKRandomGenerator g = new JDKRandomGenerator();
         g.setSeed(44428400075l);
         MultiStartUnivariateRealOptimizer<UnivariateRealFunction> optimizer =
             new MultiStartUnivariateRealOptimizer<UnivariateRealFunction>(underlying,
10, g);
-        optimizer.optimize(f, GoalType.MINIMIZE, -100.0, 100.0);
+        optimizer.optimize(300, f, GoalType.MINIMIZE, -100.0, 100.0);
         UnivariateRealPointValuePair[] optima = optimizer.getOptima();
         for (int i = 1; i < optima.length; ++i) {
             double d = (optima[i].getPoint() - optima[i-1].getPoint()) / (2 * FastMath.PI);
@@ -59,14 +58,13 @@ public class MultiStartUnivariateRealOpt
         // The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
         UnivariateRealFunction f = new QuinticFunction();
         UnivariateRealOptimizer underlying = new BrentOptimizer(1e-9, 1e-14);
-        underlying.setMaxEvaluations(300);
         JDKRandomGenerator g = new JDKRandomGenerator();
         g.setSeed(4312000053L);
         MultiStartUnivariateRealOptimizer<UnivariateRealFunction> optimizer =
             new MultiStartUnivariateRealOptimizer<UnivariateRealFunction>(underlying,
5, g);
 
         UnivariateRealPointValuePair optimum
-            = optimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2);
+            = optimizer.optimize(300, f, GoalType.MINIMIZE, -0.3, -0.2);
         assertEquals(-0.2719561293, optimum.getPoint(), 1e-9);
         assertEquals(-0.0443342695, optimum.getValue(), 1e-9);
 
@@ -89,7 +87,6 @@ public class MultiStartUnivariateRealOpt
                 }
             };
         UnivariateRealOptimizer underlying = new BrentOptimizer(1e-9, 1e-14);
-        underlying.setMaxEvaluations(300);
         JDKRandomGenerator g = new JDKRandomGenerator();
         g.setSeed(4312000053L);
         MultiStartUnivariateRealOptimizer<UnivariateRealFunction> optimizer =
@@ -97,7 +94,7 @@ public class MultiStartUnivariateRealOpt
  
         try {
             UnivariateRealPointValuePair optimum
-                = optimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2);
+                = optimizer.optimize(300, f, GoalType.MINIMIZE, -0.3, -0.2);
             Assert.fail();
         } catch (MathUserException e) {
             // Expected.



Mime
View raw message