commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject [08/18] [math] Remove deprecated optimization package.
Date Wed, 25 Feb 2015 21:49:36 GMT
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateMultiStartOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateMultiStartOptimizer.java b/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateMultiStartOptimizer.java
deleted file mode 100644
index cbf73c5..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateMultiStartOptimizer.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization.univariate;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.apache.commons.math4.analysis.UnivariateFunction;
-import org.apache.commons.math4.exception.MathIllegalStateException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.optimization.ConvergenceChecker;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.random.RandomGenerator;
-
-/**
- * Special implementation of the {@link UnivariateOptimizer} interface
- * adding multi-start features to an existing optimizer.
- *
- * This class wraps a classical optimizer to use it several times in
- * turn with different starting points in order to avoid being trapped
- * into a local extremum when looking for a global one.
- *
- * @param <FUNC> Type of the objective function to be optimized.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class UnivariateMultiStartOptimizer<FUNC extends UnivariateFunction>
-    implements BaseUnivariateOptimizer<FUNC> {
-    /** Underlying classical optimizer. */
-    private final BaseUnivariateOptimizer<FUNC> optimizer;
-    /** Maximal number of evaluations allowed. */
-    private int maxEvaluations;
-    /** Number of evaluations already performed for all starts. */
-    private int totalEvaluations;
-    /** Number of starts to go. */
-    private int starts;
-    /** Random generator for multi-start. */
-    private RandomGenerator generator;
-    /** Found optima. */
-    private UnivariatePointValuePair[] optima;
-
-    /**
-     * Create a multi-start optimizer from a single-start optimizer.
-     *
-     * @param optimizer Single-start optimizer to wrap.
-     * @param starts Number of starts to perform. If {@code starts == 1},
-     * the {@code optimize} methods will return the same solution as
-     * {@code optimizer} would.
-     * @param generator Random generator to use for restarts.
-     * @throws NullArgumentException if {@code optimizer} or {@code generator}
-     * is {@code null}.
-     * @throws NotStrictlyPositiveException if {@code starts < 1}.
-     */
-    public UnivariateMultiStartOptimizer(final BaseUnivariateOptimizer<FUNC> optimizer,
-                                             final int starts,
-                                             final RandomGenerator generator) {
-        if (optimizer == null ||
-                generator == null) {
-                throw new NullArgumentException();
-        }
-        if (starts < 1) {
-            throw new NotStrictlyPositiveException(starts);
-        }
-
-        this.optimizer = optimizer;
-        this.starts = starts;
-        this.generator = generator;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public ConvergenceChecker<UnivariatePointValuePair> getConvergenceChecker() {
-        return optimizer.getConvergenceChecker();
-    }
-
-    /** {@inheritDoc} */
-    public int getMaxEvaluations() {
-        return maxEvaluations;
-    }
-
-    /** {@inheritDoc} */
-    public int getEvaluations() {
-        return totalEvaluations;
-    }
-
-    /**
-     * Get all the optima found during the last call to {@link
-     * #optimize(int,UnivariateFunction,GoalType,double,double) optimize}.
-     * The optimizer stores all the optima found during a set of
-     * restarts. The {@link #optimize(int,UnivariateFunction,GoalType,double,double) optimize}
-     * method returns the best point only. This method returns all the points
-     * found at the end of each starts, including the best one already
-     * returned by the {@link #optimize(int,UnivariateFunction,GoalType,double,double) optimize}
-     * method.
-     * <br/>
-     * The returned array as one element for each start as specified
-     * in the constructor. It is ordered with the results from the
-     * runs that did converge first, sorted from best to worst
-     * objective value (i.e in ascending order if minimizing and in
-     * descending order if maximizing), followed by {@code null} elements
-     * corresponding to the runs that did not converge. This means all
-     * elements will be {@code null} if the {@link
-     * #optimize(int,UnivariateFunction,GoalType,double,double) optimize}
-     * method did throw an exception.
-     * This also means that if the first element is not {@code null}, it is
-     * the best point found across all starts.
-     *
-     * @return an array containing the optima.
-     * @throws MathIllegalStateException if {@link
-     * #optimize(int,UnivariateFunction,GoalType,double,double) optimize}
-     * has not been called.
-     */
-    public UnivariatePointValuePair[] getOptima() {
-        if (optima == null) {
-            throw new MathIllegalStateException(LocalizedFormats.NO_OPTIMUM_COMPUTED_YET);
-        }
-        return optima.clone();
-    }
-
-    /** {@inheritDoc} */
-    public UnivariatePointValuePair optimize(int maxEval, final FUNC f,
-                                                 final GoalType goal,
-                                                 final double min, final double max) {
-        return optimize(maxEval, f, goal, min, max, min + 0.5 * (max - min));
-    }
-
-    /** {@inheritDoc} */
-    public UnivariatePointValuePair optimize(int maxEval, final FUNC f,
-                                                 final GoalType goal,
-                                                 final double min, final double max,
-                                                 final double startValue) {
-        RuntimeException lastException = null;
-        optima = new UnivariatePointValuePair[starts];
-        totalEvaluations = 0;
-
-        // Multi-start loop.
-        for (int i = 0; i < starts; ++i) {
-            // CHECKSTYLE: stop IllegalCatch
-            try {
-                final double s = (i == 0) ? startValue : min + generator.nextDouble() * (max - min);
-                optima[i] = optimizer.optimize(maxEval - totalEvaluations, f, goal, min, max, s);
-            } catch (RuntimeException mue) {
-                lastException = mue;
-                optima[i] = null;
-            }
-            // CHECKSTYLE: resume IllegalCatch
-
-            totalEvaluations += optimizer.getEvaluations();
-        }
-
-        sortPairs(goal);
-
-        if (optima[0] == null) {
-            throw lastException; // cannot be null if starts >=1
-        }
-
-        // Return the point with the best objective function value.
-        return optima[0];
-    }
-
-    /**
-     * Sort the optima from best to worst, followed by {@code null} elements.
-     *
-     * @param goal Goal type.
-     */
-    private void sortPairs(final GoalType goal) {
-        Arrays.sort(optima, new Comparator<UnivariatePointValuePair>() {
-                public int compare(final UnivariatePointValuePair o1,
-                                   final UnivariatePointValuePair o2) {
-                    if (o1 == null) {
-                        return (o2 == null) ? 0 : 1;
-                    } else if (o2 == null) {
-                        return -1;
-                    }
-                    final double v1 = o1.getValue();
-                    final double v2 = o2.getValue();
-                    return (goal == GoalType.MINIMIZE) ?
-                        Double.compare(v1, v2) : Double.compare(v2, v1);
-                }
-            });
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateOptimizer.java b/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateOptimizer.java
deleted file mode 100644
index b621c8b..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariateOptimizer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.optimization.univariate;
-
-import org.apache.commons.math4.analysis.UnivariateFunction;
-
-/**
- * Interface for univariate optimization algorithms.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public interface UnivariateOptimizer
-    extends BaseUnivariateOptimizer<UnivariateFunction> {}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariatePointValuePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariatePointValuePair.java b/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariatePointValuePair.java
deleted file mode 100644
index 6f5c450..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/UnivariatePointValuePair.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization.univariate;
-
-import java.io.Serializable;
-
-/**
- * This class holds a point and the value of an objective function at this
- * point.
- * This is a simple immutable container.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class UnivariatePointValuePair implements Serializable {
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = 1003888396256744753L;
-    /** Point. */
-    private final double point;
-    /** Value of the objective function at the point. */
-    private final double value;
-
-    /**
-     * Build a point/objective function value pair.
-     *
-     * @param point Point.
-     * @param value Value of an objective function at the point
-     */
-    public UnivariatePointValuePair(final double point,
-                                    final double value) {
-        this.point = point;
-        this.value = value;
-    }
-
-    /**
-     * Get the point.
-     *
-     * @return the point.
-     */
-    public double getPoint() {
-        return point;
-    }
-
-    /**
-     * Get the value of the objective function.
-     *
-     * @return the stored value of the objective function.
-     */
-    public double getValue() {
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/package-info.java b/src/main/java/org/apache/commons/math4/optimization/univariate/package-info.java
deleted file mode 100644
index 97258e3..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *
- *     Univariate real functions minimum finding algorithms.
- *
- */
-package org.apache.commons.math4.optimization.univariate;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableMultiStartOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableMultiStartOptimizerTest.java b/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableMultiStartOptimizerTest.java
deleted file mode 100644
index 60c412e..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableMultiStartOptimizerTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization;
-
-
-import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableFunction;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
-import org.apache.commons.math4.optimization.ConvergenceChecker;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.optimization.MultivariateDifferentiableMultiStartOptimizer;
-import org.apache.commons.math4.optimization.MultivariateDifferentiableOptimizer;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.optimization.SimpleValueChecker;
-import org.apache.commons.math4.optimization.general.CircleScalar;
-import org.apache.commons.math4.optimization.general.ConjugateGradientFormula;
-import org.apache.commons.math4.optimization.general.NonLinearConjugateGradientOptimizer;
-import org.apache.commons.math4.random.GaussianRandomGenerator;
-import org.apache.commons.math4.random.JDKRandomGenerator;
-import org.apache.commons.math4.random.RandomVectorGenerator;
-import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
-import org.junit.Assert;
-import org.junit.Test;
-
-@Deprecated
-public class MultivariateDifferentiableMultiStartOptimizerTest {
-
-    @Test
-    public void testCircleFitting() {
-        CircleScalar circle = new CircleScalar();
-        circle.addPoint( 30.0,  68.0);
-        circle.addPoint( 50.0,  -6.0);
-        circle.addPoint(110.0, -20.0);
-        circle.addPoint( 35.0,  15.0);
-        circle.addPoint( 45.0,  97.0);
-        // TODO: the wrapper around NonLinearConjugateGradientOptimizer is a temporary hack for
-        // version 3.1 of the library. It should be removed when NonLinearConjugateGradientOptimizer
-        // will officially be declared as implementing MultivariateDifferentiableOptimizer
-        MultivariateDifferentiableOptimizer underlying =
-                new MultivariateDifferentiableOptimizer() {
-
-            private final NonLinearConjugateGradientOptimizer cg =
-                    new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
-                                                            new SimpleValueChecker(1.0e-10, 1.0e-10));
-            public PointValuePair optimize(int maxEval,
-                                           MultivariateDifferentiableFunction f,
-                                           GoalType goalType,
-                                           double[] startPoint) {
-                return cg.optimize(maxEval, f, goalType, startPoint);
-            }
-
-            public int getMaxEvaluations() {
-                return cg.getMaxEvaluations();
-            }
-
-            public int getEvaluations() {
-                return cg.getEvaluations();
-            }
-
-            public ConvergenceChecker<PointValuePair> getConvergenceChecker() {
-                return cg.getConvergenceChecker();
-            }
-        };
-        JDKRandomGenerator g = new JDKRandomGenerator();
-        g.setSeed(753289573253l);
-        RandomVectorGenerator generator =
-            new UncorrelatedRandomVectorGenerator(new double[] { 50.0, 50.0 }, new double[] { 10.0, 10.0 },
-                                                  new GaussianRandomGenerator(g));
-        MultivariateDifferentiableMultiStartOptimizer optimizer =
-            new MultivariateDifferentiableMultiStartOptimizer(underlying, 10, generator);
-        PointValuePair optimum =
-            optimizer.optimize(200, circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345 });
-        Assert.assertEquals(200, optimizer.getMaxEvaluations());
-        PointValuePair[] optima = optimizer.getOptima();
-        for (PointValuePair o : optima) {
-            Vector2D center = new Vector2D(o.getPointRef()[0], o.getPointRef()[1]);
-            Assert.assertEquals(69.960161753, circle.getRadius(center), 1.0e-8);
-            Assert.assertEquals(96.075902096, center.getX(), 1.0e-8);
-            Assert.assertEquals(48.135167894, center.getY(), 1.0e-8);
-        }
-        Assert.assertTrue(optimizer.getEvaluations() > 70);
-        Assert.assertTrue(optimizer.getEvaluations() < 90);
-        Assert.assertEquals(3.1267527, optimum.getValue(), 1.0e-8);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableVectorMultiStartOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableVectorMultiStartOptimizerTest.java b/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableVectorMultiStartOptimizerTest.java
deleted file mode 100644
index f36d364..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/MultivariateDifferentiableVectorMultiStartOptimizerTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization;
-
-
-import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
-import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableVectorFunction;
-import org.apache.commons.math4.exception.MathIllegalStateException;
-import org.apache.commons.math4.linear.BlockRealMatrix;
-import org.apache.commons.math4.linear.RealMatrix;
-import org.apache.commons.math4.optimization.ConvergenceChecker;
-import org.apache.commons.math4.optimization.MultivariateDifferentiableVectorMultiStartOptimizer;
-import org.apache.commons.math4.optimization.MultivariateDifferentiableVectorOptimizer;
-import org.apache.commons.math4.optimization.PointVectorValuePair;
-import org.apache.commons.math4.optimization.SimpleVectorValueChecker;
-import org.apache.commons.math4.optimization.general.GaussNewtonOptimizer;
-import org.apache.commons.math4.random.GaussianRandomGenerator;
-import org.apache.commons.math4.random.JDKRandomGenerator;
-import org.apache.commons.math4.random.RandomVectorGenerator;
-import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * <p>Some of the unit tests are re-implementations of the MINPACK <a
- * href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
- * The redistribution policy for MINPACK is available <a
- * href="http://www.netlib.org/minpack/disclaimer">here</a>, for
- * convenience, it is reproduced below.</p>
-
- * <table border="0" width="80%" cellpadding="10" align="center" bgcolor="#E0E0E0">
- * <tr><td>
- *    Minpack Copyright Notice (1999) University of Chicago.
- *    All rights reserved
- * </td></tr>
- * <tr><td>
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * <ol>
- *  <li>Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.</li>
- * <li>Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the following
- *     disclaimer in the documentation and/or other materials provided
- *     with the distribution.</li>
- * <li>The end-user documentation included with the redistribution, if any,
- *     must include the following acknowledgment:
- *     <code>This product includes software developed by the University of
- *           Chicago, as Operator of Argonne National Laboratory.</code>
- *     Alternately, this acknowledgment may appear in the software itself,
- *     if and wherever such third-party acknowledgments normally appear.</li>
- * <li><strong>WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
- *     WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
- *     UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
- *     THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
- *     IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
- *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
- *     OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
- *     OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
- *     USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
- *     THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
- *     DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
- *     UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
- *     BE CORRECTED.</strong></li>
- * <li><strong>LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
- *     HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
- *     ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
- *     INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
- *     ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
- *     PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
- *     SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
- *     (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
- *     EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
- *     POSSIBILITY OF SUCH LOSS OR DAMAGES.</strong></li>
- * <ol></td></tr>
- * </table>
-
- * @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)
- * @author Burton S. Garbow (original fortran minpack tests)
- * @author Kenneth E. Hillstrom (original fortran minpack tests)
- * @author Jorge J. More (original fortran minpack tests)
- * @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)
- */
-@Deprecated
-public class MultivariateDifferentiableVectorMultiStartOptimizerTest {
-
-    @Test
-    public void testTrivial() {
-        LinearProblem problem =
-            new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
-        // TODO: the wrapper around GaussNewtonOptimizer is a temporary hack for
-        // version 3.1 of the library. It should be removed when GaussNewtonOptimizer
-        // will officialy be declared as implementing MultivariateDifferentiableVectorOptimizer
-        MultivariateDifferentiableVectorOptimizer underlyingOptimizer =
-                new MultivariateDifferentiableVectorOptimizer() {
-            private GaussNewtonOptimizer gn =
-                    new GaussNewtonOptimizer(true,
-                                             new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
-
-            public PointVectorValuePair optimize(int maxEval,
-                                                 MultivariateDifferentiableVectorFunction f,
-                                                 double[] target,
-                                                 double[] weight,
-                                                 double[] startPoint) {
-                return gn.optimize(maxEval, f, target, weight, startPoint);
-            }
-
-            public int getMaxEvaluations() {
-                return gn.getMaxEvaluations();
-            }
-
-            public int getEvaluations() {
-                return gn.getEvaluations();
-            }
-
-            public ConvergenceChecker<PointVectorValuePair> getConvergenceChecker() {
-                return gn.getConvergenceChecker();
-            }
-        };
-        JDKRandomGenerator g = new JDKRandomGenerator();
-        g.setSeed(16069223052l);
-        RandomVectorGenerator generator =
-            new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
-        MultivariateDifferentiableVectorMultiStartOptimizer optimizer =
-            new MultivariateDifferentiableVectorMultiStartOptimizer(underlyingOptimizer,
-                                                                       10, generator);
-
-        // no optima before first optimization attempt
-        try {
-            optimizer.getOptima();
-            Assert.fail("an exception should have been thrown");
-        } catch (MathIllegalStateException ise) {
-            // expected
-        }
-        PointVectorValuePair optimum =
-            optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
-        Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
-        Assert.assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
-        PointVectorValuePair[] optima = optimizer.getOptima();
-        Assert.assertEquals(10, optima.length);
-        for (int i = 0; i < optima.length; ++i) {
-            Assert.assertEquals(1.5, optima[i].getPoint()[0], 1.0e-10);
-            Assert.assertEquals(3.0, optima[i].getValue()[0], 1.0e-10);
-        }
-        Assert.assertTrue(optimizer.getEvaluations() > 20);
-        Assert.assertTrue(optimizer.getEvaluations() < 50);
-        Assert.assertEquals(100, optimizer.getMaxEvaluations());
-    }
-
-    @Test(expected=TestException.class)
-    public void testNoOptimum() {
-
-        // TODO: the wrapper around GaussNewtonOptimizer is a temporary hack for
-        // version 3.1 of the library. It should be removed when GaussNewtonOptimizer
-        // will officialy be declared as implementing MultivariateDifferentiableVectorOptimizer
-        MultivariateDifferentiableVectorOptimizer underlyingOptimizer =
-                new MultivariateDifferentiableVectorOptimizer() {
-            private GaussNewtonOptimizer gn =
-                    new GaussNewtonOptimizer(true,
-                                             new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
-
-            public PointVectorValuePair optimize(int maxEval,
-                                                 MultivariateDifferentiableVectorFunction f,
-                                                 double[] target,
-                                                 double[] weight,
-                                                 double[] startPoint) {
-                return gn.optimize(maxEval, f, target, weight, startPoint);
-            }
-
-            public int getMaxEvaluations() {
-                return gn.getMaxEvaluations();
-            }
-
-            public int getEvaluations() {
-                return gn.getEvaluations();
-            }
-
-            public ConvergenceChecker<PointVectorValuePair> getConvergenceChecker() {
-                return gn.getConvergenceChecker();
-            }
-        };
-        JDKRandomGenerator g = new JDKRandomGenerator();
-        g.setSeed(12373523445l);
-        RandomVectorGenerator generator =
-            new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
-        MultivariateDifferentiableVectorMultiStartOptimizer optimizer =
-            new MultivariateDifferentiableVectorMultiStartOptimizer(underlyingOptimizer,
-                                                                       10, generator);
-        optimizer.optimize(100, new MultivariateDifferentiableVectorFunction() {
-            public double[] value(double[] point) {
-                throw new TestException();
-            }
-            public DerivativeStructure[] value(DerivativeStructure[] point) {
-                return point;
-            }
-            }, new double[] { 2 }, new double[] { 1 }, new double[] { 0 });
-    }
-
-    private static class TestException extends RuntimeException {
-        private static final long serialVersionUID = -7809988995389067683L;
-    }
-
-    private static class LinearProblem implements MultivariateDifferentiableVectorFunction {
-
-        final RealMatrix factors;
-        final double[] target;
-        public LinearProblem(double[][] factors, double[] target) {
-            this.factors = new BlockRealMatrix(factors);
-            this.target  = target;
-        }
-
-        public double[] value(double[] variables) {
-            return factors.operate(variables);
-        }
-
-        public DerivativeStructure[] value(DerivativeStructure[] variables) {
-            DerivativeStructure[] y = new DerivativeStructure[factors.getRowDimension()];
-            for (int i = 0; i < y.length; ++i) {
-                y[i] = variables[0].getField().getZero();
-                for (int j = 0; j < factors.getColumnDimension(); ++j) {
-                    y[i] = y[i].add(variables[j].multiply(factors.getEntry(i, j)));
-                }
-            }
-            return y;
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/MultivariateMultiStartOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/MultivariateMultiStartOptimizerTest.java b/src/test/java/org/apache/commons/math4/optimization/MultivariateMultiStartOptimizerTest.java
deleted file mode 100644
index f3f4461..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/MultivariateMultiStartOptimizerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization;
-
-
-import org.apache.commons.math4.analysis.MultivariateFunction;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.optimization.MultivariateMultiStartOptimizer;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.optimization.SimpleValueChecker;
-import org.apache.commons.math4.optimization.direct.NelderMeadSimplex;
-import org.apache.commons.math4.optimization.direct.SimplexOptimizer;
-import org.apache.commons.math4.random.GaussianRandomGenerator;
-import org.apache.commons.math4.random.JDKRandomGenerator;
-import org.apache.commons.math4.random.RandomVectorGenerator;
-import org.apache.commons.math4.random.UncorrelatedRandomVectorGenerator;
-import org.junit.Assert;
-import org.junit.Test;
-
-@Deprecated
-public class MultivariateMultiStartOptimizerTest {
-    @Test
-    public void testRosenbrock() {
-        Rosenbrock rosenbrock = new Rosenbrock();
-        SimplexOptimizer underlying
-            = new SimplexOptimizer(new SimpleValueChecker(-1, 1.0e-3));
-        NelderMeadSimplex simplex = new NelderMeadSimplex(new double[][] {
-                { -1.2,  1.0 }, { 0.9, 1.2 } , {  3.5, -2.3 }
-            });
-        underlying.setSimplex(simplex);
-        JDKRandomGenerator g = new JDKRandomGenerator();
-        g.setSeed(16069223052l);
-        RandomVectorGenerator generator =
-            new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g));
-        MultivariateMultiStartOptimizer optimizer =
-            new MultivariateMultiStartOptimizer(underlying, 10, generator);
-        PointValuePair optimum =
-            optimizer.optimize(1100, rosenbrock, GoalType.MINIMIZE, new double[] { -1.2, 1.0 });
-
-        Assert.assertEquals(rosenbrock.getCount(), optimizer.getEvaluations());
-        Assert.assertTrue(optimizer.getEvaluations() > 900);
-        Assert.assertTrue(optimizer.getEvaluations() < 1200);
-        Assert.assertTrue(optimum.getValue() < 8.0e-4);
-    }
-
-    private static class Rosenbrock implements MultivariateFunction {
-        private int count;
-
-        public Rosenbrock() {
-            count = 0;
-        }
-
-        public double value(double[] x) {
-            ++count;
-            double a = x[1] - x[0] * x[0];
-            double b = 1.0 - x[0];
-            return 100 * a * a + b * b;
-        }
-
-        public int getCount() {
-            return count;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/PointValuePairTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/PointValuePairTest.java b/src/test/java/org/apache/commons/math4/optimization/PointValuePairTest.java
deleted file mode 100644
index 558541f..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/PointValuePairTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization;
-
-
-import org.apache.commons.math4.TestUtils;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.junit.Assert;
-import org.junit.Test;
-
-@Deprecated
-public class PointValuePairTest {
-
-    @Test
-    public void testSerial() {
-        PointValuePair pv1 = new PointValuePair(new double[] { 1.0, 2.0, 3.0 }, 4.0);
-        PointValuePair pv2 = (PointValuePair) TestUtils.serializeAndRecover(pv1);
-        Assert.assertEquals(pv1.getKey().length, pv2.getKey().length);
-        for (int i = 0; i < pv1.getKey().length; ++i) {
-            Assert.assertEquals(pv1.getKey()[i], pv2.getKey()[i], 1.0e-15);
-        }
-        Assert.assertEquals(pv1.getValue(), pv2.getValue(), 1.0e-15);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/PointVectorValuePairTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/PointVectorValuePairTest.java b/src/test/java/org/apache/commons/math4/optimization/PointVectorValuePairTest.java
deleted file mode 100644
index 9d59f73..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/PointVectorValuePairTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.math4.optimization;
-
-
-import org.apache.commons.math4.TestUtils;
-import org.apache.commons.math4.optimization.PointVectorValuePair;
-import org.junit.Assert;
-import org.junit.Test;
-
-@Deprecated
-public class PointVectorValuePairTest {
-
-    @Test
-    public void testSerial() {
-        PointVectorValuePair pv1 = new PointVectorValuePair(new double[] { 1.0, 2.0, 3.0 },
-                                                            new double[] { 4.0, 5.0 });
-        PointVectorValuePair pv2 = (PointVectorValuePair) TestUtils.serializeAndRecover(pv1);
-        Assert.assertEquals(pv1.getKey().length, pv2.getKey().length);
-        for (int i = 0; i < pv1.getKey().length; ++i) {
-            Assert.assertEquals(pv1.getKey()[i], pv2.getKey()[i], 1.0e-15);
-        }
-        Assert.assertEquals(pv1.getValue().length, pv2.getValue().length);
-        for (int i = 0; i < pv1.getValue().length; ++i) {
-            Assert.assertEquals(pv1.getValue()[i], pv2.getValue()[i], 1.0e-15);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/SimplePointCheckerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/SimplePointCheckerTest.java b/src/test/java/org/apache/commons/math4/optimization/SimplePointCheckerTest.java
deleted file mode 100644
index 44238ca..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/SimplePointCheckerTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.optimization;
-
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.optimization.SimplePointChecker;
-import org.junit.Test;
-import org.junit.Assert;
-
-@Deprecated
-public class SimplePointCheckerTest {
-    @Test(expected=NotStrictlyPositiveException.class)
-    public void testIterationCheckPrecondition() {
-        new SimplePointChecker<PointValuePair>(1e-1, 1e-2, 0);
-    }
-
-    @Test
-    public void testIterationCheck() {
-        final int max = 10;
-        final SimplePointChecker<PointValuePair> checker
-            = new SimplePointChecker<PointValuePair>(1e-1, 1e-2, max);
-        Assert.assertTrue(checker.converged(max, null, null)); 
-        Assert.assertTrue(checker.converged(max + 1, null, null));
-    }
-
-    @Test
-    public void testIterationCheckDisabled() {
-        final SimplePointChecker<PointValuePair> checker
-            = new SimplePointChecker<PointValuePair>(1e-8, 1e-8);
-
-        final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d);
-        final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d);
-
-        Assert.assertFalse(checker.converged(-1, a, b));
-        Assert.assertFalse(checker.converged(0, a, b));
-        Assert.assertFalse(checker.converged(1000000, a, b));
-
-        Assert.assertTrue(checker.converged(-1, a, a));
-        Assert.assertTrue(checker.converged(-1, b, b));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/SimpleValueCheckerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/SimpleValueCheckerTest.java b/src/test/java/org/apache/commons/math4/optimization/SimpleValueCheckerTest.java
deleted file mode 100644
index 53b0d13..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/SimpleValueCheckerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.optimization;
-
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.optimization.SimpleValueChecker;
-import org.junit.Test;
-import org.junit.Assert;
-
-@Deprecated
-public class SimpleValueCheckerTest {
-    @Test(expected=NotStrictlyPositiveException.class)
-    public void testIterationCheckPrecondition() {
-        new SimpleValueChecker(1e-1, 1e-2, 0);
-    }
-
-    @Test
-    public void testIterationCheck() {
-        final int max = 10;
-        final SimpleValueChecker checker = new SimpleValueChecker(1e-1, 1e-2, max);
-        Assert.assertTrue(checker.converged(max, null, null)); 
-        Assert.assertTrue(checker.converged(max + 1, null, null));
-    }
-
-    @Test
-    public void testIterationCheckDisabled() {
-        final SimpleValueChecker checker = new SimpleValueChecker(1e-8, 1e-8);
-
-        final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d);
-        final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d);
-
-        Assert.assertFalse(checker.converged(-1, a, b));
-        Assert.assertFalse(checker.converged(0, a, b));
-        Assert.assertFalse(checker.converged(1000000, a, b));
-
-        Assert.assertTrue(checker.converged(-1, a, a));
-        Assert.assertTrue(checker.converged(-1, b, b));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/SimpleVectorValueCheckerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/SimpleVectorValueCheckerTest.java b/src/test/java/org/apache/commons/math4/optimization/SimpleVectorValueCheckerTest.java
deleted file mode 100644
index abe807a..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/SimpleVectorValueCheckerTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.optimization;
-
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.optimization.PointVectorValuePair;
-import org.apache.commons.math4.optimization.SimpleVectorValueChecker;
-import org.junit.Test;
-import org.junit.Assert;
-
-@Deprecated
-public class SimpleVectorValueCheckerTest {
-    @Test(expected=NotStrictlyPositiveException.class)
-    public void testIterationCheckPrecondition() {
-        new SimpleVectorValueChecker(1e-1, 1e-2, 0);
-    }
-
-    @Test
-    public void testIterationCheck() {
-        final int max = 10;
-        final SimpleVectorValueChecker checker = new SimpleVectorValueChecker(1e-1, 1e-2, max);
-        Assert.assertTrue(checker.converged(max, null, null));
-        Assert.assertTrue(checker.converged(max + 1, null, null));
-    }
-
-    @Test
-    public void testIterationCheckDisabled() {
-        final SimpleVectorValueChecker checker = new SimpleVectorValueChecker(1e-8, 1e-8);
-
-        final PointVectorValuePair a = new PointVectorValuePair(new double[] { 1d },
-                                                                new double[] { 1d });
-        final PointVectorValuePair b = new PointVectorValuePair(new double[] { 10d },
-                                                                new double[] { 10d });
-
-        Assert.assertFalse(checker.converged(-1, a, b));
-        Assert.assertFalse(checker.converged(0, a, b));
-        Assert.assertFalse(checker.converged(1000000, a, b));
-
-        Assert.assertTrue(checker.converged(-1, a, a));
-        Assert.assertTrue(checker.converged(-1, b, b));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/test/java/org/apache/commons/math4/optimization/direct/BOBYQAOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/optimization/direct/BOBYQAOptimizerTest.java b/src/test/java/org/apache/commons/math4/optimization/direct/BOBYQAOptimizerTest.java
deleted file mode 100644
index add96f3..0000000
--- a/src/test/java/org/apache/commons/math4/optimization/direct/BOBYQAOptimizerTest.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.optimization.direct;
-
-import java.util.Arrays;
-import java.util.Random;
-
-import org.apache.commons.math4.analysis.MultivariateFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.optimization.InitialGuess;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.optimization.SimpleBounds;
-import org.apache.commons.math4.optimization.direct.BOBYQAOptimizer;
-import org.apache.commons.math4.util.FastMath;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test for {@link BOBYQAOptimizer}.
- */
-@Deprecated
-public class BOBYQAOptimizerTest {
-
-    static final int DIM = 13;
-   
-    @Test(expected=NumberIsTooLargeException.class)
-    public void testInitOutOfBounds() {
-        double[] startPoint = point(DIM, 3);
-        double[][] boundaries = boundaries(DIM, -1, 2);
-        doTest(new Rosen(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 2000, null);
-    }
-    
-    @Test(expected=DimensionMismatchException.class)
-    public void testBoundariesDimensionMismatch() {
-        double[] startPoint = point(DIM, 0.5);
-        double[][] boundaries = boundaries(DIM + 1, -1, 2);
-        doTest(new Rosen(), startPoint, boundaries,
-               GoalType.MINIMIZE, 
-               1e-13, 1e-6, 2000, null);
-    }
-
-    @Test(expected=NumberIsTooSmallException.class)
-    public void testProblemDimensionTooSmall() {
-        double[] startPoint = point(1, 0.5);
-        doTest(new Rosen(), startPoint, null,
-               GoalType.MINIMIZE,
-               1e-13, 1e-6, 2000, null);
-    }
-
-    @Test(expected=TooManyEvaluationsException.class)
-    public void testMaxEvaluations() {
-        final int lowMaxEval = 2;
-        double[] startPoint = point(DIM, 0.1);
-        double[][] boundaries = null;
-        doTest(new Rosen(), startPoint, boundaries,
-               GoalType.MINIMIZE, 
-               1e-13, 1e-6, lowMaxEval, null);
-     }
-
-    @Test
-    public void testRosen() {
-        double[] startPoint = point(DIM,0.1);
-        double[][] boundaries = null;
-        PointValuePair expected = new PointValuePair(point(DIM,1.0),0.0);
-        doTest(new Rosen(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 2000, expected);
-     }
-
-    @Test
-    public void testMaximize() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected = new PointValuePair(point(DIM,0.0),1.0);
-        doTest(new MinusElli(), startPoint, boundaries,
-                GoalType.MAXIMIZE, 
-                2e-10, 5e-6, 1000, expected);
-        boundaries = boundaries(DIM,-0.3,0.3); 
-        startPoint = point(DIM,0.1);
-        doTest(new MinusElli(), startPoint, boundaries,
-                GoalType.MAXIMIZE, 
-                2e-10, 5e-6, 1000, expected);
-    }
-
-    @Test
-    public void testEllipse() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Elli(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 1000, expected);
-     }
-
-    @Test
-    public void testElliRotated() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new ElliRotated(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-12, 1e-6, 10000, expected);
-    }
-
-    @Test
-    public void testCigar() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Cigar(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 100, expected);
-    }
-
-    @Test
-    public void testTwoAxes() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new TwoAxes(), startPoint, boundaries,
-                GoalType.MINIMIZE, 2*
-                1e-13, 1e-6, 100, expected);
-     }
-
-    @Test
-    public void testCigTab() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new CigTab(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 5e-5, 100, expected);
-     }
-
-    @Test
-    public void testSphere() {
-        double[] startPoint = point(DIM,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Sphere(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 100, expected);
-    }
-
-    @Test
-    public void testTablet() {
-        double[] startPoint = point(DIM,1.0); 
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Tablet(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 100, expected);
-    }
-
-    @Test
-    public void testDiffPow() {
-        double[] startPoint = point(DIM/2,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM/2,0.0),0.0);
-        doTest(new DiffPow(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-8, 1e-1, 12000, expected);
-    }
-
-    @Test
-    public void testSsDiffPow() {
-        double[] startPoint = point(DIM/2,1.0);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM/2,0.0),0.0);
-        doTest(new SsDiffPow(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-2, 1.3e-1, 50000, expected);
-    }
-
-    @Test
-    public void testAckley() {
-        double[] startPoint = point(DIM,0.1);
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Ackley(), startPoint, boundaries,
-                GoalType.MINIMIZE,
-                1e-7, 1e-5, 1000, expected);
-    }
-
-    @Test
-    public void testRastrigin() {
-        double[] startPoint = point(DIM,1.0);
-
-        double[][] boundaries = null;
-        PointValuePair expected =
-            new PointValuePair(point(DIM,0.0),0.0);
-        doTest(new Rastrigin(), startPoint, boundaries,
-                GoalType.MINIMIZE, 
-                1e-13, 1e-6, 1000, expected);
-    }
-
-    @Test
-    public void testConstrainedRosen() {
-        double[] startPoint = point(DIM,0.1);
-
-        double[][] boundaries = boundaries(DIM,-1,2);
-        PointValuePair expected =
-            new PointValuePair(point(DIM,1.0),0.0);
-        doTest(new Rosen(), startPoint, boundaries,
-                GoalType.MINIMIZE,
-                1e-13, 1e-6, 2000, expected);
-    }
-
-    // See MATH-728
-    // TODO: this test is temporarily disabled for 3.2 release as a bug in Cobertura
-    //       makes it run for several hours before completing
-    @Ignore @Test
-    public void testConstrainedRosenWithMoreInterpolationPoints() {
-        final double[] startPoint = point(DIM, 0.1);
-        final double[][] boundaries = boundaries(DIM, -1, 2);
-        final PointValuePair expected = new PointValuePair(point(DIM, 1.0), 0.0);
-
-        // This should have been 78 because in the code the hard limit is
-        // said to be
-        //   ((DIM + 1) * (DIM + 2)) / 2 - (2 * DIM + 1)
-        // i.e. 78 in this case, but the test fails for 48, 59, 62, 63, 64,
-        // 65, 66, ...
-        final int maxAdditionalPoints = 47;
-
-        for (int num = 1; num <= maxAdditionalPoints; num++) {
-            doTest(new Rosen(), startPoint, boundaries,
-                   GoalType.MINIMIZE,
-                   1e-12, 1e-6, 2000,
-                   num,
-                   expected,
-                   "num=" + num);
-        }
-    }
-
-    /**
-     * @param func Function to optimize.
-     * @param startPoint Starting point.
-     * @param boundaries Upper / lower point limit.
-     * @param goal Minimization or maximization.
-     * @param fTol Tolerance relative error on the objective function.
-     * @param pointTol Tolerance for checking that the optimum is correct.
-     * @param maxEvaluations Maximum number of evaluations.
-     * @param expected Expected point / value.
-     */
-    private void doTest(MultivariateFunction func,
-                        double[] startPoint,
-                        double[][] boundaries,
-                        GoalType goal,
-                        double fTol,
-                        double pointTol,
-                        int maxEvaluations,
-                        PointValuePair expected) {
-        doTest(func,
-               startPoint,
-               boundaries,
-               goal,
-               fTol,
-               pointTol,
-               maxEvaluations,
-               0,
-               expected,
-               "");
-    }
-
-    /**
-     * @param func Function to optimize.
-     * @param startPoint Starting point.
-     * @param boundaries Upper / lower point limit.
-     * @param goal Minimization or maximization.
-     * @param fTol Tolerance relative error on the objective function.
-     * @param pointTol Tolerance for checking that the optimum is correct.
-     * @param maxEvaluations Maximum number of evaluations.
-     * @param additionalInterpolationPoints Number of interpolation to used
-     * in addition to the default (2 * dim + 1).
-     * @param expected Expected point / value.
-     */
-    private void doTest(MultivariateFunction func,
-                        double[] startPoint,
-                        double[][] boundaries,
-                        GoalType goal,
-                        double fTol,
-                        double pointTol,
-                        int maxEvaluations,
-                        int additionalInterpolationPoints,
-                        PointValuePair expected,
-                        String assertMsg) {
-
-//         System.out.println(func.getClass().getName() + " BEGIN"); // XXX
-
-        int dim = startPoint.length;
-//        MultivariateOptimizer optim =
-//            new PowellOptimizer(1e-13, FastMath.ulp(1d));
-//        PointValuePair result = optim.optimize(100000, func, goal, startPoint);
-        final double[] lB = boundaries == null ? null : boundaries[0];
-        final double[] uB = boundaries == null ? null : boundaries[1];
-        final int numIterpolationPoints = 2 * dim + 1 + additionalInterpolationPoints;
-        BOBYQAOptimizer optim = new BOBYQAOptimizer(numIterpolationPoints);
-        PointValuePair result = boundaries == null ?
-            optim.optimize(maxEvaluations, func, goal,
-                           new InitialGuess(startPoint)) :
-            optim.optimize(maxEvaluations, func, goal,
-                           new InitialGuess(startPoint),
-                           new SimpleBounds(lB, uB));
-//        System.out.println(func.getClass().getName() + " = " 
-//              + optim.getEvaluations() + " f(");
-//        for (double x: result.getPoint())  System.out.print(x + " ");
-//        System.out.println(") = " +  result.getValue());
-        Assert.assertEquals(assertMsg, expected.getValue(), result.getValue(), fTol);
-        for (int i = 0; i < dim; i++) {
-            Assert.assertEquals(expected.getPoint()[i],
-                                result.getPoint()[i], pointTol);
-        }
-
-//         System.out.println(func.getClass().getName() + " END"); // XXX
-    }
-
-    private static double[] point(int n, double value) {
-        double[] ds = new double[n];
-        Arrays.fill(ds, value);
-        return ds;
-    }
-
-    private static double[][] boundaries(int dim,
-            double lower, double upper) {
-        double[][] boundaries = new double[2][dim];
-        for (int i = 0; i < dim; i++)
-            boundaries[0][i] = lower;
-        for (int i = 0; i < dim; i++)
-            boundaries[1][i] = upper;
-        return boundaries;
-    }
-
-    private static class Sphere implements MultivariateFunction {
-
-        public double value(double[] x) {
-            double f = 0;
-            for (int i = 0; i < x.length; ++i)
-                f += x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class Cigar implements MultivariateFunction {
-        private double factor;
-
-        Cigar() {
-            this(1e3);
-        }
-
-        Cigar(double axisratio) {
-            factor = axisratio * axisratio;
-        }
-
-        public double value(double[] x) {
-            double f = x[0] * x[0];
-            for (int i = 1; i < x.length; ++i)
-                f += factor * x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class Tablet implements MultivariateFunction {
-        private double factor;
-
-        Tablet() {
-            this(1e3);
-        }
-
-        Tablet(double axisratio) {
-            factor = axisratio * axisratio;
-        }
-
-        public double value(double[] x) {
-            double f = factor * x[0] * x[0];
-            for (int i = 1; i < x.length; ++i)
-                f += x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class CigTab implements MultivariateFunction {
-        private double factor;
-
-        CigTab() {
-            this(1e4);
-        }
-
-        CigTab(double axisratio) {
-            factor = axisratio;
-        }
-
-        public double value(double[] x) {
-            int end = x.length - 1;
-            double f = x[0] * x[0] / factor + factor * x[end] * x[end];
-            for (int i = 1; i < end; ++i)
-                f += x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class TwoAxes implements MultivariateFunction {
-
-        private double factor;
-
-        TwoAxes() {
-            this(1e6);
-        }
-
-        TwoAxes(double axisratio) {
-            factor = axisratio * axisratio;
-        }
-
-        public double value(double[] x) {
-            double f = 0;
-            for (int i = 0; i < x.length; ++i)
-                f += (i < x.length / 2 ? factor : 1) * x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class ElliRotated implements MultivariateFunction {
-        private Basis B = new Basis();
-        private double factor;
-
-        ElliRotated() {
-            this(1e3);
-        }
-
-        ElliRotated(double axisratio) {
-            factor = axisratio * axisratio;
-        }
-
-        public double value(double[] x) {
-            double f = 0;
-            x = B.Rotate(x);
-            for (int i = 0; i < x.length; ++i)
-                f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class Elli implements MultivariateFunction {
-
-        private double factor;
-
-        Elli() {
-            this(1e3);
-        }
-
-        Elli(double axisratio) {
-            factor = axisratio * axisratio;
-        }
-
-        public double value(double[] x) {
-            double f = 0;
-            for (int i = 0; i < x.length; ++i)
-                f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
-            return f;
-        }
-    }
-
-    private static class MinusElli implements MultivariateFunction {
-        private final Elli elli = new Elli();
-        public double value(double[] x) {
-            return 1.0 - elli.value(x);
-        }
-    }
-
-    private static class DiffPow implements MultivariateFunction {
-//        private int fcount = 0;
-        public double value(double[] x) {
-            double f = 0;
-            for (int i = 0; i < x.length; ++i)
-                f += FastMath.pow(FastMath.abs(x[i]), 2. + 10 * (double) i
-                        / (x.length - 1.));
-//            System.out.print("" + (fcount++) + ") ");
-//            for (int i = 0; i < x.length; i++)
-//                System.out.print(x[i] +  " ");
-//            System.out.println(" = " + f);
-            return f;
-        }
-    }
-
-    private static class SsDiffPow implements MultivariateFunction {
-
-        public double value(double[] x) {
-            double f = FastMath.pow(new DiffPow().value(x), 0.25);
-            return f;
-        }
-    }
-
-    private static class Rosen implements MultivariateFunction {
-
-        public double value(double[] x) {
-            double f = 0;
-            for (int i = 0; i < x.length - 1; ++i)
-                f += 1e2 * (x[i] * x[i] - x[i + 1]) * (x[i] * x[i] - x[i + 1])
-                + (x[i] - 1.) * (x[i] - 1.);
-            return f;
-        }
-    }
-
-    private static class Ackley implements MultivariateFunction {
-        private double axisratio;
-
-        Ackley(double axra) {
-            axisratio = axra;
-        }
-
-        public Ackley() {
-            this(1);
-        }
-
-        public double value(double[] x) {
-            double f = 0;
-            double res2 = 0;
-            double fac = 0;
-            for (int i = 0; i < x.length; ++i) {
-                fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
-                f += fac * fac * x[i] * x[i];
-                res2 += FastMath.cos(2. * FastMath.PI * fac * x[i]);
-            }
-            f = (20. - 20. * FastMath.exp(-0.2 * FastMath.sqrt(f / x.length))
-                    + FastMath.exp(1.) - FastMath.exp(res2 / x.length));
-            return f;
-        }
-    }
-
-    private static class Rastrigin implements MultivariateFunction {
-
-        private double axisratio;
-        private double amplitude;
-
-        Rastrigin() {
-            this(1, 10);
-        }
-
-        Rastrigin(double axisratio, double amplitude) {
-            this.axisratio = axisratio;
-            this.amplitude = amplitude;
-        }
-
-        public double value(double[] x) {
-            double f = 0;
-            double fac;
-            for (int i = 0; i < x.length; ++i) {
-                fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
-                if (i == 0 && x[i] < 0)
-                    fac *= 1.;
-                f += fac * fac * x[i] * x[i] + amplitude
-                * (1. - FastMath.cos(2. * FastMath.PI * fac * x[i]));
-            }
-            return f;
-        }
-    }
-
-    private static class Basis {
-        double[][] basis;
-        Random rand = new Random(2); // use not always the same basis
-
-        double[] Rotate(double[] x) {
-            GenBasis(x.length);
-            double[] y = new double[x.length];
-            for (int i = 0; i < x.length; ++i) {
-                y[i] = 0;
-                for (int j = 0; j < x.length; ++j)
-                    y[i] += basis[i][j] * x[j];
-            }
-            return y;
-        }
-
-        void GenBasis(int DIM) {
-            if (basis != null ? basis.length == DIM : false)
-                return;
-
-            double sp;
-            int i, j, k;
-
-            /* generate orthogonal basis */
-            basis = new double[DIM][DIM];
-            for (i = 0; i < DIM; ++i) {
-                /* sample components gaussian */
-                for (j = 0; j < DIM; ++j)
-                    basis[i][j] = rand.nextGaussian();
-                /* substract projection of previous vectors */
-                for (j = i - 1; j >= 0; --j) {
-                    for (sp = 0., k = 0; k < DIM; ++k)
-                        sp += basis[i][k] * basis[j][k]; /* scalar product */
-                    for (k = 0; k < DIM; ++k)
-                        basis[i][k] -= sp * basis[j][k]; /* substract */
-                }
-                /* normalize */
-                for (sp = 0., k = 0; k < DIM; ++k)
-                    sp += basis[i][k] * basis[i][k]; /* squared norm */
-                for (k = 0; k < DIM; ++k)
-                    basis[i][k] /= FastMath.sqrt(sp);
-            }
-        }
-    }
-}


Mime
View raw message