commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject [09/18] [math] Remove deprecated optimization package.
Date Wed, 25 Feb 2015 21:49:37 GMT
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/linear/Relationship.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/linear/Relationship.java b/src/main/java/org/apache/commons/math4/optimization/linear/Relationship.java
deleted file mode 100644
index 7675694..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/linear/Relationship.java
+++ /dev/null
@@ -1,67 +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.linear;
-
-/**
- * Types of relationships between two cells in a Solver {@link LinearConstraint}.
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-public enum Relationship {
-
-    /** Equality relationship. */
-    EQ("="),
-
-    /** Lesser than or equal relationship. */
-    LEQ("<="),
-
-    /** Greater than or equal relationship. */
-    GEQ(">=");
-
-    /** Display string for the relationship. */
-    private final String stringValue;
-
-    /** Simple constructor.
-     * @param stringValue display string for the relationship
-     */
-    private Relationship(String stringValue) {
-        this.stringValue = stringValue;
-    }
-
-    @Override
-    public String toString() {
-        return stringValue;
-    }
-
-    /**
-     * Get the relationship obtained when multiplying all coefficients by -1.
-     * @return relationship obtained when multiplying all coefficients by -1
-     */
-    public Relationship oppositeRelationship() {
-        switch (this) {
-        case LEQ :
-            return GEQ;
-        case GEQ :
-            return LEQ;
-        default :
-            return EQ;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/linear/SimplexSolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/linear/SimplexSolver.java b/src/main/java/org/apache/commons/math4/optimization/linear/SimplexSolver.java
deleted file mode 100644
index 23db158..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/linear/SimplexSolver.java
+++ /dev/null
@@ -1,238 +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.linear;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.util.Precision;
-
-
-/**
- * Solves a linear problem using the Two-Phase Simplex Method.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-public class SimplexSolver extends AbstractLinearOptimizer {
-
-    /** Default amount of error to accept for algorithm convergence. */
-    private static final double DEFAULT_EPSILON = 1.0e-6;
-
-    /** Default amount of error to accept in floating point comparisons (as ulps). */
-    private static final int DEFAULT_ULPS = 10;
-
-    /** Amount of error to accept for algorithm convergence. */
-    private final double epsilon;
-
-    /** Amount of error to accept in floating point comparisons (as ulps). */
-    private final int maxUlps;
-
-    /**
-     * Build a simplex solver with default settings.
-     */
-    public SimplexSolver() {
-        this(DEFAULT_EPSILON, DEFAULT_ULPS);
-    }
-
-    /**
-     * Build a simplex solver with a specified accepted amount of error
-     * @param epsilon the amount of error to accept for algorithm convergence
-     * @param maxUlps amount of error to accept in floating point comparisons
-     */
-    public SimplexSolver(final double epsilon, final int maxUlps) {
-        this.epsilon = epsilon;
-        this.maxUlps = maxUlps;
-    }
-
-    /**
-     * Returns the column with the most negative coefficient in the objective function row.
-     * @param tableau simple tableau for the problem
-     * @return column with the most negative coefficient
-     */
-    private Integer getPivotColumn(SimplexTableau tableau) {
-        double minValue = 0;
-        Integer minPos = null;
-        for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getWidth() - 1; i++) {
-            final double entry = tableau.getEntry(0, i);
-            // check if the entry is strictly smaller than the current minimum
-            // do not use a ulp/epsilon check
-            if (entry < minValue) {
-                minValue = entry;
-                minPos = i;
-            }
-        }
-        return minPos;
-    }
-
-    /**
-     * Returns the row with the minimum ratio as given by the minimum ratio test (MRT).
-     * @param tableau simple tableau for the problem
-     * @param col the column to test the ratio of.  See {@link #getPivotColumn(SimplexTableau)}
-     * @return row with the minimum ratio
-     */
-    private Integer getPivotRow(SimplexTableau tableau, final int col) {
-        // create a list of all the rows that tie for the lowest score in the minimum ratio test
-        List<Integer> minRatioPositions = new ArrayList<Integer>();
-        double minRatio = Double.MAX_VALUE;
-        for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {
-            final double rhs = tableau.getEntry(i, tableau.getWidth() - 1);
-            final double entry = tableau.getEntry(i, col);
-
-            if (Precision.compareTo(entry, 0d, maxUlps) > 0) {
-                final double ratio = rhs / entry;
-                // check if the entry is strictly equal to the current min ratio
-                // do not use a ulp/epsilon check
-                final int cmp = Double.compare(ratio, minRatio);
-                if (cmp == 0) {
-                    minRatioPositions.add(i);
-                } else if (cmp < 0) {
-                    minRatio = ratio;
-                    minRatioPositions = new ArrayList<Integer>();
-                    minRatioPositions.add(i);
-                }
-            }
-        }
-
-        if (minRatioPositions.size() == 0) {
-            return null;
-        } else if (minRatioPositions.size() > 1) {
-            // there's a degeneracy as indicated by a tie in the minimum ratio test
-
-            // 1. check if there's an artificial variable that can be forced out of the basis
-            if (tableau.getNumArtificialVariables() > 0) {
-                for (Integer row : minRatioPositions) {
-                    for (int i = 0; i < tableau.getNumArtificialVariables(); i++) {
-                        int column = i + tableau.getArtificialVariableOffset();
-                        final double entry = tableau.getEntry(row, column);
-                        if (Precision.equals(entry, 1d, maxUlps) && row.equals(tableau.getBasicRow(column))) {
-                            return row;
-                        }
-                    }
-                }
-            }
-
-            // 2. apply Bland's rule to prevent cycling:
-            //    take the row for which the corresponding basic variable has the smallest index
-            //
-            // see http://www.stanford.edu/class/msande310/blandrule.pdf
-            // see http://en.wikipedia.org/wiki/Bland%27s_rule (not equivalent to the above paper)
-            //
-            // Additional heuristic: if we did not get a solution after half of maxIterations
-            //                       revert to the simple case of just returning the top-most row
-            // This heuristic is based on empirical data gathered while investigating MATH-828.
-            if (getIterations() < getMaxIterations() / 2) {
-                Integer minRow = null;
-                int minIndex = tableau.getWidth();
-                final int varStart = tableau.getNumObjectiveFunctions();
-                final int varEnd = tableau.getWidth() - 1;
-                for (Integer row : minRatioPositions) {
-                    for (int i = varStart; i < varEnd && !row.equals(minRow); i++) {
-                        final Integer basicRow = tableau.getBasicRow(i);
-                        if (basicRow != null && basicRow.equals(row) && i < minIndex) {
-                            minIndex = i;
-                            minRow = row;
-                        }
-                    }
-                }
-                return minRow;
-            }
-        }
-        return minRatioPositions.get(0);
-    }
-
-    /**
-     * Runs one iteration of the Simplex method on the given model.
-     * @param tableau simple tableau for the problem
-     * @throws MaxCountExceededException if the maximal iteration count has been exceeded
-     * @throws UnboundedSolutionException if the model is found not to have a bounded solution
-     */
-    protected void doIteration(final SimplexTableau tableau)
-        throws MaxCountExceededException, UnboundedSolutionException {
-
-        incrementIterationsCounter();
-
-        Integer pivotCol = getPivotColumn(tableau);
-        Integer pivotRow = getPivotRow(tableau, pivotCol);
-        if (pivotRow == null) {
-            throw new UnboundedSolutionException();
-        }
-
-        // set the pivot element to 1
-        double pivotVal = tableau.getEntry(pivotRow, pivotCol);
-        tableau.divideRow(pivotRow, pivotVal);
-
-        // set the rest of the pivot column to 0
-        for (int i = 0; i < tableau.getHeight(); i++) {
-            if (i != pivotRow) {
-                final double multiplier = tableau.getEntry(i, pivotCol);
-                tableau.subtractRow(i, pivotRow, multiplier);
-            }
-        }
-    }
-
-    /**
-     * Solves Phase 1 of the Simplex method.
-     * @param tableau simple tableau for the problem
-     * @throws MaxCountExceededException if the maximal iteration count has been exceeded
-     * @throws UnboundedSolutionException if the model is found not to have a bounded solution
-     * @throws NoFeasibleSolutionException if there is no feasible solution
-     */
-    protected void solvePhase1(final SimplexTableau tableau)
-        throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {
-
-        // make sure we're in Phase 1
-        if (tableau.getNumArtificialVariables() == 0) {
-            return;
-        }
-
-        while (!tableau.isOptimal()) {
-            doIteration(tableau);
-        }
-
-        // if W is not zero then we have no feasible solution
-        if (!Precision.equals(tableau.getEntry(0, tableau.getRhsOffset()), 0d, epsilon)) {
-            throw new NoFeasibleSolutionException();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public PointValuePair doOptimize()
-        throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {
-        final SimplexTableau tableau =
-            new SimplexTableau(getFunction(),
-                               getConstraints(),
-                               getGoalType(),
-                               restrictToNonNegative(),
-                               epsilon,
-                               maxUlps);
-
-        solvePhase1(tableau);
-        tableau.dropPhase1Objective();
-
-        while (!tableau.isOptimal()) {
-            doIteration(tableau);
-        }
-        return tableau.getSolution();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/linear/SimplexTableau.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/linear/SimplexTableau.java b/src/main/java/org/apache/commons/math4/optimization/linear/SimplexTableau.java
deleted file mode 100644
index 16f07ef..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/linear/SimplexTableau.java
+++ /dev/null
@@ -1,635 +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.linear;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.commons.math4.linear.Array2DRowRealMatrix;
-import org.apache.commons.math4.linear.MatrixUtils;
-import org.apache.commons.math4.linear.RealMatrix;
-import org.apache.commons.math4.linear.RealVector;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.optimization.PointValuePair;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.Precision;
-
-/**
- * A tableau for use in the Simplex method.
- *
- * <p>
- * Example:
- * <pre>
- *   W |  Z |  x1 |  x2 |  x- | s1 |  s2 |  a1 |  RHS
- * ---------------------------------------------------
- *  -1    0    0     0     0     0     0     1     0   &lt;= phase 1 objective
- *   0    1   -15   -10    0     0     0     0     0   &lt;= phase 2 objective
- *   0    0    1     0     0     1     0     0     2   &lt;= constraint 1
- *   0    0    0     1     0     0     1     0     3   &lt;= constraint 2
- *   0    0    1     1     0     0     0     1     4   &lt;= constraint 3
- * </pre>
- * W: Phase 1 objective function</br>
- * Z: Phase 2 objective function</br>
- * x1 &amp; x2: Decision variables</br>
- * x-: Extra decision variable to allow for negative values</br>
- * s1 &amp; s2: Slack/Surplus variables</br>
- * a1: Artificial variable</br>
- * RHS: Right hand side</br>
- * </p>
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-class SimplexTableau implements Serializable {
-
-    /** Column label for negative vars. */
-    private static final String NEGATIVE_VAR_COLUMN_LABEL = "x-";
-
-    /** Default amount of error to accept in floating point comparisons (as ulps). */
-    private static final int DEFAULT_ULPS = 10;
-
-    /** The cut-off threshold to zero-out entries. */
-    private static final double CUTOFF_THRESHOLD = 1e-12;
-
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = -1369660067587938365L;
-
-    /** Linear objective function. */
-    private final LinearObjectiveFunction f;
-
-    /** Linear constraints. */
-    private final List<LinearConstraint> constraints;
-
-    /** Whether to restrict the variables to non-negative values. */
-    private final boolean restrictToNonNegative;
-
-    /** The variables each column represents */
-    private final List<String> columnLabels = new ArrayList<String>();
-
-    /** Simple tableau. */
-    private transient RealMatrix tableau;
-
-    /** Number of decision variables. */
-    private final int numDecisionVariables;
-
-    /** Number of slack variables. */
-    private final int numSlackVariables;
-
-    /** Number of artificial variables. */
-    private int numArtificialVariables;
-
-    /** Amount of error to accept when checking for optimality. */
-    private final double epsilon;
-
-    /** Amount of error to accept in floating point comparisons. */
-    private final int maxUlps;
-
-    /**
-     * Build a tableau for a linear problem.
-     * @param f linear objective function
-     * @param constraints linear constraints
-     * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
-     * @param restrictToNonNegative whether to restrict the variables to non-negative values
-     * @param epsilon amount of error to accept when checking for optimality
-     */
-    SimplexTableau(final LinearObjectiveFunction f,
-                   final Collection<LinearConstraint> constraints,
-                   final GoalType goalType, final boolean restrictToNonNegative,
-                   final double epsilon) {
-        this(f, constraints, goalType, restrictToNonNegative, epsilon, DEFAULT_ULPS);
-    }
-
-    /**
-     * Build a tableau for a linear problem.
-     * @param f linear objective function
-     * @param constraints linear constraints
-     * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
-     * @param restrictToNonNegative whether to restrict the variables to non-negative values
-     * @param epsilon amount of error to accept when checking for optimality
-     * @param maxUlps amount of error to accept in floating point comparisons
-     */
-    SimplexTableau(final LinearObjectiveFunction f,
-                   final Collection<LinearConstraint> constraints,
-                   final GoalType goalType, final boolean restrictToNonNegative,
-                   final double epsilon,
-                   final int maxUlps) {
-        this.f                      = f;
-        this.constraints            = normalizeConstraints(constraints);
-        this.restrictToNonNegative  = restrictToNonNegative;
-        this.epsilon                = epsilon;
-        this.maxUlps                = maxUlps;
-        this.numDecisionVariables   = f.getCoefficients().getDimension() +
-                                      (restrictToNonNegative ? 0 : 1);
-        this.numSlackVariables      = getConstraintTypeCounts(Relationship.LEQ) +
-                                      getConstraintTypeCounts(Relationship.GEQ);
-        this.numArtificialVariables = getConstraintTypeCounts(Relationship.EQ) +
-                                      getConstraintTypeCounts(Relationship.GEQ);
-        this.tableau = createTableau(goalType == GoalType.MAXIMIZE);
-        initializeColumnLabels();
-    }
-
-    /**
-     * Initialize the labels for the columns.
-     */
-    protected void initializeColumnLabels() {
-      if (getNumObjectiveFunctions() == 2) {
-        columnLabels.add("W");
-      }
-      columnLabels.add("Z");
-      for (int i = 0; i < getOriginalNumDecisionVariables(); i++) {
-        columnLabels.add("x" + i);
-      }
-      if (!restrictToNonNegative) {
-        columnLabels.add(NEGATIVE_VAR_COLUMN_LABEL);
-      }
-      for (int i = 0; i < getNumSlackVariables(); i++) {
-        columnLabels.add("s" + i);
-      }
-      for (int i = 0; i < getNumArtificialVariables(); i++) {
-        columnLabels.add("a" + i);
-      }
-      columnLabels.add("RHS");
-    }
-
-    /**
-     * Create the tableau by itself.
-     * @param maximize if true, goal is to maximize the objective function
-     * @return created tableau
-     */
-    protected RealMatrix createTableau(final boolean maximize) {
-
-        // create a matrix of the correct size
-        int width = numDecisionVariables + numSlackVariables +
-        numArtificialVariables + getNumObjectiveFunctions() + 1; // + 1 is for RHS
-        int height = constraints.size() + getNumObjectiveFunctions();
-        Array2DRowRealMatrix matrix = new Array2DRowRealMatrix(height, width);
-
-        // initialize the objective function rows
-        if (getNumObjectiveFunctions() == 2) {
-            matrix.setEntry(0, 0, -1);
-        }
-        int zIndex = (getNumObjectiveFunctions() == 1) ? 0 : 1;
-        matrix.setEntry(zIndex, zIndex, maximize ? 1 : -1);
-        RealVector objectiveCoefficients =
-            maximize ? f.getCoefficients().mapMultiply(-1) : f.getCoefficients();
-        copyArray(objectiveCoefficients.toArray(), matrix.getDataRef()[zIndex]);
-        matrix.setEntry(zIndex, width - 1,
-            maximize ? f.getConstantTerm() : -1 * f.getConstantTerm());
-
-        if (!restrictToNonNegative) {
-            matrix.setEntry(zIndex, getSlackVariableOffset() - 1,
-                getInvertedCoefficientSum(objectiveCoefficients));
-        }
-
-        // initialize the constraint rows
-        int slackVar = 0;
-        int artificialVar = 0;
-        for (int i = 0; i < constraints.size(); i++) {
-            LinearConstraint constraint = constraints.get(i);
-            int row = getNumObjectiveFunctions() + i;
-
-            // decision variable coefficients
-            copyArray(constraint.getCoefficients().toArray(), matrix.getDataRef()[row]);
-
-            // x-
-            if (!restrictToNonNegative) {
-                matrix.setEntry(row, getSlackVariableOffset() - 1,
-                    getInvertedCoefficientSum(constraint.getCoefficients()));
-            }
-
-            // RHS
-            matrix.setEntry(row, width - 1, constraint.getValue());
-
-            // slack variables
-            if (constraint.getRelationship() == Relationship.LEQ) {
-                matrix.setEntry(row, getSlackVariableOffset() + slackVar++, 1);  // slack
-            } else if (constraint.getRelationship() == Relationship.GEQ) {
-                matrix.setEntry(row, getSlackVariableOffset() + slackVar++, -1); // excess
-            }
-
-            // artificial variables
-            if ((constraint.getRelationship() == Relationship.EQ) ||
-                    (constraint.getRelationship() == Relationship.GEQ)) {
-                matrix.setEntry(0, getArtificialVariableOffset() + artificialVar, 1);
-                matrix.setEntry(row, getArtificialVariableOffset() + artificialVar++, 1);
-                matrix.setRowVector(0, matrix.getRowVector(0).subtract(matrix.getRowVector(row)));
-            }
-        }
-
-        return matrix;
-    }
-
-    /**
-     * Get new versions of the constraints which have positive right hand sides.
-     * @param originalConstraints original (not normalized) constraints
-     * @return new versions of the constraints
-     */
-    public List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> originalConstraints) {
-        List<LinearConstraint> normalized = new ArrayList<LinearConstraint>(originalConstraints.size());
-        for (LinearConstraint constraint : originalConstraints) {
-            normalized.add(normalize(constraint));
-        }
-        return normalized;
-    }
-
-    /**
-     * Get a new equation equivalent to this one with a positive right hand side.
-     * @param constraint reference constraint
-     * @return new equation
-     */
-    private LinearConstraint normalize(final LinearConstraint constraint) {
-        if (constraint.getValue() < 0) {
-            return new LinearConstraint(constraint.getCoefficients().mapMultiply(-1),
-                                        constraint.getRelationship().oppositeRelationship(),
-                                        -1 * constraint.getValue());
-        }
-        return new LinearConstraint(constraint.getCoefficients(),
-                                    constraint.getRelationship(), constraint.getValue());
-    }
-
-    /**
-     * Get the number of objective functions in this tableau.
-     * @return 2 for Phase 1.  1 for Phase 2.
-     */
-    protected final int getNumObjectiveFunctions() {
-        return this.numArtificialVariables > 0 ? 2 : 1;
-    }
-
-    /**
-     * Get a count of constraints corresponding to a specified relationship.
-     * @param relationship relationship to count
-     * @return number of constraint with the specified relationship
-     */
-    private int getConstraintTypeCounts(final Relationship relationship) {
-        int count = 0;
-        for (final LinearConstraint constraint : constraints) {
-            if (constraint.getRelationship() == relationship) {
-                ++count;
-            }
-        }
-        return count;
-    }
-
-    /**
-     * Get the -1 times the sum of all coefficients in the given array.
-     * @param coefficients coefficients to sum
-     * @return the -1 times the sum of all coefficients in the given array.
-     */
-    protected static double getInvertedCoefficientSum(final RealVector coefficients) {
-        double sum = 0;
-        for (double coefficient : coefficients.toArray()) {
-            sum -= coefficient;
-        }
-        return sum;
-    }
-
-    /**
-     * Checks whether the given column is basic.
-     * @param col index of the column to check
-     * @return the row that the variable is basic in.  null if the column is not basic
-     */
-    protected Integer getBasicRow(final int col) {
-        Integer row = null;
-        for (int i = 0; i < getHeight(); i++) {
-            final double entry = getEntry(i, col);
-            if (Precision.equals(entry, 1d, maxUlps) && (row == null)) {
-                row = i;
-            } else if (!Precision.equals(entry, 0d, maxUlps)) {
-                return null;
-            }
-        }
-        return row;
-    }
-
-    /**
-     * Removes the phase 1 objective function, positive cost non-artificial variables,
-     * and the non-basic artificial variables from this tableau.
-     */
-    protected void dropPhase1Objective() {
-        if (getNumObjectiveFunctions() == 1) {
-            return;
-        }
-
-        Set<Integer> columnsToDrop = new TreeSet<Integer>();
-        columnsToDrop.add(0);
-
-        // positive cost non-artificial variables
-        for (int i = getNumObjectiveFunctions(); i < getArtificialVariableOffset(); i++) {
-            final double entry = tableau.getEntry(0, i);
-            if (Precision.compareTo(entry, 0d, epsilon) > 0) {
-                columnsToDrop.add(i);
-            }
-        }
-
-        // non-basic artificial variables
-        for (int i = 0; i < getNumArtificialVariables(); i++) {
-            int col = i + getArtificialVariableOffset();
-            if (getBasicRow(col) == null) {
-                columnsToDrop.add(col);
-            }
-        }
-
-        double[][] matrix = new double[getHeight() - 1][getWidth() - columnsToDrop.size()];
-        for (int i = 1; i < getHeight(); i++) {
-            int col = 0;
-            for (int j = 0; j < getWidth(); j++) {
-                if (!columnsToDrop.contains(j)) {
-                    matrix[i - 1][col++] = tableau.getEntry(i, j);
-                }
-            }
-        }
-
-        // remove the columns in reverse order so the indices are correct
-        Integer[] drop = columnsToDrop.toArray(new Integer[columnsToDrop.size()]);
-        for (int i = drop.length - 1; i >= 0; i--) {
-            columnLabels.remove((int) drop[i]);
-        }
-
-        this.tableau = new Array2DRowRealMatrix(matrix);
-        this.numArtificialVariables = 0;
-    }
-
-    /**
-     * @param src the source array
-     * @param dest the destination array
-     */
-    private void copyArray(final double[] src, final double[] dest) {
-        System.arraycopy(src, 0, dest, getNumObjectiveFunctions(), src.length);
-    }
-
-    /**
-     * Returns whether the problem is at an optimal state.
-     * @return whether the model has been solved
-     */
-    boolean isOptimal() {
-        for (int i = getNumObjectiveFunctions(); i < getWidth() - 1; i++) {
-            final double entry = tableau.getEntry(0, i);
-            if (Precision.compareTo(entry, 0d, epsilon) < 0) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Get the current solution.
-     * @return current solution
-     */
-    protected PointValuePair getSolution() {
-      int negativeVarColumn = columnLabels.indexOf(NEGATIVE_VAR_COLUMN_LABEL);
-      Integer negativeVarBasicRow = negativeVarColumn > 0 ? getBasicRow(negativeVarColumn) : null;
-      double mostNegative = negativeVarBasicRow == null ? 0 : getEntry(negativeVarBasicRow, getRhsOffset());
-
-      Set<Integer> basicRows = new HashSet<Integer>();
-      double[] coefficients = new double[getOriginalNumDecisionVariables()];
-      for (int i = 0; i < coefficients.length; i++) {
-          int colIndex = columnLabels.indexOf("x" + i);
-          if (colIndex < 0) {
-            coefficients[i] = 0;
-            continue;
-          }
-          Integer basicRow = getBasicRow(colIndex);
-          if (basicRow != null && basicRow == 0) {
-              // if the basic row is found to be the objective function row
-              // set the coefficient to 0 -> this case handles unconstrained
-              // variables that are still part of the objective function
-              coefficients[i] = 0;
-          } else if (basicRows.contains(basicRow)) {
-              // if multiple variables can take a given value
-              // then we choose the first and set the rest equal to 0
-              coefficients[i] = 0 - (restrictToNonNegative ? 0 : mostNegative);
-          } else {
-              basicRows.add(basicRow);
-              coefficients[i] =
-                  (basicRow == null ? 0 : getEntry(basicRow, getRhsOffset())) -
-                  (restrictToNonNegative ? 0 : mostNegative);
-          }
-      }
-      return new PointValuePair(coefficients, f.getValue(coefficients));
-    }
-
-    /**
-     * Subtracts a multiple of one row from another.
-     * <p>
-     * After application of this operation, the following will hold:
-     * <pre>minuendRow = minuendRow - multiple * subtrahendRow</pre>
-     *
-     * @param dividendRow index of the row
-     * @param divisor value of the divisor
-     */
-    protected void divideRow(final int dividendRow, final double divisor) {
-        for (int j = 0; j < getWidth(); j++) {
-            tableau.setEntry(dividendRow, j, tableau.getEntry(dividendRow, j) / divisor);
-        }
-    }
-
-    /**
-     * Subtracts a multiple of one row from another.
-     * <p>
-     * After application of this operation, the following will hold:
-     * <pre>minuendRow = minuendRow - multiple * subtrahendRow</pre>
-     *
-     * @param minuendRow row index
-     * @param subtrahendRow row index
-     * @param multiple multiplication factor
-     */
-    protected void subtractRow(final int minuendRow, final int subtrahendRow,
-                               final double multiple) {
-        for (int i = 0; i < getWidth(); i++) {
-            double result = tableau.getEntry(minuendRow, i) - tableau.getEntry(subtrahendRow, i) * multiple;
-            // cut-off values smaller than the CUTOFF_THRESHOLD, otherwise may lead to numerical instabilities
-            if (FastMath.abs(result) < CUTOFF_THRESHOLD) {
-                result = 0.0;
-            }
-            tableau.setEntry(minuendRow, i, result);
-        }
-    }
-
-    /**
-     * Get the width of the tableau.
-     * @return width of the tableau
-     */
-    protected final int getWidth() {
-        return tableau.getColumnDimension();
-    }
-
-    /**
-     * Get the height of the tableau.
-     * @return height of the tableau
-     */
-    protected final int getHeight() {
-        return tableau.getRowDimension();
-    }
-
-    /**
-     * Get an entry of the tableau.
-     * @param row row index
-     * @param column column index
-     * @return entry at (row, column)
-     */
-    protected final double getEntry(final int row, final int column) {
-        return tableau.getEntry(row, column);
-    }
-
-    /**
-     * Set an entry of the tableau.
-     * @param row row index
-     * @param column column index
-     * @param value for the entry
-     */
-    protected final void setEntry(final int row, final int column,
-                                  final double value) {
-        tableau.setEntry(row, column, value);
-    }
-
-    /**
-     * Get the offset of the first slack variable.
-     * @return offset of the first slack variable
-     */
-    protected final int getSlackVariableOffset() {
-        return getNumObjectiveFunctions() + numDecisionVariables;
-    }
-
-    /**
-     * Get the offset of the first artificial variable.
-     * @return offset of the first artificial variable
-     */
-    protected final int getArtificialVariableOffset() {
-        return getNumObjectiveFunctions() + numDecisionVariables + numSlackVariables;
-    }
-
-    /**
-     * Get the offset of the right hand side.
-     * @return offset of the right hand side
-     */
-    protected final int getRhsOffset() {
-        return getWidth() - 1;
-    }
-
-    /**
-     * Get the number of decision variables.
-     * <p>
-     * If variables are not restricted to positive values, this will include 1 extra decision variable to represent
-     * the absolute value of the most negative variable.
-     *
-     * @return number of decision variables
-     * @see #getOriginalNumDecisionVariables()
-     */
-    protected final int getNumDecisionVariables() {
-        return numDecisionVariables;
-    }
-
-    /**
-     * Get the original number of decision variables.
-     * @return original number of decision variables
-     * @see #getNumDecisionVariables()
-     */
-    protected final int getOriginalNumDecisionVariables() {
-        return f.getCoefficients().getDimension();
-    }
-
-    /**
-     * Get the number of slack variables.
-     * @return number of slack variables
-     */
-    protected final int getNumSlackVariables() {
-        return numSlackVariables;
-    }
-
-    /**
-     * Get the number of artificial variables.
-     * @return number of artificial variables
-     */
-    protected final int getNumArtificialVariables() {
-        return numArtificialVariables;
-    }
-
-    /**
-     * Get the tableau data.
-     * @return tableau data
-     */
-    protected final double[][] getData() {
-        return tableau.getData();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-
-      if (this == other) {
-        return true;
-      }
-
-      if (other instanceof SimplexTableau) {
-          SimplexTableau rhs = (SimplexTableau) other;
-          return (restrictToNonNegative  == rhs.restrictToNonNegative) &&
-                 (numDecisionVariables   == rhs.numDecisionVariables) &&
-                 (numSlackVariables      == rhs.numSlackVariables) &&
-                 (numArtificialVariables == rhs.numArtificialVariables) &&
-                 (epsilon                == rhs.epsilon) &&
-                 (maxUlps                == rhs.maxUlps) &&
-                 f.equals(rhs.f) &&
-                 constraints.equals(rhs.constraints) &&
-                 tableau.equals(rhs.tableau);
-      }
-      return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return Boolean.valueOf(restrictToNonNegative).hashCode() ^
-               numDecisionVariables ^
-               numSlackVariables ^
-               numArtificialVariables ^
-               Double.valueOf(epsilon).hashCode() ^
-               maxUlps ^
-               f.hashCode() ^
-               constraints.hashCode() ^
-               tableau.hashCode();
-    }
-
-    /**
-     * Serialize the instance.
-     * @param oos stream where object should be written
-     * @throws IOException if object cannot be written to stream
-     */
-    private void writeObject(ObjectOutputStream oos)
-        throws IOException {
-        oos.defaultWriteObject();
-        MatrixUtils.serializeRealMatrix(tableau, oos);
-    }
-
-    /**
-     * Deserialize the instance.
-     * @param ois stream from which the object should be read
-     * @throws ClassNotFoundException if a class in the stream cannot be found
-     * @throws IOException if object cannot be read from the stream
-     */
-    private void readObject(ObjectInputStream ois)
-      throws ClassNotFoundException, IOException {
-        ois.defaultReadObject();
-        MatrixUtils.deserializeRealMatrix(this, "tableau", ois);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/linear/UnboundedSolutionException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/linear/UnboundedSolutionException.java b/src/main/java/org/apache/commons/math4/optimization/linear/UnboundedSolutionException.java
deleted file mode 100644
index 1332440..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/linear/UnboundedSolutionException.java
+++ /dev/null
@@ -1,42 +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.linear;
-
-import org.apache.commons.math4.exception.MathIllegalStateException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-
-/**
- * This class represents exceptions thrown by optimizers when a solution escapes to infinity.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-public class UnboundedSolutionException extends MathIllegalStateException {
-
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = 940539497277290619L;
-
-    /**
-     * Simple constructor using a default message.
-     */
-    public UnboundedSolutionException() {
-        super(LocalizedFormats.UNBOUNDED_SOLUTION);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/linear/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/linear/package-info.java b/src/main/java/org/apache/commons/math4/optimization/linear/package-info.java
deleted file mode 100644
index 3e7c424..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/linear/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.
- */
-/**
- *
- * This package provides optimization algorithms for linear constrained problems.
- *
- */
-package org.apache.commons.math4.optimization.linear;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/package-info.java b/src/main/java/org/apache/commons/math4/optimization/package-info.java
deleted file mode 100644
index f92cb0f..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/package-info.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.
- */
-/**
- * <h2>All classes and sub-packages of this package are deprecated.</h2>
- * <h3>Please use their replacements, to be found under
- *  <ul>
- *   <li>{@link org.apache.commons.math4.optim}</li>
- *   <li>{@link org.apache.commons.math4.fitting}</li>
- *  </ul>
- * </h3>
- *
- * <p>
- * This package provides common interfaces for the optimization algorithms
- * provided in sub-packages. The main interfaces defines optimizers and convergence
- * checkers. The functions that are optimized by the algorithms provided by this
- * package and its sub-packages are a subset of the one defined in the <code>analysis</code>
- * package, namely the real and vector valued functions. These functions are called
- * objective function here. When the goal is to minimize, the functions are often called
- * cost function, this name is not used in this package.
- * </p>
- *
- * <p>
- * Optimizers are the algorithms that will either minimize or maximize, the objective function
- * by changing its input variables set until an optimal set is found. There are only four
- * interfaces defining the common behavior of optimizers, one for each supported type of objective
- * function:
- * <ul>
- *  <li>{@link org.apache.commons.math4.optimization.univariate.UnivariateOptimizer
- *      UnivariateOptimizer} for {@link org.apache.commons.math4.analysis.UnivariateFunction
- *      univariate real functions}</li>
- *  <li>{@link org.apache.commons.math4.optimization.MultivariateOptimizer
- *      MultivariateOptimizer} for {@link org.apache.commons.math4.analysis.MultivariateFunction
- *      multivariate real functions}</li>
- *  <li>{@link org.apache.commons.math4.optimization.MultivariateDifferentiableOptimizer
- *      MultivariateDifferentiableOptimizer} for {@link
- *      org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableFunction
- *      multivariate differentiable real functions}</li>
- *  <li>{@link org.apache.commons.math4.optimization.MultivariateDifferentiableVectorOptimizer
- *      MultivariateDifferentiableVectorOptimizer} for {@link
- *      org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableVectorFunction
- *      multivariate differentiable vectorial functions}</li>
- * </ul>
- * </p>
- *
- * <p>
- * Despite there are only four types of supported optimizers, it is possible to optimize a
- * transform a {@link org.apache.commons.math4.analysis.MultivariateVectorFunction
- * non-differentiable multivariate vectorial function} by converting it to a {@link
- * org.apache.commons.math4.analysis.MultivariateFunction non-differentiable multivariate
- * real function} thanks to the {@link
- * org.apache.commons.math4.optimization.LeastSquaresConverter LeastSquaresConverter} helper class.
- * The transformed function can be optimized using any implementation of the {@link
- * org.apache.commons.math4.optimization.MultivariateOptimizer MultivariateOptimizer} interface.
- * </p>
- *
- * <p>
- * For each of the four types of supported optimizers, there is a special implementation which
- * wraps a classical optimizer in order to add it a multi-start feature. This feature call the
- * underlying optimizer several times in sequence with different starting points and returns
- * the best optimum found or all optima if desired. This is a classical way to prevent being
- * trapped into a local extremum when looking for a global one.
- * </p>
- *
- */
-package org.apache.commons.math4.optimization;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/BaseAbstractUnivariateOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/BaseAbstractUnivariateOptimizer.java b/src/main/java/org/apache/commons/math4/optimization/univariate/BaseAbstractUnivariateOptimizer.java
deleted file mode 100644
index 6b6a9b1..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/BaseAbstractUnivariateOptimizer.java
+++ /dev/null
@@ -1,162 +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;
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.optimization.ConvergenceChecker;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.util.Incrementor;
-
-/**
- * Provide a default implementation for several functions useful to generic
- * optimizers.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-public abstract class BaseAbstractUnivariateOptimizer
-    implements UnivariateOptimizer {
-    /** Convergence checker. */
-    private final ConvergenceChecker<UnivariatePointValuePair> checker;
-    /** Evaluations counter. */
-    private final Incrementor evaluations = new Incrementor();
-    /** Optimization type */
-    private GoalType goal;
-    /** Lower end of search interval. */
-    private double searchMin;
-    /** Higher end of search interval. */
-    private double searchMax;
-    /** Initial guess . */
-    private double searchStart;
-    /** Function to optimize. */
-    private UnivariateFunction function;
-
-    /**
-     * @param checker Convergence checking procedure.
-     */
-    protected BaseAbstractUnivariateOptimizer(ConvergenceChecker<UnivariatePointValuePair> checker) {
-        this.checker = checker;
-    }
-
-    /** {@inheritDoc} */
-    public int getMaxEvaluations() {
-        return evaluations.getMaximalCount();
-    }
-
-    /** {@inheritDoc} */
-    public int getEvaluations() {
-        return evaluations.getCount();
-    }
-
-    /**
-     * @return the optimization type.
-     */
-    public GoalType getGoalType() {
-        return goal;
-    }
-    /**
-     * @return the lower end of the search interval.
-     */
-    public double getMin() {
-        return searchMin;
-    }
-    /**
-     * @return the higher end of the search interval.
-     */
-    public double getMax() {
-        return searchMax;
-    }
-    /**
-     * @return the initial guess.
-     */
-    public double getStartValue() {
-        return searchStart;
-    }
-
-    /**
-     * Compute the objective function value.
-     *
-     * @param point Point at which the objective function must be evaluated.
-     * @return the objective function value at specified point.
-     * @throws TooManyEvaluationsException if the maximal number of evaluations
-     * is exceeded.
-     */
-    protected double computeObjectiveValue(double point) {
-        try {
-            evaluations.incrementCount();
-        } catch (MaxCountExceededException e) {
-            throw new TooManyEvaluationsException(e.getMax());
-        }
-        return function.value(point);
-    }
-
-    /** {@inheritDoc} */
-    public UnivariatePointValuePair optimize(int maxEval, UnivariateFunction f,
-                                             GoalType goalType,
-                                             double min, double max,
-                                             double startValue) {
-        // Checks.
-        if (f == null) {
-            throw new NullArgumentException();
-        }
-        if (goalType == null) {
-            throw new NullArgumentException();
-        }
-
-        // Reset.
-        searchMin = min;
-        searchMax = max;
-        searchStart = startValue;
-        goal = goalType;
-        function = f;
-        evaluations.setMaximalCount(maxEval);
-        evaluations.resetCount();
-
-        // Perform computation.
-        return doOptimize();
-    }
-
-    /** {@inheritDoc} */
-    public UnivariatePointValuePair optimize(int maxEval,
-                                             UnivariateFunction f,
-                                             GoalType goalType,
-                                             double min, double max){
-        return optimize(maxEval, f, goalType, min, max, min + 0.5 * (max - min));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public ConvergenceChecker<UnivariatePointValuePair> getConvergenceChecker() {
-        return checker;
-    }
-
-    /**
-     * Method for implementing actual optimization algorithms in derived
-     * classes.
-     *
-     * @return the optimum and its corresponding function value.
-     * @throws TooManyEvaluationsException if the maximal number of evaluations
-     * is exceeded.
-     */
-    protected abstract UnivariatePointValuePair doOptimize();
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/BaseUnivariateOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/BaseUnivariateOptimizer.java b/src/main/java/org/apache/commons/math4/optimization/univariate/BaseUnivariateOptimizer.java
deleted file mode 100644
index 67e16ca..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/BaseUnivariateOptimizer.java
+++ /dev/null
@@ -1,86 +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;
-import org.apache.commons.math4.optimization.BaseOptimizer;
-import org.apache.commons.math4.optimization.GoalType;
-
-/**
- * This interface is mainly intended to enforce the internal coherence of
- * Commons-Math. Users of the API are advised to base their code on
- * the following interfaces:
- * <ul>
- *  <li>{@link org.apache.commons.math4.optimization.univariate.UnivariateOptimizer}</li>
- * </ul>
- *
- * @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 interface BaseUnivariateOptimizer<FUNC extends UnivariateFunction>
-    extends BaseOptimizer<UnivariatePointValuePair> {
-    /**
-     * Find an optimum in the given interval.
-     *
-     * An optimizer may require that the interval brackets a single optimum.
-     *
-     * @param f Function to optimize.
-     * @param goalType Type of optimization goal: either
-     * {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
-     * @param min Lower bound for the interval.
-     * @param max Upper bound for the interval.
-     * @param maxEval Maximum number of function evaluations.
-     * @return a (point, value) pair where the function is optimum.
-     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException
-     * if the maximum evaluation count is exceeded.
-     * @throws org.apache.commons.math4.exception.ConvergenceException
-     * if the optimizer detects a convergence problem.
-     * @throws IllegalArgumentException if {@code min > max} or the endpoints
-     * do not satisfy the requirements specified by the optimizer.
-     */
-    UnivariatePointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
-                                          double min, double max);
-
-    /**
-     * Find an optimum in the given interval, start at startValue.
-     * An optimizer may require that the interval brackets a single optimum.
-     *
-     * @param f Function to optimize.
-     * @param goalType Type of optimization goal: either
-     * {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
-     * @param min Lower bound for the interval.
-     * @param max Upper bound for the interval.
-     * @param startValue Start value to use.
-     * @param maxEval Maximum number of function evaluations.
-     * @return a (point, value) pair where the function is optimum.
-     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException
-     * if the maximum evaluation count is exceeded.
-     * @throws org.apache.commons.math4.exception.ConvergenceException if the
-     * optimizer detects a convergence problem.
-     * @throws IllegalArgumentException if {@code min > max} or the endpoints
-     * do not satisfy the requirements specified by the optimizer.
-     * @throws org.apache.commons.math4.exception.NullArgumentException if any
-     * argument is {@code null}.
-     */
-    UnivariatePointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
-                                          double min, double max,
-                                          double startValue);
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/BracketFinder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/BracketFinder.java b/src/main/java/org/apache/commons/math4/optimization/univariate/BracketFinder.java
deleted file mode 100644
index 2727a2f..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/BracketFinder.java
+++ /dev/null
@@ -1,289 +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;
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.Incrementor;
-
-/**
- * Provide an interval that brackets a local optimum of a function.
- * This code is based on a Python implementation (from <em>SciPy</em>,
- * module {@code optimize.py} v0.5).
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.2
- */
-@Deprecated
-public class BracketFinder {
-    /** Tolerance to avoid division by zero. */
-    private static final double EPS_MIN = 1e-21;
-    /**
-     * Golden section.
-     */
-    private static final double GOLD = 1.618034;
-    /**
-     * Factor for expanding the interval.
-     */
-    private final double growLimit;
-    /**
-     * Counter for function evaluations.
-     */
-    private final Incrementor evaluations = new Incrementor();
-    /**
-     * Lower bound of the bracket.
-     */
-    private double lo;
-    /**
-     * Higher bound of the bracket.
-     */
-    private double hi;
-    /**
-     * Point inside the bracket.
-     */
-    private double mid;
-    /**
-     * Function value at {@link #lo}.
-     */
-    private double fLo;
-    /**
-     * Function value at {@link #hi}.
-     */
-    private double fHi;
-    /**
-     * Function value at {@link #mid}.
-     */
-    private double fMid;
-
-    /**
-     * Constructor with default values {@code 100, 50} (see the
-     * {@link #BracketFinder(double,int) other constructor}).
-     */
-    public BracketFinder() {
-        this(100, 50);
-    }
-
-    /**
-     * Create a bracketing interval finder.
-     *
-     * @param growLimit Expanding factor.
-     * @param maxEvaluations Maximum number of evaluations allowed for finding
-     * a bracketing interval.
-     */
-    public BracketFinder(double growLimit,
-                         int maxEvaluations) {
-        if (growLimit <= 0) {
-            throw new NotStrictlyPositiveException(growLimit);
-        }
-        if (maxEvaluations <= 0) {
-            throw new NotStrictlyPositiveException(maxEvaluations);
-        }
-
-        this.growLimit = growLimit;
-        evaluations.setMaximalCount(maxEvaluations);
-    }
-
-    /**
-     * Search new points that bracket a local optimum of the function.
-     *
-     * @param func Function whose optimum should be bracketed.
-     * @param goal {@link GoalType Goal type}.
-     * @param xA Initial point.
-     * @param xB Initial point.
-     * @throws TooManyEvaluationsException if the maximum number of evaluations
-     * is exceeded.
-     */
-    public void search(UnivariateFunction func, GoalType goal, double xA, double xB) {
-        evaluations.resetCount();
-        final boolean isMinim = goal == GoalType.MINIMIZE;
-
-        double fA = eval(func, xA);
-        double fB = eval(func, xB);
-        if (isMinim ?
-            fA < fB :
-            fA > fB) {
-
-            double tmp = xA;
-            xA = xB;
-            xB = tmp;
-
-            tmp = fA;
-            fA = fB;
-            fB = tmp;
-        }
-
-        double xC = xB + GOLD * (xB - xA);
-        double fC = eval(func, xC);
-
-        while (isMinim ? fC < fB : fC > fB) {
-            double tmp1 = (xB - xA) * (fB - fC);
-            double tmp2 = (xB - xC) * (fB - fA);
-
-            double val = tmp2 - tmp1;
-            double denom = FastMath.abs(val) < EPS_MIN ? 2 * EPS_MIN : 2 * val;
-
-            double w = xB - ((xB - xC) * tmp2 - (xB - xA) * tmp1) / denom;
-            double wLim = xB + growLimit * (xC - xB);
-
-            double fW;
-            if ((w - xC) * (xB - w) > 0) {
-                fW = eval(func, w);
-                if (isMinim ?
-                    fW < fC :
-                    fW > fC) {
-                    xA = xB;
-                    xB = w;
-                    fA = fB;
-                    fB = fW;
-                    break;
-                } else if (isMinim ?
-                           fW > fB :
-                           fW < fB) {
-                    xC = w;
-                    fC = fW;
-                    break;
-                }
-                w = xC + GOLD * (xC - xB);
-                fW = eval(func, w);
-            } else if ((w - wLim) * (wLim - xC) >= 0) {
-                w = wLim;
-                fW = eval(func, w);
-            } else if ((w - wLim) * (xC - w) > 0) {
-                fW = eval(func, w);
-                if (isMinim ?
-                    fW < fC :
-                    fW > fC) {
-                    xB = xC;
-                    xC = w;
-                    w = xC + GOLD * (xC - xB);
-                    fB = fC;
-                    fC =fW;
-                    fW = eval(func, w);
-                }
-            } else {
-                w = xC + GOLD * (xC - xB);
-                fW = eval(func, w);
-            }
-
-            xA = xB;
-            fA = fB;
-            xB = xC;
-            fB = fC;
-            xC = w;
-            fC = fW;
-        }
-
-        lo = xA;
-        fLo = fA;
-        mid = xB;
-        fMid = fB;
-        hi = xC;
-        fHi = fC;
-
-        if (lo > hi) {
-            double tmp = lo;
-            lo = hi;
-            hi = tmp;
-
-            tmp = fLo;
-            fLo = fHi;
-            fHi = tmp;
-        }
-    }
-
-    /**
-     * @return the number of evalutations.
-     */
-    public int getMaxEvaluations() {
-        return evaluations.getMaximalCount();
-    }
-
-    /**
-     * @return the number of evalutations.
-     */
-    public int getEvaluations() {
-        return evaluations.getCount();
-    }
-
-    /**
-     * @return the lower bound of the bracket.
-     * @see #getFLo()
-     */
-    public double getLo() {
-        return lo;
-    }
-
-    /**
-     * Get function value at {@link #getLo()}.
-     * @return function value at {@link #getLo()}
-     */
-    public double getFLo() {
-        return fLo;
-    }
-
-    /**
-     * @return the higher bound of the bracket.
-     * @see #getFHi()
-     */
-    public double getHi() {
-        return hi;
-    }
-
-    /**
-     * Get function value at {@link #getHi()}.
-     * @return function value at {@link #getHi()}
-     */
-    public double getFHi() {
-        return fHi;
-    }
-
-    /**
-     * @return a point in the middle of the bracket.
-     * @see #getFMid()
-     */
-    public double getMid() {
-        return mid;
-    }
-
-    /**
-     * Get function value at {@link #getMid()}.
-     * @return function value at {@link #getMid()}
-     */
-    public double getFMid() {
-        return fMid;
-    }
-
-    /**
-     * @param f Function.
-     * @param x Argument.
-     * @return {@code f(x)}
-     * @throws TooManyEvaluationsException if the maximal number of evaluations is
-     * exceeded.
-     */
-    private double eval(UnivariateFunction f, double x) {
-        try {
-            evaluations.incrementCount();
-        } catch (MaxCountExceededException e) {
-            throw new TooManyEvaluationsException(e.getMax());
-        }
-        return f.value(x);
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/BrentOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/BrentOptimizer.java b/src/main/java/org/apache/commons/math4/optimization/univariate/BrentOptimizer.java
deleted file mode 100644
index a7d39df..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/BrentOptimizer.java
+++ /dev/null
@@ -1,316 +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.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.optimization.ConvergenceChecker;
-import org.apache.commons.math4.optimization.GoalType;
-import org.apache.commons.math4.util.FastMath;
-import org.apache.commons.math4.util.Precision;
-
-/**
- * For a function defined on some interval {@code (lo, hi)}, this class
- * finds an approximation {@code x} to the point at which the function
- * attains its minimum.
- * It implements Richard Brent's algorithm (from his book "Algorithms for
- * Minimization without Derivatives", p. 79) for finding minima of real
- * univariate functions.
- * <br/>
- * This code is an adaptation, partly based on the Python code from SciPy
- * (module "optimize.py" v0.5); the original algorithm is also modified
- * <ul>
- *  <li>to use an initial guess provided by the user,</li>
- *  <li>to ensure that the best point encountered is the one returned.</li>
- * </ul>
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 2.0
- */
-@Deprecated
-public class BrentOptimizer extends BaseAbstractUnivariateOptimizer {
-    /**
-     * Golden section.
-     */
-    private static final double GOLDEN_SECTION = 0.5 * (3 - FastMath.sqrt(5));
-    /**
-     * Minimum relative tolerance.
-     */
-    private static final double MIN_RELATIVE_TOLERANCE = 2 * FastMath.ulp(1d);
-    /**
-     * Relative threshold.
-     */
-    private final double relativeThreshold;
-    /**
-     * Absolute threshold.
-     */
-    private final double absoluteThreshold;
-
-    /**
-     * The arguments are used implement the original stopping criterion
-     * of Brent's algorithm.
-     * {@code abs} and {@code rel} define a tolerance
-     * {@code tol = rel |x| + abs}. {@code rel} should be no smaller than
-     * <em>2 macheps</em> and preferably not much less than <em>sqrt(macheps)</em>,
-     * where <em>macheps</em> is the relative machine precision. {@code abs} must
-     * be positive.
-     *
-     * @param rel Relative threshold.
-     * @param abs Absolute threshold.
-     * @param checker Additional, user-defined, convergence checking
-     * procedure.
-     * @throws NotStrictlyPositiveException if {@code abs <= 0}.
-     * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
-     */
-    public BrentOptimizer(double rel,
-                          double abs,
-                          ConvergenceChecker<UnivariatePointValuePair> checker) {
-        super(checker);
-
-        if (rel < MIN_RELATIVE_TOLERANCE) {
-            throw new NumberIsTooSmallException(rel, MIN_RELATIVE_TOLERANCE, true);
-        }
-        if (abs <= 0) {
-            throw new NotStrictlyPositiveException(abs);
-        }
-
-        relativeThreshold = rel;
-        absoluteThreshold = abs;
-    }
-
-    /**
-     * The arguments are used for implementing the original stopping criterion
-     * of Brent's algorithm.
-     * {@code abs} and {@code rel} define a tolerance
-     * {@code tol = rel |x| + abs}. {@code rel} should be no smaller than
-     * <em>2 macheps</em> and preferably not much less than <em>sqrt(macheps)</em>,
-     * where <em>macheps</em> is the relative machine precision. {@code abs} must
-     * be positive.
-     *
-     * @param rel Relative threshold.
-     * @param abs Absolute threshold.
-     * @throws NotStrictlyPositiveException if {@code abs <= 0}.
-     * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
-     */
-    public BrentOptimizer(double rel,
-                          double abs) {
-        this(rel, abs, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected UnivariatePointValuePair doOptimize() {
-        final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
-        final double lo = getMin();
-        final double mid = getStartValue();
-        final double hi = getMax();
-
-        // Optional additional convergence criteria.
-        final ConvergenceChecker<UnivariatePointValuePair> checker
-            = getConvergenceChecker();
-
-        double a;
-        double b;
-        if (lo < hi) {
-            a = lo;
-            b = hi;
-        } else {
-            a = hi;
-            b = lo;
-        }
-
-        double x = mid;
-        double v = x;
-        double w = x;
-        double d = 0;
-        double e = 0;
-        double fx = computeObjectiveValue(x);
-        if (!isMinim) {
-            fx = -fx;
-        }
-        double fv = fx;
-        double fw = fx;
-
-        UnivariatePointValuePair previous = null;
-        UnivariatePointValuePair current
-            = new UnivariatePointValuePair(x, isMinim ? fx : -fx);
-        // Best point encountered so far (which is the initial guess).
-        UnivariatePointValuePair best = current;
-
-        int iter = 0;
-        while (true) {
-            final double m = 0.5 * (a + b);
-            final double tol1 = relativeThreshold * FastMath.abs(x) + absoluteThreshold;
-            final double tol2 = 2 * tol1;
-
-            // Default stopping criterion.
-            final boolean stop = FastMath.abs(x - m) <= tol2 - 0.5 * (b - a);
-            if (!stop) {
-                double p = 0;
-                double q = 0;
-                double r = 0;
-                double u = 0;
-
-                if (FastMath.abs(e) > tol1) { // Fit parabola.
-                    r = (x - w) * (fx - fv);
-                    q = (x - v) * (fx - fw);
-                    p = (x - v) * q - (x - w) * r;
-                    q = 2 * (q - r);
-
-                    if (q > 0) {
-                        p = -p;
-                    } else {
-                        q = -q;
-                    }
-
-                    r = e;
-                    e = d;
-
-                    if (p > q * (a - x) &&
-                        p < q * (b - x) &&
-                        FastMath.abs(p) < FastMath.abs(0.5 * q * r)) {
-                        // Parabolic interpolation step.
-                        d = p / q;
-                        u = x + d;
-
-                        // f must not be evaluated too close to a or b.
-                        if (u - a < tol2 || b - u < tol2) {
-                            if (x <= m) {
-                                d = tol1;
-                            } else {
-                                d = -tol1;
-                            }
-                        }
-                    } else {
-                        // Golden section step.
-                        if (x < m) {
-                            e = b - x;
-                        } else {
-                            e = a - x;
-                        }
-                        d = GOLDEN_SECTION * e;
-                    }
-                } else {
-                    // Golden section step.
-                    if (x < m) {
-                        e = b - x;
-                    } else {
-                        e = a - x;
-                    }
-                    d = GOLDEN_SECTION * e;
-                }
-
-                // Update by at least "tol1".
-                if (FastMath.abs(d) < tol1) {
-                    if (d >= 0) {
-                        u = x + tol1;
-                    } else {
-                        u = x - tol1;
-                    }
-                } else {
-                    u = x + d;
-                }
-
-                double fu = computeObjectiveValue(u);
-                if (!isMinim) {
-                    fu = -fu;
-                }
-
-                // User-defined convergence checker.
-                previous = current;
-                current = new UnivariatePointValuePair(u, isMinim ? fu : -fu);
-                best = best(best,
-                            best(previous,
-                                 current,
-                                 isMinim),
-                            isMinim);
-
-                if (checker != null && checker.converged(iter, previous, current)) {
-                    return best;
-                }
-
-                // Update a, b, v, w and x.
-                if (fu <= fx) {
-                    if (u < x) {
-                        b = x;
-                    } else {
-                        a = x;
-                    }
-                    v = w;
-                    fv = fw;
-                    w = x;
-                    fw = fx;
-                    x = u;
-                    fx = fu;
-                } else {
-                    if (u < x) {
-                        a = u;
-                    } else {
-                        b = u;
-                    }
-                    if (fu <= fw ||
-                        Precision.equals(w, x)) {
-                        v = w;
-                        fv = fw;
-                        w = u;
-                        fw = fu;
-                    } else if (fu <= fv ||
-                               Precision.equals(v, x) ||
-                               Precision.equals(v, w)) {
-                        v = u;
-                        fv = fu;
-                    }
-                }
-            } else { // Default termination (Brent's criterion).
-                return best(best,
-                            best(previous,
-                                 current,
-                                 isMinim),
-                            isMinim);
-            }
-            ++iter;
-        }
-    }
-
-    /**
-     * Selects the best of two points.
-     *
-     * @param a Point and value.
-     * @param b Point and value.
-     * @param isMinim {@code true} if the selected point must be the one with
-     * the lowest value.
-     * @return the best point, or {@code null} if {@code a} and {@code b} are
-     * both {@code null}. When {@code a} and {@code b} have the same function
-     * value, {@code a} is returned.
-     */
-    private UnivariatePointValuePair best(UnivariatePointValuePair a,
-                                          UnivariatePointValuePair b,
-                                          boolean isMinim) {
-        if (a == null) {
-            return b;
-        }
-        if (b == null) {
-            return a;
-        }
-
-        if (isMinim) {
-            return a.getValue() <= b.getValue() ? a : b;
-        } else {
-            return a.getValue() >= b.getValue() ? a : b;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/univariate/SimpleUnivariateValueChecker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/univariate/SimpleUnivariateValueChecker.java b/src/main/java/org/apache/commons/math4/optimization/univariate/SimpleUnivariateValueChecker.java
deleted file mode 100644
index 29928e1..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/univariate/SimpleUnivariateValueChecker.java
+++ /dev/null
@@ -1,139 +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.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.optimization.AbstractConvergenceChecker;
-import org.apache.commons.math4.util.FastMath;
-
-/**
- * Simple implementation of the
- * {@link org.apache.commons.math4.optimization.ConvergenceChecker} interface
- * that uses only objective function values.
- *
- * Convergence is considered to have been reached if either the relative
- * difference between the objective function values is smaller than a
- * threshold or if either the absolute difference between the objective
- * function values is smaller than another threshold.
- * <br/>
- * The {@link #converged(int,UnivariatePointValuePair,UnivariatePointValuePair)
- * converged} method will also return {@code true} if the number of iterations
- * has been set (see {@link #SimpleUnivariateValueChecker(double,double,int)
- * this constructor}).
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.1
- */
-@Deprecated
-public class SimpleUnivariateValueChecker
-    extends AbstractConvergenceChecker<UnivariatePointValuePair> {
-    /**
-     * If {@link #maxIterationCount} is set to this value, the number of
-     * iterations will never cause
-     * {@link #converged(int,UnivariatePointValuePair,UnivariatePointValuePair)}
-     * to return {@code true}.
-     */
-    private static final int ITERATION_CHECK_DISABLED = -1;
-    /**
-     * Number of iterations after which the
-     * {@link #converged(int,UnivariatePointValuePair,UnivariatePointValuePair)}
-     * method will return true (unless the check is disabled).
-     */
-    private final int maxIterationCount;
-
-    /**
-     * Build an instance with default thresholds.
-     * @deprecated See {@link AbstractConvergenceChecker#AbstractConvergenceChecker()}
-     */
-    @Deprecated
-    public SimpleUnivariateValueChecker() {
-        maxIterationCount = ITERATION_CHECK_DISABLED;
-    }
-
-    /** Build an instance with specified thresholds.
-     *
-     * In order to perform only relative checks, the absolute tolerance
-     * must be set to a negative value. In order to perform only absolute
-     * checks, the relative tolerance must be set to a negative value.
-     *
-     * @param relativeThreshold relative tolerance threshold
-     * @param absoluteThreshold absolute tolerance threshold
-     */
-    public SimpleUnivariateValueChecker(final double relativeThreshold,
-                                        final double absoluteThreshold) {
-        super(relativeThreshold, absoluteThreshold);
-        maxIterationCount = ITERATION_CHECK_DISABLED;
-    }
-
-    /**
-     * Builds an instance with specified thresholds.
-     *
-     * In order to perform only relative checks, the absolute tolerance
-     * must be set to a negative value. In order to perform only absolute
-     * checks, the relative tolerance must be set to a negative value.
-     *
-     * @param relativeThreshold relative tolerance threshold
-     * @param absoluteThreshold absolute tolerance threshold
-     * @param maxIter Maximum iteration count.
-     * @throws NotStrictlyPositiveException if {@code maxIter <= 0}.
-     *
-     * @since 3.1
-     */
-    public SimpleUnivariateValueChecker(final double relativeThreshold,
-                                        final double absoluteThreshold,
-                                        final int maxIter) {
-        super(relativeThreshold, absoluteThreshold);
-
-        if (maxIter <= 0) {
-            throw new NotStrictlyPositiveException(maxIter);
-        }
-        maxIterationCount = maxIter;
-    }
-
-    /**
-     * Check if the optimization algorithm has converged considering the
-     * last two points.
-     * This method may be called several time from the same algorithm
-     * iteration with different points. This can be detected by checking the
-     * iteration number at each call if needed. Each time this method is
-     * called, the previous and current point correspond to points with the
-     * same role at each iteration, so they can be compared. As an example,
-     * simplex-based algorithms call this method for all points of the simplex,
-     * not only for the best or worst ones.
-     *
-     * @param iteration Index of current iteration
-     * @param previous Best point in the previous iteration.
-     * @param current Best point in the current iteration.
-     * @return {@code true} if the algorithm has converged.
-     */
-    @Override
-    public boolean converged(final int iteration,
-                             final UnivariatePointValuePair previous,
-                             final UnivariatePointValuePair current) {
-        if (maxIterationCount != ITERATION_CHECK_DISABLED && iteration >= maxIterationCount) {
-            return true;
-        }
-
-        final double p = previous.getValue();
-        final double c = current.getValue();
-        final double difference = FastMath.abs(p - c);
-        final double size = FastMath.max(FastMath.abs(p), FastMath.abs(c));
-        return difference <= size * getRelativeThreshold() ||
-            difference <= getAbsoluteThreshold();
-    }
-}


Mime
View raw message