Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java Sat Nov 20 20:57:37 2010 @@ -24,12 +24,13 @@ import static org.junit.Assert.assertTru import static org.junit.Assert.fail; import org.apache.commons.math.ConvergenceException; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.MathException; import org.apache.commons.math.MaxEvaluationsExceededException; import org.apache.commons.math.MaxIterationsExceededException; import org.apache.commons.math.analysis.MultivariateRealFunction; import org.apache.commons.math.analysis.MultivariateVectorialFunction; +import org.apache.commons.math.exception.MathUserException; +import org.apache.commons.math.exception.util.LocalizedFormats; import org.apache.commons.math.linear.Array2DRowRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.optimization.GoalType; @@ -44,15 +45,15 @@ import org.junit.Test; public class NelderMeadTest { @Test - public void testFunctionEvaluationExceptions() throws OptimizationException { + public void testMathUserException() throws OptimizationException, MathUserException, IllegalArgumentException { MultivariateRealFunction wrong = new MultivariateRealFunction() { private static final long serialVersionUID = 4751314470965489371L; - public double value(double[] x) throws FunctionEvaluationException { + public double value(double[] x) throws MathUserException { if (x[0] < 0) { - throw new FunctionEvaluationException(x, "{0}", "oops"); + throw new MathUserException(LocalizedFormats.SIMPLE_MESSAGE, "oops"); } else if (x[0] > 1) { - throw new FunctionEvaluationException(new RuntimeException("oops"), x); + throw new MathUserException(new RuntimeException("oops")); } else { return x[0] * (1 - x[0]); } @@ -62,7 +63,7 @@ public class NelderMeadTest { NelderMead optimizer = new NelderMead(0.9, 1.9, 0.4, 0.6); optimizer.optimize(wrong, GoalType.MINIMIZE, new double[] { -1.0 }); fail("an exception should have been thrown"); - } catch (FunctionEvaluationException ce) { + } catch (MathUserException ce) { // expected behavior assertNull(ce.getCause()); } @@ -70,7 +71,7 @@ public class NelderMeadTest { NelderMead optimizer = new NelderMead(0.9, 1.9, 0.4, 0.6); optimizer.optimize(wrong, GoalType.MINIMIZE, new double[] { +2.0 }); fail("an exception should have been thrown"); - } catch (FunctionEvaluationException ce) { + } catch (MathUserException ce) { // expected behavior assertNotNull(ce.getCause()); } @@ -78,7 +79,7 @@ public class NelderMeadTest { @Test public void testMinimizeMaximize() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { // the following function has 4 local extrema: final double xM = -3.841947088256863675365; @@ -91,7 +92,7 @@ public class NelderMeadTest { final double valueXpYp = -valueXpYm; // global maximum MultivariateRealFunction fourExtrema = new MultivariateRealFunction() { private static final long serialVersionUID = -7039124064449091152L; - public double value(double[] variables) throws FunctionEvaluationException { + public double value(double[] variables) throws MathUserException { final double x = variables[0]; final double y = variables[1]; return ((x == 0) || (y == 0)) ? 0 : (FastMath.atan(x) * FastMath.atan(x + 2) * FastMath.atan(y) * FastMath.atan(y) / (x * y)); @@ -138,7 +139,7 @@ public class NelderMeadTest { @Test public void testRosenbrock() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { Rosenbrock rosenbrock = new Rosenbrock(); NelderMead optimizer = new NelderMead(); @@ -159,7 +160,7 @@ public class NelderMeadTest { @Test public void testPowell() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { Powell powell = new Powell(); NelderMead optimizer = new NelderMead(); @@ -176,7 +177,7 @@ public class NelderMeadTest { @Test public void testLeastSquares1() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { @@ -202,7 +203,7 @@ public class NelderMeadTest { @Test public void testLeastSquares2() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { @@ -228,7 +229,7 @@ public class NelderMeadTest { @Test public void testLeastSquares3() - throws FunctionEvaluationException, ConvergenceException { + throws MathUserException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { @@ -278,7 +279,7 @@ public class NelderMeadTest { optimizer.setConvergenceChecker(new SimpleRealPointChecker(-1.0, 1.0e-3)); optimizer.setMaxEvaluations(20); optimizer.optimize(powell, GoalType.MINIMIZE, new double[] { 3.0, -1.0, 0.0, 1.0 }); - } catch (FunctionEvaluationException fee) { + } catch (MathUserException fee) { if (fee.getCause() instanceof ConvergenceException) { throw (ConvergenceException) fee.getCause(); } @@ -294,7 +295,7 @@ public class NelderMeadTest { count = 0; } - public double value(double[] x) throws FunctionEvaluationException { + public double value(double[] x) { ++count; double a = x[1] - x[0] * x[0]; double b = 1.0 - x[0]; @@ -315,7 +316,7 @@ public class NelderMeadTest { count = 0; } - public double value(double[] x) throws FunctionEvaluationException { + public double value(double[] x) { ++count; double a = x[0] + 10 * x[1]; double b = x[2] - x[3];
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/PowellOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/PowellOptimizerTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/PowellOptimizerTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/PowellOptimizerTest.java Sat Nov 20 20:57:37 2010 @@ -16,7 +16,6 @@ */ package org.apache.commons.math.optimization.direct; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.MathException; import org.apache.commons.math.analysis.MultivariateRealFunction; import org.apache.commons.math.analysis.SumSincFunction; @@ -24,7 +23,6 @@ import org.apache.commons.math.optimizat import org.apache.commons.math.optimization.MultivariateRealOptimizer; import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.SimpleScalarValueChecker; -import org.apache.commons.math.optimization.direct.PowellOptimizer; import org.junit.Assert; import org.junit.Test; @@ -61,8 +59,7 @@ public class PowellOptimizerTest { @Test public void testQuadratic() throws MathException { final MultivariateRealFunction func = new MultivariateRealFunction() { - public double value(double[] x) - throws FunctionEvaluationException { + public double value(double[] x) { final double a = x[0] - 1; final double b = x[1] - 1; return a * a + b * b + 1; @@ -93,8 +90,7 @@ public class PowellOptimizerTest { @Test public void testMaximizeQuadratic() throws MathException { final MultivariateRealFunction func = new MultivariateRealFunction() { - public double value(double[] x) - throws FunctionEvaluationException { + public double value(double[] x) { final double a = x[0] - 1; final double b = x[1] - 1; return -a * a - b * b + 1; Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java Sat Nov 20 20:57:37 2010 @@ -17,7 +17,7 @@ package org.apache.commons.math.optimization.fitting; -import org.apache.commons.math.FunctionEvaluationException; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer; import org.apache.commons.math.util.FastMath; @@ -28,7 +28,7 @@ public class CurveFitterTest { @Test public void testMath303() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter fitter = new CurveFitter(optimizer); @@ -52,7 +52,7 @@ public class CurveFitterTest { @Test public void testMath304() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter fitter = new CurveFitter(optimizer); @@ -75,7 +75,7 @@ public class CurveFitterTest { @Test public void testMath372() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter curveFitter = new CurveFitter(optimizer); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/GaussianFitterTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/GaussianFitterTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/GaussianFitterTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/GaussianFitterTest.java Sat Nov 20 20:57:37 2010 @@ -19,7 +19,7 @@ package org.apache.commons.math.optimiza import static org.junit.Assert.assertEquals; -import org.apache.commons.math.FunctionEvaluationException; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.general. LevenbergMarquardtOptimizer; @@ -185,11 +185,11 @@ public class GaussianFitterTest { * Basic. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit01() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(DATASET1, fitter); GaussianFunction fitFunction = fitter.fit(); @@ -203,11 +203,11 @@ public class GaussianFitterTest { * Zero points is not enough observed points. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test(expected=IllegalArgumentException.class) public void testFit02() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); fitter.fit(); } @@ -216,11 +216,11 @@ public class GaussianFitterTest { * Two points is not enough observed points. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test(expected=IllegalArgumentException.class) public void testFit03() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(new double[][] { {4.0254623, 531026.0}, @@ -233,11 +233,11 @@ public class GaussianFitterTest { * Poor data: right of peak not symmetric with left of peak. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit04() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(DATASET2, fitter); GaussianFunction fitFunction = fitter.fit(); @@ -251,11 +251,11 @@ public class GaussianFitterTest { * Poor data: long tails. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit05() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(DATASET3, fitter); GaussianFunction fitFunction = fitter.fit(); @@ -269,11 +269,11 @@ public class GaussianFitterTest { * Poor data: right of peak is missing. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit06() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(DATASET4, fitter); GaussianFunction fitFunction = fitter.fit(); @@ -287,11 +287,11 @@ public class GaussianFitterTest { * Basic with smaller dataset. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit07() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { GaussianFitter fitter = new GaussianFitter(new LevenbergMarquardtOptimizer()); addDatasetToGaussianFitter(DATASET5, fitter); GaussianFunction fitFunction = fitter.fit(); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunctionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunctionTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunctionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunctionTest.java Sat Nov 20 20:57:37 2010 @@ -17,7 +17,7 @@ package org.apache.commons.math.optimization.fitting; -import org.apache.commons.math.FunctionEvaluationException; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.exception.ZeroException; import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.fitting.CurveFitter; @@ -72,11 +72,11 @@ public class ParametricGaussianFunctionT * Using not-so-good initial parameters. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit01() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { CurveFitter fitter = new CurveFitter(new LevenbergMarquardtOptimizer()); addDatasetToCurveFitter(DATASET1, fitter); double[] parameters = fitter.fit(new ParametricGaussianFunction(), @@ -91,11 +91,11 @@ public class ParametricGaussianFunctionT * Using eye-balled guesses for initial parameters. * * @throws OptimizationException in the event of a test case error - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test public void testFit02() - throws OptimizationException, FunctionEvaluationException { + throws OptimizationException, MathUserException { CurveFitter fitter = new CurveFitter(new LevenbergMarquardtOptimizer()); addDatasetToCurveFitter(DATASET1, fitter); double[] parameters = fitter.fit(new ParametricGaussianFunction(), @@ -109,10 +109,10 @@ public class ParametricGaussianFunctionT /** * The parameters array is null. * - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test(expected=IllegalArgumentException.class) - public void testValue01() throws FunctionEvaluationException { + public void testValue01() throws MathUserException { ParametricGaussianFunction f = new ParametricGaussianFunction(); f.value(0.0, null); } @@ -120,10 +120,10 @@ public class ParametricGaussianFunctionT /** * The parameters array length is not 4. * - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test(expected=IllegalArgumentException.class) - public void testValue02() throws FunctionEvaluationException { + public void testValue02() throws MathUserException { ParametricGaussianFunction f = new ParametricGaussianFunction(); f.value(0.0, new double[] {0.0, 1.0}); } @@ -131,10 +131,10 @@ public class ParametricGaussianFunctionT /** * The parameters d is 0. * - * @throws FunctionEvaluationException in the event of a test case error + * @throws MathUserException in the event of a test case error */ @Test(expected=ZeroException.class) - public void testValue03() throws FunctionEvaluationException { + public void testValue03() throws MathUserException { ParametricGaussianFunction f = new ParametricGaussianFunction(); f.value(0.0, new double[] {0.0, 1.0, 1.0, 0.0}); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java Sat Nov 20 20:57:37 2010 @@ -24,9 +24,9 @@ import java.util.Arrays; import junit.framework.TestCase; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction; import org.apache.commons.math.analysis.MultivariateMatrixFunction; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.linear.BlockRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.optimization.OptimizationException; @@ -104,7 +104,7 @@ extends TestCase { super(name); } - public void testTrivial() throws FunctionEvaluationException, OptimizationException { + public void testTrivial() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 }); GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true); @@ -117,7 +117,7 @@ extends TestCase { assertEquals(3.0, optimum.getValue()[0], 1.0e-10); } - public void testColumnsPermutation() throws FunctionEvaluationException, OptimizationException { + public void testColumnsPermutation() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 } }, @@ -137,7 +137,7 @@ extends TestCase { } - public void testNoDependency() throws FunctionEvaluationException, OptimizationException { + public void testNoDependency() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2, 0, 0, 0, 0, 0 }, { 0, 2, 0, 0, 0, 0 }, @@ -158,7 +158,7 @@ extends TestCase { } } - public void testOneSet() throws FunctionEvaluationException, OptimizationException { + public void testOneSet() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0, 0 }, @@ -177,7 +177,7 @@ extends TestCase { } - public void testTwoSets() throws FunctionEvaluationException, OptimizationException { + public void testTwoSets() throws MathUserException, OptimizationException { double epsilon = 1.0e-7; LinearProblem problem = new LinearProblem(new double[][] { { 2, 1, 0, 4, 0, 0 }, @@ -222,7 +222,7 @@ extends TestCase { } } - public void testIllConditioned() throws FunctionEvaluationException, OptimizationException { + public void testIllConditioned() throws MathUserException, OptimizationException { LinearProblem problem1 = new LinearProblem(new double[][] { { 10.0, 7.0, 8.0, 7.0 }, { 7.0, 5.0, 6.0, 5.0 }, @@ -299,7 +299,7 @@ extends TestCase { } } - public void testRedundantEquations() throws FunctionEvaluationException, OptimizationException { + public void testRedundantEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -318,7 +318,7 @@ extends TestCase { } - public void testInconsistentEquations() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -333,7 +333,7 @@ extends TestCase { } - public void testInconsistentSizes() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentSizes() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } }, new double[] { -1, 1 }); GaussNewtonOptimizer optimizer = new GaussNewtonOptimizer(true); @@ -360,7 +360,7 @@ extends TestCase { new double[] { 1 }, new double[] { 0, 0 }); fail("an exception should have been thrown"); - } catch (FunctionEvaluationException oe) { + } catch (MathUserException oe) { // expected behavior } @@ -386,7 +386,7 @@ extends TestCase { } } - public void testCircleFitting() throws FunctionEvaluationException, OptimizationException { + public void testCircleFitting() throws MathUserException, OptimizationException { Circle circle = new Circle(); circle.addPoint( 30.0, 68.0); circle.addPoint( 50.0, -6.0); @@ -407,7 +407,7 @@ extends TestCase { assertEquals(48.135167894714, center.y, 1.0e-10); } - public void testCircleFittingBadInit() throws FunctionEvaluationException, OptimizationException { + public void testCircleFittingBadInit() throws MathUserException, OptimizationException { Circle circle = new Circle(); double[][] points = new double[][] { {-0.312967, 0.072366}, {-0.339248, 0.132965}, {-0.379780, 0.202724}, Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java Sat Nov 20 20:57:37 2010 @@ -25,9 +25,9 @@ import java.util.List; import junit.framework.TestCase; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction; import org.apache.commons.math.analysis.MultivariateMatrixFunction; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.linear.BlockRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.optimization.OptimizationException; @@ -104,7 +104,7 @@ public class LevenbergMarquardtOptimizer super(name); } - public void testTrivial() throws FunctionEvaluationException, OptimizationException { + public void testTrivial() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 }); LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); @@ -121,7 +121,7 @@ public class LevenbergMarquardtOptimizer assertEquals(3.0, optimum.getValue()[0], 1.0e-10); } - public void testQRColumnsPermutation() throws FunctionEvaluationException, OptimizationException { + public void testQRColumnsPermutation() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 } }, @@ -139,7 +139,7 @@ public class LevenbergMarquardtOptimizer } - public void testNoDependency() throws FunctionEvaluationException, OptimizationException { + public void testNoDependency() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2, 0, 0, 0, 0, 0 }, { 0, 2, 0, 0, 0, 0 }, @@ -158,7 +158,7 @@ public class LevenbergMarquardtOptimizer } } - public void testOneSet() throws FunctionEvaluationException, OptimizationException { + public void testOneSet() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0, 0 }, @@ -175,7 +175,7 @@ public class LevenbergMarquardtOptimizer } - public void testTwoSets() throws FunctionEvaluationException, OptimizationException { + public void testTwoSets() throws MathUserException, OptimizationException { double epsilon = 1.0e-7; LinearProblem problem = new LinearProblem(new double[][] { { 2, 1, 0, 4, 0, 0 }, @@ -200,7 +200,7 @@ public class LevenbergMarquardtOptimizer } - public void testNonInversible() throws FunctionEvaluationException, OptimizationException { + public void testNonInversible() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 2, -3 }, @@ -220,7 +220,7 @@ public class LevenbergMarquardtOptimizer } - public void testIllConditioned() throws FunctionEvaluationException, OptimizationException { + public void testIllConditioned() throws MathUserException, OptimizationException { LinearProblem problem1 = new LinearProblem(new double[][] { { 10.0, 7.0, 8.0, 7.0 }, { 7.0, 5.0, 6.0, 5.0 }, @@ -254,7 +254,7 @@ public class LevenbergMarquardtOptimizer } - public void testMoreEstimatedParametersSimple() throws FunctionEvaluationException, OptimizationException { + public void testMoreEstimatedParametersSimple() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 3.0, 2.0, 0.0, 0.0 }, @@ -269,7 +269,7 @@ public class LevenbergMarquardtOptimizer } - public void testMoreEstimatedParametersUnsorted() throws FunctionEvaluationException, OptimizationException { + public void testMoreEstimatedParametersUnsorted() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 1.0, 1.0, 0.0 }, @@ -290,7 +290,7 @@ public class LevenbergMarquardtOptimizer } - public void testRedundantEquations() throws FunctionEvaluationException, OptimizationException { + public void testRedundantEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -307,7 +307,7 @@ public class LevenbergMarquardtOptimizer } - public void testInconsistentEquations() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -320,7 +320,7 @@ public class LevenbergMarquardtOptimizer } - public void testInconsistentSizes() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentSizes() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } }, new double[] { -1, 1 }); LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); @@ -345,7 +345,7 @@ public class LevenbergMarquardtOptimizer new double[] { 1 }, new double[] { 0, 0 }); fail("an exception should have been thrown"); - } catch (FunctionEvaluationException oe) { + } catch (MathUserException oe) { // expected behavior } @@ -381,12 +381,12 @@ public class LevenbergMarquardtOptimizer assertTrue(! shouldFail); } catch (OptimizationException ee) { assertTrue(shouldFail); - } catch (FunctionEvaluationException ee) { + } catch (MathUserException ee) { assertTrue(shouldFail); } } - public void testCircleFitting() throws FunctionEvaluationException, OptimizationException { + public void testCircleFitting() throws MathUserException, OptimizationException { Circle circle = new Circle(); circle.addPoint( 30.0, 68.0); circle.addPoint( 50.0, -6.0); @@ -435,7 +435,7 @@ public class LevenbergMarquardtOptimizer } - public void testCircleFittingBadInit() throws FunctionEvaluationException, OptimizationException { + public void testCircleFittingBadInit() throws MathUserException, OptimizationException { Circle circle = new Circle(); double[][] points = new double[][] { {-0.312967, 0.072366}, {-0.339248, 0.132965}, {-0.379780, 0.202724}, @@ -488,7 +488,7 @@ public class LevenbergMarquardtOptimizer assertEquals( 0.2075001, center.y, 1.0e-6); } - public void testMath199() throws FunctionEvaluationException { + public void testMath199() throws MathUserException { try { QuadraticProblem problem = new QuadraticProblem(); problem.addPoint (0, -3.182591015485607); @@ -590,7 +590,7 @@ public class LevenbergMarquardtOptimizer } public double[] value(double[] variables) - throws FunctionEvaluationException, IllegalArgumentException { + throws MathUserException, IllegalArgumentException { Point2D.Double center = new Point2D.Double(variables[0], variables[1]); double radius = getRadius(center); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java Sat Nov 20 20:57:37 2010 @@ -22,9 +22,9 @@ import java.util.Arrays; import junit.framework.TestCase; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction; import org.apache.commons.math.analysis.MultivariateMatrixFunction; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.VectorialPointValuePair; import org.apache.commons.math.util.FastMath; @@ -505,7 +505,7 @@ public class MinpackTest extends TestCas function.checkTheoreticalMinParams(optimum); } catch (OptimizationException lsse) { assertTrue(exceptionExpected); - } catch (FunctionEvaluationException fe) { + } catch (MathUserException fe) { assertTrue(exceptionExpected); } } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java Sat Nov 20 20:57:37 2010 @@ -23,11 +23,11 @@ import java.util.ArrayList; import junit.framework.TestCase; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.DifferentiableMultivariateRealFunction; import org.apache.commons.math.analysis.MultivariateRealFunction; import org.apache.commons.math.analysis.MultivariateVectorialFunction; import org.apache.commons.math.analysis.solvers.BrentSolver; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.linear.BlockRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.optimization.GoalType; @@ -104,7 +104,7 @@ extends TestCase { super(name); } - public void testTrivial() throws FunctionEvaluationException, OptimizationException { + public void testTrivial() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 }); NonLinearConjugateGradientOptimizer optimizer = @@ -117,7 +117,7 @@ extends TestCase { assertEquals(0.0, optimum.getValue(), 1.0e-10); } - public void testColumnsPermutation() throws FunctionEvaluationException, OptimizationException { + public void testColumnsPermutation() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 } }, @@ -135,7 +135,7 @@ extends TestCase { } - public void testNoDependency() throws FunctionEvaluationException, OptimizationException { + public void testNoDependency() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 2, 0, 0, 0, 0, 0 }, { 0, 2, 0, 0, 0, 0 }, @@ -155,7 +155,7 @@ extends TestCase { } } - public void testOneSet() throws FunctionEvaluationException, OptimizationException { + public void testOneSet() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0, 0 }, @@ -174,7 +174,7 @@ extends TestCase { } - public void testTwoSets() throws FunctionEvaluationException, OptimizationException { + public void testTwoSets() throws MathUserException, OptimizationException { final double epsilon = 1.0e-7; LinearProblem problem = new LinearProblem(new double[][] { { 2, 1, 0, 4, 0, 0 }, @@ -213,7 +213,7 @@ extends TestCase { } - public void testNonInversible() throws FunctionEvaluationException, OptimizationException { + public void testNonInversible() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 2, -3 }, @@ -229,7 +229,7 @@ extends TestCase { assertTrue(optimum.getValue() > 0.5); } - public void testIllConditioned() throws FunctionEvaluationException, OptimizationException { + public void testIllConditioned() throws MathUserException, OptimizationException { LinearProblem problem1 = new LinearProblem(new double[][] { { 10.0, 7.0, 8.0, 7.0 }, { 7.0, 5.0, 6.0, 5.0 }, @@ -267,7 +267,7 @@ extends TestCase { } public void testMoreEstimatedParametersSimple() - throws FunctionEvaluationException, OptimizationException { + throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 3.0, 2.0, 0.0, 0.0 }, @@ -286,7 +286,7 @@ extends TestCase { } public void testMoreEstimatedParametersUnsorted() - throws FunctionEvaluationException, OptimizationException { + throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 1.0, 1.0, 0.0 }, @@ -303,7 +303,7 @@ extends TestCase { assertEquals(0, optimum.getValue(), 1.0e-10); } - public void testRedundantEquations() throws FunctionEvaluationException, OptimizationException { + public void testRedundantEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -321,7 +321,7 @@ extends TestCase { } - public void testInconsistentEquations() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentEquations() throws MathUserException, OptimizationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -338,7 +338,7 @@ extends TestCase { } - public void testCircleFitting() throws FunctionEvaluationException, OptimizationException { + public void testCircleFitting() throws MathUserException, OptimizationException { Circle circle = new Circle(); circle.addPoint( 30.0, 68.0); circle.addPoint( 50.0, -6.0); @@ -383,7 +383,7 @@ extends TestCase { return p; } - public double value(double[] variables) throws FunctionEvaluationException { + public double value(double[] variables) throws MathUserException { double[] y = factors.operate(variables); double sum = 0; for (int i = 0; i < y.length; ++i) { @@ -457,7 +457,7 @@ extends TestCase { } public double value(double[] variables) - throws IllegalArgumentException, FunctionEvaluationException { + throws IllegalArgumentException, MathUserException { Point2D.Double center = new Point2D.Double(variables[0], variables[1]); double radius = getRadius(center); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BracketFinderTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BracketFinderTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BracketFinderTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BracketFinderTest.java Sat Nov 20 20:57:37 2010 @@ -17,7 +17,6 @@ package org.apache.commons.math.optimization.univariate; import org.apache.commons.math.MathException; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.UnivariateRealFunction; import org.apache.commons.math.optimization.GoalType; @@ -30,8 +29,7 @@ public class BracketFinderTest { public void testCubicMin() throws MathException { final BracketFinder bFind = new BracketFinder(); final UnivariateRealFunction func = new UnivariateRealFunction() { - public double value(double x) - throws FunctionEvaluationException { + public double value(double x) { if (x < -2) { return value(-2); } @@ -53,8 +51,7 @@ public class BracketFinderTest { public void testCubicMax() throws MathException { final BracketFinder bFind = new BracketFinder(); final UnivariateRealFunction func = new UnivariateRealFunction() { - public double value(double x) - throws FunctionEvaluationException { + public double value(double x) { if (x < -2) { return value(-2); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java Sat Nov 20 20:57:37 2010 @@ -20,9 +20,9 @@ import static org.junit.Assert.assertEqu import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.MathException; import org.apache.commons.math.MaxIterationsExceededException; +import org.apache.commons.math.exception.MathUserException; import org.apache.commons.math.exception.NoDataException; import org.apache.commons.math.analysis.QuinticFunction; import org.apache.commons.math.analysis.SinFunction; @@ -60,7 +60,7 @@ public final class BrentOptimizerTest { try { minimizer.optimize(f, GoalType.MINIMIZE, 4, 5); fail("an exception should have been thrown"); - } catch (FunctionEvaluationException fee) { + } catch (MathUserException mue) { // expected } catch (Exception e) { fail("wrong exception caught"); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegressionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegressionTest.java?rev=1037327&r1=1037326&r2=1037327&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegressionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegressionTest.java Sat Nov 20 20:57:37 2010 @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEqu import org.apache.commons.math.TestUtils; import org.apache.commons.math.linear.DefaultRealMatrixChangingVisitor; import org.apache.commons.math.linear.MatrixUtils; -import org.apache.commons.math.linear.MatrixVisitorException; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.linear.Array2DRowRealMatrix; import org.apache.commons.math.linear.RealVector; @@ -88,8 +87,7 @@ public class OLSMultipleLinearRegression RealMatrix referenceVariance = new Array2DRowRealMatrix(s.length, s.length); referenceVariance.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor() { @Override - public double visit(int row, int column, double value) - throws MatrixVisitorException { + public double visit(int row, int column, double value) { if (row == 0) { return s[column]; }