commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject [16/18] [math] Remove deprecated optimization package.
Date Wed, 25 Feb 2015 21:49:44 GMT
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/OptimizationData.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/OptimizationData.java b/src/main/java/org/apache/commons/math4/optimization/OptimizationData.java
deleted file mode 100644
index 1ddf3c7..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/OptimizationData.java
+++ /dev/null
@@ -1,30 +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;
-
-/**
- * Marker interface.
- * Implementations will provide functionality (optional or required) needed
- * by the optimizers, and those will need to check the actual type of the
- * arguments and perform the appropriate cast in order to access the data
- * they need.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.1
- */
-@Deprecated
-public interface OptimizationData {}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/PointValuePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/PointValuePair.java b/src/main/java/org/apache/commons/math4/optimization/PointValuePair.java
deleted file mode 100644
index d3831e9..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/PointValuePair.java
+++ /dev/null
@@ -1,128 +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 java.io.Serializable;
-
-import org.apache.commons.math4.util.Pair;
-
-/**
- * This class holds a point and the value of an objective function at
- * that point.
- *
- * @see PointVectorValuePair
- * @see org.apache.commons.math4.analysis.MultivariateFunction
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class PointValuePair extends Pair<double[], Double> implements Serializable {
-
-    /** Serializable UID. */
-    private static final long serialVersionUID = 20120513L;
-
-    /**
-     * Builds a point/objective function value pair.
-     *
-     * @param point Point coordinates. This instance will store
-     * a copy of the array, not the array passed as argument.
-     * @param value Value of the objective function at the point.
-     */
-    public PointValuePair(final double[] point,
-                          final double value) {
-        this(point, value, true);
-    }
-
-    /**
-     * Builds a point/objective function value pair.
-     *
-     * @param point Point coordinates.
-     * @param value Value of the objective function at the point.
-     * @param copyArray if {@code true}, the input array will be copied,
-     * otherwise it will be referenced.
-     */
-    public PointValuePair(final double[] point,
-                          final double value,
-                          final boolean copyArray) {
-        super(copyArray ? ((point == null) ? null :
-                           point.clone()) :
-              point,
-              value);
-    }
-
-    /**
-     * Gets the point.
-     *
-     * @return a copy of the stored point.
-     */
-    public double[] getPoint() {
-        final double[] p = getKey();
-        return p == null ? null : p.clone();
-    }
-
-    /**
-     * Gets a reference to the point.
-     *
-     * @return a reference to the internal array storing the point.
-     */
-    public double[] getPointRef() {
-        return getKey();
-    }
-
-    /**
-     * Replace the instance with a data transfer object for serialization.
-     * @return data transfer object that will be serialized
-     */
-    private Object writeReplace() {
-        return new DataTransferObject(getKey(), getValue());
-    }
-
-    /** Internal class used only for serialization. */
-    private static class DataTransferObject implements Serializable {
-        /** Serializable UID. */
-        private static final long serialVersionUID = 20120513L;
-        /**
-         * Point coordinates.
-         * @Serial
-         */
-        private final double[] point;
-        /**
-         * Value of the objective function at the point.
-         * @Serial
-         */
-        private final double value;
-
-        /** Simple constructor.
-         * @param point Point coordinates.
-         * @param value Value of the objective function at the point.
-         */
-        public DataTransferObject(final double[] point, final double value) {
-            this.point = point.clone();
-            this.value = value;
-        }
-
-        /** Replace the deserialized data transfer object with a {@link PointValuePair}.
-         * @return replacement {@link PointValuePair}
-         */
-        private Object readResolve() {
-            return new PointValuePair(point, value, false);
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/PointVectorValuePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/PointVectorValuePair.java b/src/main/java/org/apache/commons/math4/optimization/PointVectorValuePair.java
deleted file mode 100644
index 410ba67..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/PointVectorValuePair.java
+++ /dev/null
@@ -1,151 +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 java.io.Serializable;
-
-import org.apache.commons.math4.util.Pair;
-
-/**
- * This class holds a point and the vectorial value of an objective function at
- * that point.
- *
- * @see PointValuePair
- * @see org.apache.commons.math4.analysis.MultivariateVectorFunction
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class PointVectorValuePair extends Pair<double[], double[]> implements Serializable {
-
-    /** Serializable UID. */
-    private static final long serialVersionUID = 20120513L;
-
-    /**
-     * Builds a point/objective function value pair.
-     *
-     * @param point Point coordinates. This instance will store
-     * a copy of the array, not the array passed as argument.
-     * @param value Value of the objective function at the point.
-     */
-    public PointVectorValuePair(final double[] point,
-                                final double[] value) {
-        this(point, value, true);
-    }
-
-    /**
-     * Build a point/objective function value pair.
-     *
-     * @param point Point coordinates.
-     * @param value Value of the objective function at the point.
-     * @param copyArray if {@code true}, the input arrays will be copied,
-     * otherwise they will be referenced.
-     */
-    public PointVectorValuePair(final double[] point,
-                                final double[] value,
-                                final boolean copyArray) {
-        super(copyArray ?
-              ((point == null) ? null :
-               point.clone()) :
-              point,
-              copyArray ?
-              ((value == null) ? null :
-               value.clone()) :
-              value);
-    }
-
-    /**
-     * Gets the point.
-     *
-     * @return a copy of the stored point.
-     */
-    public double[] getPoint() {
-        final double[] p = getKey();
-        return p == null ? null : p.clone();
-    }
-
-    /**
-     * Gets a reference to the point.
-     *
-     * @return a reference to the internal array storing the point.
-     */
-    public double[] getPointRef() {
-        return getKey();
-    }
-
-    /**
-     * Gets the value of the objective function.
-     *
-     * @return a copy of the stored value of the objective function.
-     */
-    @Override
-    public double[] getValue() {
-        final double[] v = super.getValue();
-        return v == null ? null : v.clone();
-    }
-
-    /**
-     * Gets a reference to the value of the objective function.
-     *
-     * @return a reference to the internal array storing the value of
-     * the objective function.
-     */
-    public double[] getValueRef() {
-        return super.getValue();
-    }
-
-    /**
-     * Replace the instance with a data transfer object for serialization.
-     * @return data transfer object that will be serialized
-     */
-    private Object writeReplace() {
-        return new DataTransferObject(getKey(), getValue());
-    }
-
-    /** Internal class used only for serialization. */
-    private static class DataTransferObject implements Serializable {
-        /** Serializable UID. */
-        private static final long serialVersionUID = 20120513L;
-        /**
-         * Point coordinates.
-         * @Serial
-         */
-        private final double[] point;
-        /**
-         * Value of the objective function at the point.
-         * @Serial
-         */
-        private final double[] value;
-
-        /** Simple constructor.
-         * @param point Point coordinates.
-         * @param value Value of the objective function at the point.
-         */
-        public DataTransferObject(final double[] point, final double[] value) {
-            this.point = point.clone();
-            this.value = value.clone();
-        }
-
-        /** Replace the deserialized data transfer object with a {@link PointValuePair}.
-         * @return replacement {@link PointValuePair}
-         */
-        private Object readResolve() {
-            return new PointVectorValuePair(point, value, false);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/SimpleBounds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/SimpleBounds.java b/src/main/java/org/apache/commons/math4/optimization/SimpleBounds.java
deleted file mode 100644
index 097ba8a..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/SimpleBounds.java
+++ /dev/null
@@ -1,63 +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;
-
-/**
- * Simple optimization constraints: lower and upper bounds.
- * The valid range of the parameters is an interval that can be infinite
- * (in one or both directions).
- * <br/>
- * Immutable class.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.1
- */
-@Deprecated
-public class SimpleBounds implements OptimizationData {
-    /** Lower bounds. */
-    private final double[] lower;
-    /** Upper bounds. */
-    private final double[] upper;
-
-    /**
-     * @param lB Lower bounds.
-     * @param uB Upper bounds.
-     */
-    public SimpleBounds(double[] lB,
-                        double[] uB) {
-        lower = lB.clone();
-        upper = uB.clone();
-    }
-
-    /**
-     * Gets the lower bounds.
-     *
-     * @return the initial guess.
-     */
-    public double[] getLower() {
-        return lower.clone();
-    }
-    /**
-     * Gets the lower bounds.
-     *
-     * @return the initial guess.
-     */
-    public double[] getUpper() {
-        return upper.clone();
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/SimplePointChecker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/SimplePointChecker.java b/src/main/java/org/apache/commons/math4/optimization/SimplePointChecker.java
deleted file mode 100644
index 0651725..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/SimplePointChecker.java
+++ /dev/null
@@ -1,145 +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.util.FastMath;
-import org.apache.commons.math4.util.Pair;
-
-/**
- * Simple implementation of the {@link ConvergenceChecker} interface using
- * only point coordinates.
- *
- * Convergence is considered to have been reached if either the relative
- * difference between each point coordinate are smaller than a threshold
- * or if either the absolute difference between the point coordinates are
- * smaller than another threshold.
- * <br/>
- * The {@link #converged(int,Pair,Pair) converged} method will also return
- * {@code true} if the number of iterations has been set (see
- * {@link #SimplePointChecker(double,double,int) this constructor}).
- *
- * @param <PAIR> Type of the (point, value) pair.
- * The type of the "value" part of the pair (not used by this class).
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class SimplePointChecker<PAIR extends Pair<double[], ? extends Object>>
-    extends AbstractConvergenceChecker<PAIR> {
-    /**
-     * If {@link #maxIterationCount} is set to this value, the number of
-     * iterations will never cause {@link #converged(int, Pair, Pair)}
-     * to return {@code true}.
-     */
-    private static final int ITERATION_CHECK_DISABLED = -1;
-    /**
-     * Number of iterations after which the
-     * {@link #converged(int, Pair, Pair)} method
-     * will return true (unless the check is disabled).
-     */
-    private final int maxIterationCount;
-
-    /**
-     * Build an instance with default threshold.
-     * @deprecated See {@link AbstractConvergenceChecker#AbstractConvergenceChecker()}
-     */
-    @Deprecated
-    public SimplePointChecker() {
-        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 SimplePointChecker(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 SimplePointChecker(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 times 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 arguments satify the convergence criterion.
-     */
-    @Override
-    public boolean converged(final int iteration,
-                             final PAIR previous,
-                             final PAIR current) {
-        if (maxIterationCount != ITERATION_CHECK_DISABLED && iteration >= maxIterationCount) {
-            return true;
-        }
-
-        final double[] p = previous.getKey();
-        final double[] c = current.getKey();
-        for (int i = 0; i < p.length; ++i) {
-            final double pi = p[i];
-            final double ci = c[i];
-            final double difference = FastMath.abs(pi - ci);
-            final double size = FastMath.max(FastMath.abs(pi), FastMath.abs(ci));
-            if (difference > size * getRelativeThreshold() &&
-                difference > getAbsoluteThreshold()) {
-                return false;
-            }
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/SimpleValueChecker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/SimpleValueChecker.java b/src/main/java/org/apache/commons/math4/optimization/SimpleValueChecker.java
deleted file mode 100644
index 45f44ba..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/SimpleValueChecker.java
+++ /dev/null
@@ -1,136 +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.util.FastMath;
-
-/**
- * Simple implementation of the {@link ConvergenceChecker} interface using
- * 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,PointValuePair,PointValuePair) converged}
- * method will also return {@code true} if the number of iterations has been set
- * (see {@link #SimpleValueChecker(double,double,int) this constructor}).
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class SimpleValueChecker
-    extends AbstractConvergenceChecker<PointValuePair> {
-    /**
-     * If {@link #maxIterationCount} is set to this value, the number of
-     * iterations will never cause
-     * {@link #converged(int,PointValuePair,PointValuePair)}
-     * to return {@code true}.
-     */
-    private static final int ITERATION_CHECK_DISABLED = -1;
-    /**
-     * Number of iterations after which the
-     * {@link #converged(int,PointValuePair,PointValuePair)} 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 SimpleValueChecker() {
-        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 SimpleValueChecker(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 SimpleValueChecker(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 PointValuePair previous,
-                             final PointValuePair 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();
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/SimpleVectorValueChecker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/SimpleVectorValueChecker.java b/src/main/java/org/apache/commons/math4/optimization/SimpleVectorValueChecker.java
deleted file mode 100644
index 8105988..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/SimpleVectorValueChecker.java
+++ /dev/null
@@ -1,145 +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.util.FastMath;
-
-/**
- * Simple implementation of the {@link ConvergenceChecker} interface using
- * 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 for all vectors elements.
- * <br/>
- * The {@link #converged(int,PointVectorValuePair,PointVectorValuePair) converged}
- * method will also return {@code true} if the number of iterations has been set
- * (see {@link #SimpleVectorValueChecker(double,double,int) this constructor}).
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public class SimpleVectorValueChecker
-    extends AbstractConvergenceChecker<PointVectorValuePair> {
-    /**
-     * If {@link #maxIterationCount} is set to this value, the number of
-     * iterations will never cause
-     * {@link #converged(int,PointVectorValuePair,PointVectorValuePair)}
-     * to return {@code true}.
-     */
-    private static final int ITERATION_CHECK_DISABLED = -1;
-    /**
-     * Number of iterations after which the
-     * {@link #converged(int,PointVectorValuePair,PointVectorValuePair)} 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 SimpleVectorValueChecker() {
-        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 SimpleVectorValueChecker(final double relativeThreshold,
-                                    final double absoluteThreshold) {
-        super(relativeThreshold, absoluteThreshold);
-        maxIterationCount = ITERATION_CHECK_DISABLED;
-    }
-
-    /**
-     * Builds an instance with specified tolerance thresholds and
-     * iteration count.
-     *
-     * 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 SimpleVectorValueChecker(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 times 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 arguments satify the convergence criterion.
-     */
-    @Override
-    public boolean converged(final int iteration,
-                             final PointVectorValuePair previous,
-                             final PointVectorValuePair current) {
-        if (maxIterationCount != ITERATION_CHECK_DISABLED && iteration >= maxIterationCount) {
-            return true;
-        }
-
-        final double[] p = previous.getValueRef();
-        final double[] c = current.getValueRef();
-        for (int i = 0; i < p.length; ++i) {
-            final double pi         = p[i];
-            final double ci         = c[i];
-            final double difference = FastMath.abs(pi - ci);
-            final double size       = FastMath.max(FastMath.abs(pi), FastMath.abs(ci));
-            if (difference > size * getRelativeThreshold() &&
-                difference > getAbsoluteThreshold()) {
-                return false;
-            }
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/Target.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/Target.java b/src/main/java/org/apache/commons/math4/optimization/Target.java
deleted file mode 100644
index 380d841..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/Target.java
+++ /dev/null
@@ -1,50 +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;
-
-/**
- * Target of the optimization procedure.
- * They are the values which the objective vector function must reproduce
- * When the parameters of the model have been optimized.
- * <br/>
- * Immutable class.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.1
- */
-@Deprecated
-public class Target implements OptimizationData {
-    /** Target values (of the objective vector function). */
-    private final double[] target;
-
-    /**
-     * @param observations Target values.
-     */
-    public Target(double[] observations) {
-        target = observations.clone();
-    }
-
-    /**
-     * Gets the initial guess.
-     *
-     * @return the initial guess.
-     */
-    public double[] getTarget() {
-        return target.clone();
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/Weight.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/Weight.java b/src/main/java/org/apache/commons/math4/optimization/Weight.java
deleted file mode 100644
index e5a3a9e..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/Weight.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;
-
-import org.apache.commons.math4.linear.DiagonalMatrix;
-import org.apache.commons.math4.linear.NonSquareMatrixException;
-import org.apache.commons.math4.linear.RealMatrix;
-
-/**
- * Weight matrix of the residuals between model and observations.
- * <br/>
- * Immutable class.
- *
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.1
- */
-@Deprecated
-public class Weight implements OptimizationData {
-    /** Weight matrix. */
-    private final RealMatrix weightMatrix;
-
-    /**
-     * Creates a diagonal weight matrix.
-     *
-     * @param weight List of the values of the diagonal.
-     */
-    public Weight(double[] weight) {
-        weightMatrix = new DiagonalMatrix(weight);
-    }
-
-    /**
-     * @param weight Weight matrix.
-     * @throws NonSquareMatrixException if the argument is not
-     * a square matrix.
-     */
-    public Weight(RealMatrix weight) {
-        if (weight.getColumnDimension() != weight.getRowDimension()) {
-            throw new NonSquareMatrixException(weight.getColumnDimension(),
-                                               weight.getRowDimension());
-        }
-
-        weightMatrix = weight.copy();
-    }
-
-    /**
-     * Gets the initial guess.
-     *
-     * @return the initial guess.
-     */
-    public RealMatrix getWeight() {
-        return weightMatrix.copy();
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b4669aad/src/main/java/org/apache/commons/math4/optimization/direct/AbstractSimplex.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optimization/direct/AbstractSimplex.java b/src/main/java/org/apache/commons/math4/optimization/direct/AbstractSimplex.java
deleted file mode 100644
index d30a0c6..0000000
--- a/src/main/java/org/apache/commons/math4/optimization/direct/AbstractSimplex.java
+++ /dev/null
@@ -1,347 +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.Comparator;
-
-import org.apache.commons.math4.analysis.MultivariateFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.exception.OutOfRangeException;
-import org.apache.commons.math4.exception.ZeroException;
-import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.optimization.OptimizationData;
-import org.apache.commons.math4.optimization.PointValuePair;
-
-/**
- * This class implements the simplex concept.
- * It is intended to be used in conjunction with {@link SimplexOptimizer}.
- * <br/>
- * The initial configuration of the simplex is set by the constructors
- * {@link #AbstractSimplex(double[])} or {@link #AbstractSimplex(double[][])}.
- * The other {@link #AbstractSimplex(int) constructor} will set all steps
- * to 1, thus building a default configuration from a unit hypercube.
- * <br/>
- * Users <em>must</em> call the {@link #build(double[]) build} method in order
- * to create the data structure that will be acted on by the other methods of
- * this class.
- *
- * @see SimplexOptimizer
- * @deprecated As of 3.1 (to be removed in 4.0).
- * @since 3.0
- */
-@Deprecated
-public abstract class AbstractSimplex implements OptimizationData {
-    /** Simplex. */
-    private PointValuePair[] simplex;
-    /** Start simplex configuration. */
-    private double[][] startConfiguration;
-    /** Simplex dimension (must be equal to {@code simplex.length - 1}). */
-    private final int dimension;
-
-    /**
-     * Build a unit hypercube simplex.
-     *
-     * @param n Dimension of the simplex.
-     */
-    protected AbstractSimplex(int n) {
-        this(n, 1d);
-    }
-
-    /**
-     * Build a hypercube simplex with the given side length.
-     *
-     * @param n Dimension of the simplex.
-     * @param sideLength Length of the sides of the hypercube.
-     */
-    protected AbstractSimplex(int n,
-                              double sideLength) {
-        this(createHypercubeSteps(n, sideLength));
-    }
-
-    /**
-     * The start configuration for simplex is built from a box parallel to
-     * the canonical axes of the space. The simplex is the subset of vertices
-     * of a box parallel to the canonical axes. It is built as the path followed
-     * while traveling from one vertex of the box to the diagonally opposite
-     * vertex moving only along the box edges. The first vertex of the box will
-     * be located at the start point of the optimization.
-     * As an example, in dimension 3 a simplex has 4 vertices. Setting the
-     * steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the
-     * start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }.
-     * The first vertex would be set to the start point at (1, 1, 1) and the
-     * last vertex would be set to the diagonally opposite vertex at (2, 11, 3).
-     *
-     * @param steps Steps along the canonical axes representing box edges. They
-     * may be negative but not zero.
-     * @throws NullArgumentException if {@code steps} is {@code null}.
-     * @throws ZeroException if one of the steps is zero.
-     */
-    protected AbstractSimplex(final double[] steps) {
-        if (steps == null) {
-            throw new NullArgumentException();
-        }
-        if (steps.length == 0) {
-            throw new ZeroException();
-        }
-        dimension = steps.length;
-
-        // Only the relative position of the n final vertices with respect
-        // to the first one are stored.
-        startConfiguration = new double[dimension][dimension];
-        for (int i = 0; i < dimension; i++) {
-            final double[] vertexI = startConfiguration[i];
-            for (int j = 0; j < i + 1; j++) {
-                if (steps[j] == 0) {
-                    throw new ZeroException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX);
-                }
-                System.arraycopy(steps, 0, vertexI, 0, j + 1);
-            }
-        }
-    }
-
-    /**
-     * The real initial simplex will be set up by moving the reference
-     * simplex such that its first point is located at the start point of the
-     * optimization.
-     *
-     * @param referenceSimplex Reference simplex.
-     * @throws NotStrictlyPositiveException if the reference simplex does not
-     * contain at least one point.
-     * @throws DimensionMismatchException if there is a dimension mismatch
-     * in the reference simplex.
-     * @throws IllegalArgumentException if one of its vertices is duplicated.
-     */
-    protected AbstractSimplex(final double[][] referenceSimplex) {
-        if (referenceSimplex.length <= 0) {
-            throw new NotStrictlyPositiveException(LocalizedFormats.SIMPLEX_NEED_ONE_POINT,
-                                                   referenceSimplex.length);
-        }
-        dimension = referenceSimplex.length - 1;
-
-        // Only the relative position of the n final vertices with respect
-        // to the first one are stored.
-        startConfiguration = new double[dimension][dimension];
-        final double[] ref0 = referenceSimplex[0];
-
-        // Loop over vertices.
-        for (int i = 0; i < referenceSimplex.length; i++) {
-            final double[] refI = referenceSimplex[i];
-
-            // Safety checks.
-            if (refI.length != dimension) {
-                throw new DimensionMismatchException(refI.length, dimension);
-            }
-            for (int j = 0; j < i; j++) {
-                final double[] refJ = referenceSimplex[j];
-                boolean allEquals = true;
-                for (int k = 0; k < dimension; k++) {
-                    if (refI[k] != refJ[k]) {
-                        allEquals = false;
-                        break;
-                    }
-                }
-                if (allEquals) {
-                    throw new MathIllegalArgumentException(LocalizedFormats.EQUAL_VERTICES_IN_SIMPLEX,
-                                                           i, j);
-                }
-            }
-
-            // Store vertex i position relative to vertex 0 position.
-            if (i > 0) {
-                final double[] confI = startConfiguration[i - 1];
-                for (int k = 0; k < dimension; k++) {
-                    confI[k] = refI[k] - ref0[k];
-                }
-            }
-        }
-    }
-
-    /**
-     * Get simplex dimension.
-     *
-     * @return the dimension of the simplex.
-     */
-    public int getDimension() {
-        return dimension;
-    }
-
-    /**
-     * Get simplex size.
-     * After calling the {@link #build(double[]) build} method, this method will
-     * will be equivalent to {@code getDimension() + 1}.
-     *
-     * @return the size of the simplex.
-     */
-    public int getSize() {
-        return simplex.length;
-    }
-
-    /**
-     * Compute the next simplex of the algorithm.
-     *
-     * @param evaluationFunction Evaluation function.
-     * @param comparator Comparator to use to sort simplex vertices from best
-     * to worst.
-     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException
-     * if the algorithm fails to converge.
-     */
-    public abstract void iterate(final MultivariateFunction evaluationFunction,
-                                 final Comparator<PointValuePair> comparator);
-
-    /**
-     * Build an initial simplex.
-     *
-     * @param startPoint First point of the simplex.
-     * @throws DimensionMismatchException if the start point does not match
-     * simplex dimension.
-     */
-    public void build(final double[] startPoint) {
-        if (dimension != startPoint.length) {
-            throw new DimensionMismatchException(dimension, startPoint.length);
-        }
-
-        // Set first vertex.
-        simplex = new PointValuePair[dimension + 1];
-        simplex[0] = new PointValuePair(startPoint, Double.NaN);
-
-        // Set remaining vertices.
-        for (int i = 0; i < dimension; i++) {
-            final double[] confI = startConfiguration[i];
-            final double[] vertexI = new double[dimension];
-            for (int k = 0; k < dimension; k++) {
-                vertexI[k] = startPoint[k] + confI[k];
-            }
-            simplex[i + 1] = new PointValuePair(vertexI, Double.NaN);
-        }
-    }
-
-    /**
-     * Evaluate all the non-evaluated points of the simplex.
-     *
-     * @param evaluationFunction Evaluation function.
-     * @param comparator Comparator to use to sort simplex vertices from best to worst.
-     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException
-     * if the maximal number of evaluations is exceeded.
-     */
-    public void evaluate(final MultivariateFunction evaluationFunction,
-                         final Comparator<PointValuePair> comparator) {
-        // Evaluate the objective function at all non-evaluated simplex points.
-        for (int i = 0; i < simplex.length; i++) {
-            final PointValuePair vertex = simplex[i];
-            final double[] point = vertex.getPointRef();
-            if (Double.isNaN(vertex.getValue())) {
-                simplex[i] = new PointValuePair(point, evaluationFunction.value(point), false);
-            }
-        }
-
-        // Sort the simplex from best to worst.
-        Arrays.sort(simplex, comparator);
-    }
-
-    /**
-     * Replace the worst point of the simplex by a new point.
-     *
-     * @param pointValuePair Point to insert.
-     * @param comparator Comparator to use for sorting the simplex vertices
-     * from best to worst.
-     */
-    protected void replaceWorstPoint(PointValuePair pointValuePair,
-                                     final Comparator<PointValuePair> comparator) {
-        for (int i = 0; i < dimension; i++) {
-            if (comparator.compare(simplex[i], pointValuePair) > 0) {
-                PointValuePair tmp = simplex[i];
-                simplex[i] = pointValuePair;
-                pointValuePair = tmp;
-            }
-        }
-        simplex[dimension] = pointValuePair;
-    }
-
-    /**
-     * Get the points of the simplex.
-     *
-     * @return all the simplex points.
-     */
-    public PointValuePair[] getPoints() {
-        final PointValuePair[] copy = new PointValuePair[simplex.length];
-        System.arraycopy(simplex, 0, copy, 0, simplex.length);
-        return copy;
-    }
-
-    /**
-     * Get the simplex point stored at the requested {@code index}.
-     *
-     * @param index Location.
-     * @return the point at location {@code index}.
-     */
-    public PointValuePair getPoint(int index) {
-        if (index < 0 ||
-            index >= simplex.length) {
-            throw new OutOfRangeException(index, 0, simplex.length - 1);
-        }
-        return simplex[index];
-    }
-
-    /**
-     * Store a new point at location {@code index}.
-     * Note that no deep-copy of {@code point} is performed.
-     *
-     * @param index Location.
-     * @param point New value.
-     */
-    protected void setPoint(int index, PointValuePair point) {
-        if (index < 0 ||
-            index >= simplex.length) {
-            throw new OutOfRangeException(index, 0, simplex.length - 1);
-        }
-        simplex[index] = point;
-    }
-
-    /**
-     * Replace all points.
-     * Note that no deep-copy of {@code points} is performed.
-     *
-     * @param points New Points.
-     */
-    protected void setPoints(PointValuePair[] points) {
-        if (points.length != simplex.length) {
-            throw new DimensionMismatchException(points.length, simplex.length);
-        }
-        simplex = points;
-    }
-
-    /**
-     * Create steps for a unit hypercube.
-     *
-     * @param n Dimension of the hypercube.
-     * @param sideLength Length of the sides of the hypercube.
-     * @return the steps.
-     */
-    private static double[] createHypercubeSteps(int n,
-                                                 double sideLength) {
-        final double[] steps = new double[n];
-        for (int i = 0; i < n; i++) {
-            steps[i] = sideLength;
-        }
-        return steps;
-    }
-}


Mime
View raw message