commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r748274 [2/3] - in /commons/proper/math/trunk: ./ src/java/org/apache/commons/math/analysis/ src/java/org/apache/commons/math/analysis/minimization/ src/java/org/apache/commons/math/estimation/ src/java/org/apache/commons/math/optimization/...
Date Thu, 26 Feb 2009 19:17:41 GMT
Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/MultiDirectional.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/MultiDirectional.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/MultiDirectional.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/NelderMead.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/NelderMead.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/NelderMead.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.optimization;
+package org.apache.commons.math.optimization.direct;
+
+import org.apache.commons.math.optimization.ObjectiveException;
+import org.apache.commons.math.optimization.PointValuePair;
 
 /** 
  * This class implements the Nelder-Mead direct search method.
@@ -24,153 +27,150 @@
  * @see MultiDirectional
  * @since 1.2
  */
-public class NelderMead
-  extends DirectSearchOptimizer {
-
-  /** Build a Nelder-Mead optimizer with default coefficients.
-   * <p>The default coefficients are 1.0 for rho, 2.0 for khi and 0.5
-   * for both gamma and sigma.</p>
-   */
-  public NelderMead() {
-    super();
-    this.rho   = 1.0;
-    this.khi   = 2.0;
-    this.gamma = 0.5;
-    this.sigma = 0.5;
-  }
-
-  /** Build a Nelder-Mead optimizer with specified coefficients.
-   * @param rho reflection coefficient
-   * @param khi expansion coefficient
-   * @param gamma contraction coefficient
-   * @param sigma shrinkage coefficient
-   */
-  public NelderMead(double rho, double khi, double gamma, double sigma) {
-    super();
-    this.rho   = rho;
-    this.khi   = khi;
-    this.gamma = gamma;
-    this.sigma = sigma;
-  }
-
-  /** Compute the next simplex of the algorithm.
-   * @exception CostException if the function cannot be evaluated at
-   * some point
-   */
-  protected void iterateSimplex()
-    throws CostException {
-
-    // the simplex has n+1 point if dimension is n
-    int n = simplex.length - 1;
-
-    // interesting costs
-    double   smallest      = simplex[0].getCost();
-    double   secondLargest = simplex[n-1].getCost();
-    double   largest       = simplex[n].getCost();
-    double[] xLargest      = simplex[n].getPoint();
-
-    // compute the centroid of the best vertices
-    // (dismissing the worst point at index n)
-    double[] centroid = new double[n];
-    for (int i = 0; i < n; ++i) {
-      double[] x = simplex[i].getPoint();
-      for (int j = 0; j < n; ++j) {
-        centroid[j] += x[j];
-      }
-    }
-    double scaling = 1.0 / n;
-    for (int j = 0; j < n; ++j) {
-      centroid[j] *= scaling;
-    }
-
-    // compute the reflection point
-    double[] xR       = new double[n];
-    for (int j = 0; j < n; ++j) {
-      xR[j] = centroid[j] + rho * (centroid[j] - xLargest[j]);
-    }
-    double costR = evaluateCost(xR);
-
-    if ((smallest <= costR) && (costR < secondLargest)) {
-
-      // accept the reflected point
-      replaceWorstPoint(new PointCostPair(xR, costR));
+public class NelderMead extends DirectSearchOptimizer {
 
-    } else if (costR < smallest) {
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = -5810365844886183056L;
 
-      // compute the expansion point
-      double[] xE = new double[n];
-      for (int j = 0; j < n; ++j) {
-        xE[j] = centroid[j] + khi * (xR[j] - centroid[j]);
-      }
-      double costE = evaluateCost(xE);
+    /** Reflection coefficient. */
+    private final double rho;
 
-      if (costE < costR) {
-        // accept the expansion point
-        replaceWorstPoint(new PointCostPair(xE, costE));
-      } else {
-        // accept the reflected point
-        replaceWorstPoint(new PointCostPair(xR, costR));
-      }
+    /** Expansion coefficient. */
+    private final double khi;
+
+    /** Contraction coefficient. */
+    private final double gamma;
+
+    /** Shrinkage coefficient. */
+    private final double sigma;
+
+    /** Build a Nelder-Mead optimizer with default coefficients.
+     * <p>The default coefficients are 1.0 for rho, 2.0 for khi and 0.5
+     * for both gamma and sigma.</p>
+     */
+    public NelderMead() {
+        this.rho   = 1.0;
+        this.khi   = 2.0;
+        this.gamma = 0.5;
+        this.sigma = 0.5;
+    }
 
-    } else {
+    /** Build a Nelder-Mead optimizer with specified coefficients.
+     * @param rho reflection coefficient
+     * @param khi expansion coefficient
+     * @param gamma contraction coefficient
+     * @param sigma shrinkage coefficient
+     */
+    public NelderMead(final double rho, final double khi,
+                      final double gamma, final double sigma) {
+        this.rho   = rho;
+        this.khi   = khi;
+        this.gamma = gamma;
+        this.sigma = sigma;
+    }
 
-      if (costR < largest) {
+    /** {@inheritDoc} */
+    protected void iterateSimplex() throws ObjectiveException {
 
-        // perform an outside contraction
-        double[] xC = new double[n];
-        for (int j = 0; j < n; ++j) {
-          xC[j] = centroid[j] + gamma * (xR[j] - centroid[j]);
-        }
-        double costC = evaluateCost(xC);
+        // the simplex has n+1 point if dimension is n
+        final int n = simplex.length - 1;
 
-        if (costC <= costR) {
-          // accept the contraction point
-          replaceWorstPoint(new PointCostPair(xC, costC));
-          return;
+        // interesting values
+        final double   smallest      = simplex[0].getValue();
+        final double   secondLargest = simplex[n-1].getValue();
+        final double   largest       = simplex[n].getValue();
+        final double[] xLargest      = simplex[n].getPoint();
+
+        // compute the centroid of the best vertices
+        // (dismissing the worst point at index n)
+        final double[] centroid = new double[n];
+        for (int i = 0; i < n; ++i) {
+            final double[] x = simplex[i].getPoint();
+            for (int j = 0; j < n; ++j) {
+                centroid[j] += x[j];
+            }
         }
-
-      } else {
-
-        // perform an inside contraction
-        double[] xC = new double[n];
+        final double scaling = 1.0 / n;
         for (int j = 0; j < n; ++j) {
-          xC[j] = centroid[j] - gamma * (centroid[j] - xLargest[j]);
-        }
-        double costC = evaluateCost(xC);
-
-        if (costC < largest) {
-          // accept the contraction point
-          replaceWorstPoint(new PointCostPair(xC, costC));
-          return;
+            centroid[j] *= scaling;
         }
 
-      }
-
-      // perform a shrink
-      double[] xSmallest = simplex[0].getPoint();
-      for (int i = 1; i < simplex.length; ++i) {
-        double[] x = simplex[i].getPoint();
+        // compute the reflection point
+        final double[] xR = new double[n];
         for (int j = 0; j < n; ++j) {
-          x[j] = xSmallest[j] + sigma * (x[j] - xSmallest[j]);
+            xR[j] = centroid[j] + rho * (centroid[j] - xLargest[j]);
         }
-        simplex[i] = new PointCostPair(x, Double.NaN);
-      }
-      evaluateSimplex();
+        final double valueR = evaluate(xR);
 
-    }
+        if ((smallest <= valueR) && (valueR < secondLargest)) {
 
-  }
+            // accept the reflected point
+            replaceWorstPoint(new PointValuePair(xR, valueR));
 
-  /** Reflection coefficient. */
-  private double rho;
+        } else if (valueR < smallest) {
 
-  /** Expansion coefficient. */
-  private double khi;
+            // compute the expansion point
+            final double[] xE = new double[n];
+            for (int j = 0; j < n; ++j) {
+                xE[j] = centroid[j] + khi * (xR[j] - centroid[j]);
+            }
+            final double valueE = evaluate(xE);
+
+            if (valueE < valueR) {
+                // accept the expansion point
+                replaceWorstPoint(new PointValuePair(xE, valueE));
+            } else {
+                // accept the reflected point
+                replaceWorstPoint(new PointValuePair(xR, valueR));
+            }
+
+        } else {
+
+            if (valueR < largest) {
+
+                // perform an outside contraction
+                final double[] xC = new double[n];
+                for (int j = 0; j < n; ++j) {
+                    xC[j] = centroid[j] + gamma * (xR[j] - centroid[j]);
+                }
+                final double valueC = evaluate(xC);
+
+                if (valueC <= valueR) {
+                    // accept the contraction point
+                    replaceWorstPoint(new PointValuePair(xC, valueC));
+                    return;
+                }
+
+            } else {
+
+                // perform an inside contraction
+                final double[] xC = new double[n];
+                for (int j = 0; j < n; ++j) {
+                    xC[j] = centroid[j] - gamma * (centroid[j] - xLargest[j]);
+                }
+                final double valueC = evaluate(xC);
+
+                if (valueC < largest) {
+                    // accept the contraction point
+                    replaceWorstPoint(new PointValuePair(xC, valueC));
+                    return;
+                }
+
+            }
+
+            // perform a shrink
+            final double[] xSmallest = simplex[0].getPoint();
+            for (int i = 1; i < simplex.length; ++i) {
+                final double[] x = simplex[i].getPoint();
+                for (int j = 0; j < n; ++j) {
+                    x[j] = xSmallest[j] + sigma * (x[j] - xSmallest[j]);
+                }
+                simplex[i] = new PointValuePair(x, Double.NaN);
+            }
+            evaluateSimplex();
 
-  /** Contraction coefficient. */
-  private double gamma;
+        }
 
-  /** Shrinkage coefficient. */
-  private double sigma;
+    }
 
 }

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/NelderMead.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html?rev=748274&view=auto
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html (added)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html Thu Feb 26 19:17:39 2009
@@ -0,0 +1,24 @@
+<html>
+<!--
+   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.
+  -->
+    <!-- $Revision$ -->
+<body>
+<p>
+This package provides optimization algorithms that don't require derivatives.
+</p>
+</body>
+</html>

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/package.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java (from r746578, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.util.Arrays;
 
@@ -23,6 +23,7 @@
 import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
 import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
+import org.apache.commons.math.optimization.OptimizationException;
 
 /**
  * Base class for implementing estimators.
@@ -98,14 +99,14 @@
 
     /** 
      * Update the residuals array and cost function value.
-     * @exception EstimationException if the number of cost evaluations
+     * @exception OptimizationException if the number of cost evaluations
      * exceeds the maximum allowed
      */
     protected void updateResidualsAndCost()
-    throws EstimationException {
+    throws OptimizationException {
 
         if (++costEvaluations > maxCostEval) {
-            throw new EstimationException("maximal number of evaluations exceeded ({0})",
+            throw new OptimizationException("maximal number of evaluations exceeded ({0})",
                                           maxCostEval);
         }
 
@@ -160,11 +161,11 @@
      * Get the covariance matrix of unbound estimated parameters.
      * @param problem estimation problem
      * @return covariance matrix
-     * @exception EstimationException if the covariance matrix
+     * @exception OptimizationException if the covariance matrix
      * cannot be computed (singular problem)
      */
     public double[][] getCovariances(EstimationProblem problem)
-      throws EstimationException {
+      throws OptimizationException {
  
         // set up the jacobian
         updateJacobian();
@@ -191,7 +192,7 @@
                 new LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj)).getSolver().getInverse();
             return inverse.getData();
         } catch (InvalidMatrixException ime) {
-            throw new EstimationException("unable to compute covariances: singular problem");
+            throw new OptimizationException("unable to compute covariances: singular problem");
         }
 
     }
@@ -201,16 +202,16 @@
      * <p>Guessing is covariance-based, it only gives rough order of magnitude.</p>
      * @param problem estimation problem
      * @return errors in estimated parameters
-     * @exception EstimationException if the covariances matrix cannot be computed
+     * @exception OptimizationException if the covariances matrix cannot be computed
      * or the number of degrees of freedom is not positive (number of measurements
      * lesser or equal to number of parameters)
      */
     public double[] guessParametersErrors(EstimationProblem problem)
-      throws EstimationException {
+      throws OptimizationException {
         int m = problem.getMeasurements().length;
         int p = problem.getUnboundParameters().length;
         if (m <= p) {
-            throw new EstimationException(
+            throw new OptimizationException(
                     "no degrees of freedom ({0} measurements, {1} parameters)",
                     m, p);
         }
@@ -261,11 +262,11 @@
      * EstimationProblem.getAllParameters} method.</p>
      *
      * @param problem estimation problem to solve
-     * @exception EstimationException if the problem cannot be solved
+     * @exception OptimizationException if the problem cannot be solved
      *
      */
     public abstract void estimate(EstimationProblem problem)
-    throws EstimationException;
+    throws OptimizationException;
 
     /** Array of measurements. */
     protected WeightedMeasurement[] measurements;

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractEstimator.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimatedParameter.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimatedParameter.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimatedParameter.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.io.Serializable;
 

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimatedParameter.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimationProblem.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimationProblem.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/EstimationProblem.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 /** 
  * This interface represents an estimation problem.
@@ -48,18 +48,18 @@
    * Get the measurements of an estimation problem.
    * @return measurements
    */
-  public WeightedMeasurement[] getMeasurements();
+  WeightedMeasurement[] getMeasurements();
 
   /** 
    * Get the unbound parameters of the problem.
    * @return unbound parameters
    */
-  public EstimatedParameter[] getUnboundParameters();
+  EstimatedParameter[] getUnboundParameters();
 
   /** 
    * Get all the parameters of the problem.
    * @return parameters
    */
-  public EstimatedParameter[] getAllParameters();
+  EstimatedParameter[] getAllParameters();
 
 }

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/EstimationProblem.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/Estimator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/Estimator.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/Estimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
+
+import org.apache.commons.math.optimization.OptimizationException;
 
 /**
  * This interface represents solvers for estimation problems.
@@ -48,11 +50,11 @@
    * EstimationProblem.getAllParameters} method.</p>
    *
    * @param problem estimation problem to solve
-   * @exception EstimationException if the problem cannot be solved
+   * @exception OptimizationException if the problem cannot be solved
    *
    */
-  public void estimate(EstimationProblem problem)
-    throws EstimationException;
+  void estimate(EstimationProblem problem)
+    throws OptimizationException;
 
   /** 
    * Get the Root Mean Square value.
@@ -66,26 +68,26 @@
    * @param problem estimation problem
    * @return RMS value
    */
-  public double getRMS(EstimationProblem problem);
+  double getRMS(EstimationProblem problem);
 
   /**
    * Get the covariance matrix of estimated parameters.
    * @param problem estimation problem
    * @return covariance matrix
-   * @exception EstimationException if the covariance matrix
+   * @exception OptimizationException if the covariance matrix
    * cannot be computed (singular problem)
    */
-  public double[][] getCovariances(EstimationProblem problem)
-    throws EstimationException;
+  double[][] getCovariances(EstimationProblem problem)
+    throws OptimizationException;
 
   /**
    * Guess the errors in estimated parameters.
    * @see #getRMS(EstimationProblem)
    * @param problem estimation problem
    * @return errors in estimated parameters
-     * @exception EstimationException if the error cannot be guessed
+     * @exception OptimizationException if the error cannot be guessed
    */
-  public double[] guessParametersErrors(EstimationProblem problem)
-    throws EstimationException;
+  double[] guessParametersErrors(EstimationProblem problem)
+    throws OptimizationException;
 
 }

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/Estimator.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java (from r746578, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.io.Serializable;
 
@@ -25,6 +25,7 @@
 import org.apache.commons.math.linear.RealVector;
 import org.apache.commons.math.linear.RealVectorImpl;
 import org.apache.commons.math.linear.decomposition.LUDecompositionImpl;
+import org.apache.commons.math.optimization.OptimizationException;
 
 /** 
  * This class implements a solver for estimation problems.
@@ -87,7 +88,7 @@
      *
      * <p>If neither conditions are fulfilled before a given number of
      * iterations, the algorithm is considered to have failed and an
-     * {@link EstimationException} is thrown.</p>
+     * {@link OptimizationException} is thrown.</p>
      *
      * @param maxCostEval maximal number of cost evaluations allowed
      * @param convergence criterion threshold below which we do not need
@@ -144,17 +145,17 @@
      * useless or when the algorithm is unable to improve it (even if it
      * is still high). The first condition that is met stops the
      * iterations. If the convergence it not reached before the maximum
-     * number of iterations, an {@link EstimationException} is
+     * number of iterations, an {@link OptimizationException} is
      * thrown.</p>
      *
      * @param problem estimation problem to solve
-     * @exception EstimationException if the problem cannot be solved
+     * @exception OptimizationException if the problem cannot be solved
      *
      * @see EstimationProblem
      *
      */
     public void estimate(EstimationProblem problem)
-    throws EstimationException {
+    throws OptimizationException {
 
         initializeEstimate(problem);
 
@@ -210,7 +211,7 @@
                 }
 
             } catch(InvalidMatrixException e) {
-                throw new EstimationException("unable to solve: singular problem");
+                throw new OptimizationException("unable to solve: singular problem");
             }
 
 

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonEstimator.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java (from r746578, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java Thu Feb 26 19:17:39 2009
@@ -14,11 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.io.Serializable;
 import java.util.Arrays;
 
+import org.apache.commons.math.optimization.OptimizationException;
+
 
 /** 
  * This class solves a least squares problem.
@@ -188,7 +190,7 @@
    * <p>Luc Maisonobe did the Java translation.</p>
    * 
    * @param problem estimation problem to solve
-   * @exception EstimationException if convergence cannot be
+   * @exception OptimizationException if convergence cannot be
    * reached with the specified algorithm settings or if there are more variables
    * than equations
    * @see #setInitialStepBoundFactor
@@ -197,7 +199,7 @@
    * @see #setOrthoTolerance
    */
   public void estimate(EstimationProblem problem)
-    throws EstimationException {
+    throws OptimizationException {
 
     initializeEstimate(problem);
 
@@ -397,17 +399,17 @@
         // tests for termination and stringent tolerances
         // (2.2204e-16 is the machine epsilon for IEEE754)
         if ((Math.abs(actRed) <= 2.2204e-16) && (preRed <= 2.2204e-16) && (ratio <= 2.0)) {
-          throw new EstimationException("cost relative tolerance is too small ({0})," +
+          throw new OptimizationException("cost relative tolerance is too small ({0})," +
                                         " no further reduction in the" +
                                         " sum of squares is possible",
                                         costRelativeTolerance);
         } else if (delta <= 2.2204e-16 * xNorm) {
-          throw new EstimationException("parameters relative tolerance is too small" +
+          throw new OptimizationException("parameters relative tolerance is too small" +
                                         " ({0}), no further improvement in" +
                                         " the approximate solution is possible",
                                         parRelativeTolerance);
         } else if (maxCosine <= 2.2204e-16)  {
-          throw new EstimationException("orthogonality tolerance is too small ({0})," +
+          throw new OptimizationException("orthogonality tolerance is too small ({0})," +
                                         " solution is orthogonal to the jacobian",
                                         orthoTolerance);
         }
@@ -732,9 +734,9 @@
    * are performed in non-increasing columns norms order thanks to columns
    * pivoting. The diagonal elements of the R matrix are therefore also in
    * non-increasing absolute values order.</p>
-   * @exception EstimationException if the decomposition cannot be performed
+   * @exception OptimizationException if the decomposition cannot be performed
    */
-  private void qrDecomposition() throws EstimationException {
+  private void qrDecomposition() throws OptimizationException {
 
     // initializations
     for (int k = 0; k < cols; ++k) {
@@ -761,7 +763,7 @@
           norm2 += aki * aki;
         }
         if (Double.isInfinite(norm2) || Double.isNaN(norm2)) {
-            throw new EstimationException(
+            throw new OptimizationException(
                     "unable to perform Q.R decomposition on the {0}x{1} jacobian matrix",
                     rows, cols);
         }

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/LevenbergMarquardtEstimator.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.util.ArrayList;
 import java.util.List;

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/SimpleEstimationProblem.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/WeightedMeasurement.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/WeightedMeasurement.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/WeightedMeasurement.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
 import java.io.Serializable;
 

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/WeightedMeasurement.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/package.html)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/package.html&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/package.html (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html Thu Feb 26 19:17:39 2009
@@ -17,39 +17,6 @@
   -->
     <!-- $Revision$ -->
 <body>
-This package provides classes to solve estimation problems.
-
-<p>The estimation problems considered here are parametric problems where a user model
-depends on initially unknown scalar parameters and several measurements made on
-values that depend on the model are available. As an example, one can consider the
-flow rate of a river given rain data on its vicinity, or the center and radius of a
-circle given points on a ring.</p>
-
-<p>One important class of estimation problems is weighted least squares problems.
-They basically consist in finding the values for some parameters p<sub>k</sub> such
-that a cost function J = sum(w<sub>i</sub> r<sub>i</sub><sup>2</sup>) is minimized.
-The various r<sub>i</sub> terms represent the deviation r<sub>i</sub> =
-mes<sub>i</sub> - mod<sub>i</sub> between the measurements and the parameterized
-models. The w<sub>i</sub> factors are the measurements weights, they are often chosen
-either all equal to 1.0 or proportional to the inverse of the variance of the
-measurement type. The solver adjusts the values of the estimated parameters
-p<sub>k</sub> which are not bound. It does not touch the parameters which have been
-put in a bound state by the user.</p>
- 
-<p>This package provides the {@link
-org.apache.commons.math.estimation.EstimatedParameter EstimatedParameter} class to
-represent each estimated parameter, and the {@link
-org.apache.commons.math.estimation.WeightedMeasurement WeightedMeasurement} abstract
-class the user can extend to define its measurements. All parameters and measurements
-are then provided to some {@link org.apache.commons.math.estimation.Estimator
-Estimator} packed together in an {@link
-org.apache.commons.math.estimation.EstimationProblem EstimationProblem} instance
-which acts only as a container. The package provides two common estimators for
-weighted least squares problems, one based on the {@link
-org.apache.commons.math.estimation.GaussNewtonEstimator Gauss-Newton} method and the
-other one based on the {@link
-org.apache.commons.math.estimation.LevenbergMarquardtEstimator Levenberg-Marquardt}
-method.</p>
-
+This package provides optimization algorithms that require derivatives.
 </body>
 </html>

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/package.html
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/package.html?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/package.html (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/package.html Thu Feb 26 19:17:39 2009
@@ -18,7 +18,36 @@
     <!-- $Revision$ -->
 <body>
 <p>
-This package provides parametric optimization algorithms.
+This package provides common interfaces for the optimization algorithms
+provided in sub-packages. The main interfaces are {@link
+org.apache.commons.math.optimization.ObjectiveFunction ObjectiveFunction}
+and {@link org.apache.commons.math.optimization.MultiObjectiveFunction
+MultiObjectiveFunction}. Both interfaces are intended to be implemented by
+user code to represent the problem they want to optimize.
+</p>
+<p>
+The {@link org.apache.commons.math.optimization.ObjectiveFunction ObjectiveFunction}
+interface represent a scalar function that should be either minimized or maximized,
+by changing its input variables set until an optimal set is found. This function is
+often called a cost function when the goal is to minimize it.
+</p>
+
+<p>
+The {@link org.apache.commons.math.optimization.MultiObjectiveFunction
+MultiObjectiveFunction} interface represent a vectorial function that should be either
+minimized or maximized, by changing its input variables set until an optimal set is
+found.
+</p>
+
+<p>
+The {@link org.apache.commons.math.optimization.LeastSquaresConverter
+LeastSquaresConverter} class can be used to convert vectorial objective functions to
+scalar objective functions when the goal is to minimize them. This class is mostly used
+when the vectorial objective function represents residuals, i.e. differences between a
+theoretical result computed from a variables set applied to a model and a reference.
+Residuals are intended to be minimized in order to get the variables set that best fit
+the model to the reference. The reference may be obtained for example from physical
+measurements whether the model is built from theoretical considerations.
 </p>
 </body>
 </html>

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/BrentMinimizer.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/BrentMinimizer.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/BrentMinimizer.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java Thu Feb 26 19:17:39 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math.analysis.minimization;
+package org.apache.commons.math.optimization.univariate;
 
 import org.apache.commons.math.FunctionEvaluationException;
 import org.apache.commons.math.MaxIterationsExceededException;

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/BrentMinimizer.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java (from r746504, commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizer.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizer.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizer.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java Thu Feb 26 19:17:39 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.math.analysis.minimization;
+package org.apache.commons.math.optimization.univariate;
 
 import org.apache.commons.math.ConvergenceException;
 import org.apache.commons.math.ConvergingAlgorithm;
@@ -47,8 +47,7 @@
      * satisfy the requirements specified by the minimizer
      */
     double minimize(UnivariateRealFunction f, double min, double max)
-        throws ConvergenceException, 
-        FunctionEvaluationException;
+        throws ConvergenceException, FunctionEvaluationException;
 
     /**
      * Find a minimum in the given interval, start at startValue.

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizer.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java (from r746578, commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizerImpl.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java?p2=commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java&p1=commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizerImpl.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizerImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java Thu Feb 26 19:17:39 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.analysis.minimization;
+package org.apache.commons.math.optimization.univariate;
 
 import org.apache.commons.math.ConvergingAlgorithmImpl;
 import org.apache.commons.math.MathRuntimeException;

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/UnivariateRealMinimizerImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/package.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/univariate/package.html
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: commons/proper/math/trunk/src/site/resources/userguide/TrajectoryDeterminationProblem.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/resources/userguide/TrajectoryDeterminationProblem.java?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/resources/userguide/TrajectoryDeterminationProblem.java (original)
+++ commons/proper/math/trunk/src/site/resources/userguide/TrajectoryDeterminationProblem.java Thu Feb 26 19:17:39 2009
@@ -15,12 +15,12 @@
  * limitations under the License.
  */
 
-import org.apache.commons.math.estimation.EstimationException;
-import org.apache.commons.math.estimation.EstimatedParameter;
-import org.apache.commons.math.estimation.EstimationProblem;
-import org.apache.commons.math.estimation.LevenbergMarquardtEstimator;
-import org.apache.commons.math.estimation.SimpleEstimationProblem;
-import org.apache.commons.math.estimation.WeightedMeasurement;
+import org.apache.commons.math.optimization.general.EstimationException;
+import org.apache.commons.math.optimization.general.EstimatedParameter;
+import org.apache.commons.math.optimization.general.EstimationProblem;
+import org.apache.commons.math.optimization.general.LevenbergMarquardtEstimator;
+import org.apache.commons.math.optimization.general.SimpleEstimationProblem;
+import org.apache.commons.math.optimization.general.WeightedMeasurement;
 
 public class TrajectoryDeterminationProblem extends SimpleEstimationProblem {
 

Modified: commons/proper/math/trunk/src/site/xdoc/userguide/analysis.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/analysis.xml?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/analysis.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/analysis.xml Thu Feb 26 19:17:39 2009
@@ -237,19 +237,7 @@
           </table>
         </p>
       </subsection>
-      <subsection name="4.3 Minimization" href="minimization">
-        <p>
-          A <a href="../apidocs/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizer.html">
-          org.apache.commons.math.analysis.minimization.UnivariateRealMinimizer</a>
-          is used to find the minimal values of a univariate real-valued function <code>f</code>.
-        </p>
-        <p>
-          Minimization algorithms usage is very similar to root-finding algorithms usage explained
-          above. The main difference is that the <code>solve</code> methods in root finding algorithms
-          is replaced by <code>minimize</code> methods.
-        </p>
-      </subsection>
-      <subsection name="4.4 Interpolation" href="interpolation">
+      <subsection name="4.3 Interpolation" href="interpolation">
         <p>
           A <a href="../apidocs/org/apache/commons/math/analysis/interpolation/UnivariateRealInterpolator.html">
           org.apache.commons.math.analysis.interpolation.UnivariateRealInterpolator</a>
@@ -300,7 +288,7 @@
           adding more points does not always lead to a better interpolation.
         </p>
       </subsection>
-      <subsection name="4.5 Integration" href="integration">
+      <subsection name="4.4 Integration" href="integration">
         <p>
           A <a href="../apidocs/org/apache/commons/math/analysis/integration/UnivariateRealIntegrator.html">
           org.apache.commons.math.analysis.integration.UnivariateRealIntegrator.</a>
@@ -317,7 +305,7 @@
           </ul>      
         </p>
       </subsection>
-      <subsection name="4.6 Polynomials" href="polynomials">
+      <subsection name="4.5 Polynomials" href="polynomials">
         <p>
           The <a href="../apidocs/org/apache/commons/math/analysis/polynomials/package-summary.html">
           org.apache.commons.math.analysis.polynomials</a> package provides real coefficients

Modified: commons/proper/math/trunk/src/site/xdoc/userguide/index.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/index.xml?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/index.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/index.xml Thu Feb 26 19:17:39 2009
@@ -67,10 +67,9 @@
                 <ul>
                 <li><a href="analysis.html#a4.1_Overview">4.1 Overview</a></li>
                 <li><a href="analysis.html#a4.2_Root-finding">4.2 Root-finding</a></li>                
-                <li><a href="analysis.html#a4.3_Minimization">4.3 Minimization</a></li>
-                <li><a href="analysis.html#a4.4_Interpolation">4.4 Interpolation</a></li>
-                <li><a href="analysis.html#a4.5_Integration">4.5 Integration</a></li>
-                <li><a href="analysis.html#a4.6_Polynomials">4.6 Polynomials</a></li>
+                <li><a href="analysis.html#a4.3_Interpolation">4.3 Interpolation</a></li>
+                <li><a href="analysis.html#a4.4_Integration">4.4 Integration</a></li>
+                <li><a href="analysis.html#a4.5_Polynomials">4.5 Polynomials</a></li>
                 </ul></li>     
             <li><a href="special.html">5. Special Functions</a>
                 <ul>
@@ -124,7 +123,10 @@
         <li><a href="optimization.html">13. Optimization</a>
                 <ul>
                 <li><a href="optimization.html#a13.1_Overview">13.1 Overview</a></li>
-                <li><a href="optimization.html#a13.2_Direct_Methods">13.2 Direct Methods</a></li>
+                <li><a href="analysis.html#a13.2_Univariate_Functions">13.2 Univariate Functions</a></li>
+                <li><a href="analysis.html#a13.3_Linear_Programming">13.3 Linear Programming</a></li>
+                <li><a href="optimization.html#a13.4_Direct_Methods">13.4 Direct Methods</a></li>
+                <li><a href="analysis.html#a13.5_General_Case">13.5 General Case</a></li>
                 </ul></li>                                 
         <li><a href="ode.html">14. Ordinary Differential Equations Integration</a>
                 <ul>

Modified: commons/proper/math/trunk/src/site/xdoc/userguide/optimization.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/optimization.xml?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/optimization.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/optimization.xml Thu Feb 26 19:17:39 2009
@@ -29,24 +29,37 @@
     <section name="13 Optimization">
       <subsection name="13.1 Overview" href="overview">
         <p>
-          The optimization package provides simplex-based direct search optimization algorithms.
-        </p>
-        <p>
-          The aim of this package is similar to the aim of the estimation package, but the
-          algorithms are entirely differents as:
+          The optimization package provides algorithms to optimize (i.e. minimize) some
+          objective or cost function. The package is split in several sub-packages
+          dedicated to different kind of functions or algorithms.
           <ul>
-            <li>
-              they do not need the partial derivatives of the measurements
-              with respect to the free parameters
-            </li>
-            <li>
-              they do not rely on residuals-based quadratic cost functions but
-              handle any cost functions, including non-continuous ones! 
-            </li>
+            <li>the univariate package handles univariate real functions,</li>
+            <li>the linear package handles multivariate vector linear functions
+                with linear constraints,</li>
+            <li>the direct package handles multivariate real functions using direct
+            search methods (i.e. not using derivatives),</li>
+            <li>the general package handles multivariate real or vector functions
+            using derivatives.</li>
           </ul>
         </p>
       </subsection>
-      <subsection name="13.2 Direct Methods" href="direct">
+      <subsection name="13.2 Univariate Functions" href="univariate">
+        <p>
+          A <a href="../apidocs/org/apache/commons/math/analysis/minimization/UnivariateRealMinimizer.html">
+          org.apache.commons.math.optimization.univariate.UnivariateRealMinimizer</a>
+          is used to find the minimal values of a univariate real-valued function <code>f</code>.
+        </p>
+        <p>
+          Minimization algorithms usage is very similar to root-finding algorithms usage explained
+          in the analysis package. The main difference is that the <code>solve</code> methods in root
+          finding algorithms is replaced by <code>minimize</code> methods.
+        </p>
+      </subsection>
+      <subsection name="13.3 Linear Programming" href="linear">
+        <p>
+        </p>
+      </subsection>
+      <subsection name="13.4 Direct Methods" href="direct">
         <p>
           Direct search methods only use cost function values, they don't
           need derivatives and don't either try to compute approximation of
@@ -77,13 +90,17 @@
           already provided by the <code>minimizes</code> method).
         </p>
         <p>
-          The package provides two solvers. The first one is the classical
-          <a href="../apidocs/org/apache/commons/math/optimization/NelderMead.html">
+          The <code>direct</code> package provides two solvers. The first one is the classical
+          <a href="../apidocs/org/apache/commons/math/optimization/direct/NelderMead.html">
           Nelder-Mead</a> method. The second one is Virginia Torczon's
-          <a href="../apidocs/org/apache/commons/math/optimization/MultiDirectional.html">
+          <a href="../apidocs/org/apache/commons/math/optimization/direct/MultiDirectional.html">
           multi-directional</a> method.
         </p>
       </subsection>
+      <subsection name="13.5 General Case" href="general">
+        <p>
+        </p>
+      </subsection>
      </section>
   </body>
 </document>

Modified: commons/proper/math/trunk/src/site/xdoc/userguide/overview.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/overview.xml?rev=748274&r1=748273&r2=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/overview.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/overview.xml Thu Feb 26 19:17:39 2009
@@ -85,7 +85,7 @@
       <li><a href="transform.html">org.apache.commons.math.transform</a> - transform methods (Fast Fourier)</li>
       <li><a href="geometry.html">org.apache.commons.math.geometry</a> - 3D geometry (vectors and rotations)</li>
       <li><a href="estimation.html">org.apache.commons.math.estimation</a> - parametric estimation problems</li>
-      <li><a href="optimization.html">org.apache.commons.math.optimization</a> - multi-dimensional functions minimization</li>
+      <li><a href="optimization.html">org.apache.commons.math.optimization</a> - functions minimization</li>
       <li><a href="ode.html">org.apache.commons.math.ode</a> - Ordinary Differential Equations integration</li>
     </ol>
     Package javadocs are <a href="../apidocs/index.html">here</a>

Copied: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java (from r746578, commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/MultiDirectionalTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java?p2=commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java&p1=commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/MultiDirectionalTest.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/MultiDirectionalTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java Thu Feb 26 19:17:39 2009
@@ -15,14 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.optimization;
+package org.apache.commons.math.optimization.direct;
 
+import org.apache.commons.math.linear.decomposition.NotPositiveDefiniteMatrixException;
 import org.apache.commons.math.optimization.ConvergenceChecker;
-import org.apache.commons.math.optimization.CostException;
-import org.apache.commons.math.optimization.CostFunction;
-import org.apache.commons.math.optimization.MultiDirectional;
+import org.apache.commons.math.optimization.ObjectiveException;
+import org.apache.commons.math.optimization.ObjectiveFunction;
+import org.apache.commons.math.optimization.PointValuePair;
 import org.apache.commons.math.ConvergenceException;
-import org.apache.commons.math.optimization.PointCostPair;
 
 import junit.framework.*;
 
@@ -33,34 +33,35 @@
     super(name);
   }
 
-  public void testCostExceptions() throws ConvergenceException {
-      CostFunction wrong =
-          new CostFunction() {
-            public double cost(double[] x) throws CostException {
+  public void testObjectiveExceptions() throws ConvergenceException {
+      ObjectiveFunction wrong =
+          new ObjectiveFunction() {
+            private static final long serialVersionUID = 4751314470965489371L;
+            public double objective(double[] x) throws ObjectiveException {
                 if (x[0] < 0) {
-                    throw new CostException("{0}", "oops");
+                    throw new ObjectiveException("{0}", "oops");
                 } else if (x[0] > 1) {
-                    throw new CostException(new RuntimeException("oops"));
+                    throw new ObjectiveException(new RuntimeException("oops"));
                 } else {
                     return x[0] * (1 - x[0]);
                 }
             }
       };
       try {
-          new MultiDirectional(1.9, 0.4).minimize(wrong, 10, new ValueChecker(1.0e-3),
+          new MultiDirectional(1.9, 0.4).optimize(wrong, 10, new ValueChecker(1.0e-3), true,
                                                   new double[] { -0.5 }, new double[] { 0.5 });
           fail("an exception should have been thrown");
-      } catch (CostException ce) {
+      } catch (ObjectiveException ce) {
           // expected behavior
           assertNull(ce.getCause());
       } catch (Exception e) {
           fail("wrong exception caught: " + e.getMessage());
       } 
       try {
-          new MultiDirectional(1.9, 0.4).minimize(wrong, 10, new ValueChecker(1.0e-3),
-                                                  new double[] { 0.5 }, new double[] { 1.5 });
+          new MultiDirectional(1.9, 0.4).optimize(wrong, 10, new ValueChecker(1.0e-3), true,
+                  new double[] { 0.5 }, new double[] { 1.5 });
           fail("an exception should have been thrown");
-      } catch (CostException ce) {
+      } catch (ObjectiveException ce) {
           // expected behavior
           assertNotNull(ce.getCause());
       } catch (Exception e) {
@@ -68,12 +69,96 @@
       } 
   }
 
+  public void testMinimizeMaximize()
+      throws ObjectiveException, ConvergenceException, NotPositiveDefiniteMatrixException {
+
+      // the following function has 4 local extrema:
+      final double xM        = -3.841947088256863675365;
+      final double yM        = -1.391745200270734924416;
+      final double xP        =  0.2286682237349059125691;
+      final double yP        = -yM;
+      final double valueXmYm =  0.2373295333134216789769; // local  maximum
+      final double valueXmYp = -valueXmYm;                // local  minimum
+      final double valueXpYm = -0.7290400707055187115322; // global minimum
+      final double valueXpYp = -valueXpYm;                // global maximum
+      ObjectiveFunction fourExtrema = new ObjectiveFunction() {
+          private static final long serialVersionUID = -7039124064449091152L;
+          public double objective(double[] variables) {
+              final double x = variables[0];
+              final double y = variables[1];
+              return Math.atan(x) * Math.atan(x + 2) * Math.atan(y) * Math.atan(y) / (x * y);
+          }
+      };
+
+      MultiDirectional md = new MultiDirectional();
+
+      // minimization
+      md.optimize(fourExtrema, 200, new ValueChecker(1.0e-8), true,
+                  new double[] { -4, -2 }, new double[] { 1, 2 }, 10, 38821113105892l);
+      PointValuePair[] optima = md.getOptima();
+      assertEquals(10, optima.length);
+      int localCount  = 0;
+      int globalCount = 0;
+      for (PointValuePair optimum : optima) {
+          if (optimum != null) {
+              if (optimum.getPoint()[0] < 0) {
+                  // this should be the local minimum
+                  ++localCount;
+                  assertEquals(xM,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yP,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXmYp, optimum.getValue(),     3.0e-8);
+              } else {
+                  // this should be the global minimum
+                  ++globalCount;
+                  assertEquals(xP,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yM,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXpYm, optimum.getValue(),     3.0e-8);              
+              }
+          }
+      }
+      assertTrue(localCount  > 0);
+      assertTrue(globalCount > 0);
+      assertTrue(md.getTotalEvaluations() > 1400);
+      assertTrue(md.getTotalEvaluations() < 1700);
+
+      // minimization
+      md.optimize(fourExtrema, 200, new ValueChecker(1.0e-8), false,
+                  new double[] { -3.5, -1 }, new double[] { 0.5, 1.5 }, 10, 38821113105892l);
+      optima = md.getOptima();
+      assertEquals(10, optima.length);
+      localCount  = 0;
+      globalCount = 0;
+      for (PointValuePair optimum : optima) {
+          if (optimum != null) {
+              if (optimum.getPoint()[0] < 0) {
+                  // this should be the local maximum
+                  ++localCount;
+                  assertEquals(xM,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yM,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXmYm, optimum.getValue(),     4.0e-8);
+              } else {
+                  // this should be the global maximum
+                  ++globalCount;
+                  assertEquals(xP,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yP,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXpYp, optimum.getValue(),     4.0e-8);              
+              }
+          }
+      }
+      assertTrue(localCount  > 0);
+      assertTrue(globalCount > 0);
+      assertTrue(md.getTotalEvaluations() > 1400);
+      assertTrue(md.getTotalEvaluations() < 1700);
+
+  }
+
   public void testRosenbrock()
-    throws CostException, ConvergenceException {
+    throws ObjectiveException, ConvergenceException {
 
-    CostFunction rosenbrock =
-      new CostFunction() {
-        public double cost(double[] x) {
+    ObjectiveFunction rosenbrock =
+      new ObjectiveFunction() {
+        private static final long serialVersionUID = -9044950469615237490L;
+        public double objective(double[] x) {
           ++count;
           double a = x[1] - x[0] * x[0];
           double b = 1.0 - x[0];
@@ -82,23 +167,24 @@
       };
 
     count = 0;
-    PointCostPair optimum =
-      new MultiDirectional().minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
+    PointValuePair optimum =
+      new MultiDirectional().optimize(rosenbrock, 100, new ValueChecker(1.0e-3), true,
                                       new double[][] {
                                         { -1.2,  1.0 }, { 0.9, 1.2 } , {  3.5, -2.3 }
                                       });
 
     assertTrue(count > 60);
-    assertTrue(optimum.getCost() > 0.01);
+    assertTrue(optimum.getValue() > 0.01);
 
   }
 
   public void testPowell()
-    throws CostException, ConvergenceException {
+    throws ObjectiveException, ConvergenceException {
 
-    CostFunction powell =
-      new CostFunction() {
-        public double cost(double[] x) {
+    ObjectiveFunction powell =
+      new ObjectiveFunction() {
+        private static final long serialVersionUID = -832162886102041840L;
+        public double objective(double[] x) {
           ++count;
           double a = x[0] + 10 * x[1];
           double b = x[2] - x[3];
@@ -109,12 +195,12 @@
       };
 
     count = 0;
-    PointCostPair optimum =
-      new MultiDirectional().minimize(powell, 1000, new ValueChecker(1.0e-3),
+    PointValuePair optimum =
+      new MultiDirectional().optimize(powell, 1000, new ValueChecker(1.0e-3), true,
                                       new double[] {  3.0, -1.0, 0.0, 1.0 },
                                       new double[] {  4.0,  0.0, 1.0, 2.0 });
     assertTrue(count > 850);
-    assertTrue(optimum.getCost() > 0.015);
+    assertTrue(optimum.getValue() > 0.015);
 
   }
 
@@ -124,10 +210,10 @@
       this.threshold = threshold;
     }
 
-    public boolean converged(PointCostPair[] simplex) {
-      PointCostPair smallest = simplex[0];
-      PointCostPair largest  = simplex[simplex.length - 1];
-      return (largest.getCost() - smallest.getCost()) < threshold;
+    public boolean converged(PointValuePair[] simplex) {
+      PointValuePair smallest = simplex[0];
+      PointValuePair largest  = simplex[simplex.length - 1];
+      return (largest.getValue() - smallest.getValue()) < threshold;
     }
 
     private double threshold;

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java (from r746578, commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/NelderMeadTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java?p2=commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java&p1=commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/NelderMeadTest.java&r1=746578&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/NelderMeadTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java Thu Feb 26 19:17:39 2009
@@ -15,15 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.optimization;
+package org.apache.commons.math.optimization.direct;
 
 import org.apache.commons.math.linear.decomposition.NotPositiveDefiniteMatrixException;
 import org.apache.commons.math.optimization.ConvergenceChecker;
-import org.apache.commons.math.optimization.CostException;
-import org.apache.commons.math.optimization.CostFunction;
-import org.apache.commons.math.optimization.NelderMead;
+import org.apache.commons.math.optimization.ObjectiveException;
+import org.apache.commons.math.optimization.ObjectiveFunction;
+import org.apache.commons.math.optimization.PointValuePair;
 import org.apache.commons.math.ConvergenceException;
-import org.apache.commons.math.optimization.PointCostPair;
 import org.apache.commons.math.random.JDKRandomGenerator;
 import org.apache.commons.math.random.RandomGenerator;
 import org.apache.commons.math.random.RandomVectorGenerator;
@@ -39,34 +38,35 @@
     super(name);
   }
 
-  public void testCostExceptions() throws ConvergenceException {
-      CostFunction wrong =
-          new CostFunction() {
-            public double cost(double[] x) throws CostException {
+  public void testObjectiveExceptions() throws ConvergenceException {
+      ObjectiveFunction wrong =
+          new ObjectiveFunction() {
+            private static final long serialVersionUID = 2624035220997628868L;
+            public double objective(double[] x) throws ObjectiveException {
                 if (x[0] < 0) {
-                    throw new CostException("{0}", "oops");
+                    throw new ObjectiveException("{0}", "oops");
                 } else if (x[0] > 1) {
-                    throw new CostException(new RuntimeException("oops"));
+                    throw new ObjectiveException(new RuntimeException("oops"));
                 } else {
                     return x[0] * (1 - x[0]);
                 }
             }
       };
       try {
-          new NelderMead(0.9, 1.9, 0.4, 0.6).minimize(wrong, 10, new ValueChecker(1.0e-3),
+          new NelderMead(0.9, 1.9, 0.4, 0.6).optimize(wrong, 10, new ValueChecker(1.0e-3), true,
                                                       new double[] { -0.5 }, new double[] { 0.5 });
           fail("an exception should have been thrown");
-      } catch (CostException ce) {
+      } catch (ObjectiveException ce) {
           // expected behavior
           assertNull(ce.getCause());
       } catch (Exception e) {
           fail("wrong exception caught: " + e.getMessage());
       } 
       try {
-          new NelderMead(0.9, 1.9, 0.4, 0.6).minimize(wrong, 10, new ValueChecker(1.0e-3),
+          new NelderMead(0.9, 1.9, 0.4, 0.6).optimize(wrong, 10, new ValueChecker(1.0e-3), true,
                                                       new double[] { 0.5 }, new double[] { 1.5 });
           fail("an exception should have been thrown");
-      } catch (CostException ce) {
+      } catch (ObjectiveException ce) {
           // expected behavior
           assertNotNull(ce.getCause());
       } catch (Exception e) {
@@ -74,12 +74,96 @@
       } 
   }
 
+  public void testMinimizeMaximize()
+      throws ObjectiveException, ConvergenceException, NotPositiveDefiniteMatrixException {
+
+      // the following function has 4 local extrema:
+      final double xM        = -3.841947088256863675365;
+      final double yM        = -1.391745200270734924416;
+      final double xP        =  0.2286682237349059125691;
+      final double yP        = -yM;
+      final double valueXmYm =  0.2373295333134216789769; // local  maximum
+      final double valueXmYp = -valueXmYm;                // local  minimum
+      final double valueXpYm = -0.7290400707055187115322; // global minimum
+      final double valueXpYp = -valueXpYm;                // global maximum
+      ObjectiveFunction fourExtrema = new ObjectiveFunction() {
+        private static final long serialVersionUID = -7039124064449091152L;
+        public double objective(double[] variables) {
+              final double x = variables[0];
+              final double y = variables[1];
+              return Math.atan(x) * Math.atan(x + 2) * Math.atan(y) * Math.atan(y) / (x * y);
+          }
+      };
+
+      NelderMead nm = new NelderMead();
+
+      // minimization
+      nm.optimize(fourExtrema, 100, new ValueChecker(1.0e-8), true,
+                  new double[] { -5, -5 }, new double[] { 5, 5 }, 10, 38821113105892l);
+      PointValuePair[] optima = nm.getOptima();
+      assertEquals(10, optima.length);
+      int localCount  = 0;
+      int globalCount = 0;
+      for (PointValuePair optimum : optima) {
+          if (optimum != null) {
+              if (optimum.getPoint()[0] < 0) {
+                  // this should be the local minimum
+                  ++localCount;
+                  assertEquals(xM,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yP,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXmYp, optimum.getValue(),     2.0e-8);
+              } else {
+                  // this should be the global minimum
+                  ++globalCount;
+                  assertEquals(xP,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yM,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXpYm, optimum.getValue(),     2.0e-8);              
+              }
+          }
+      }
+      assertTrue(localCount  > 0);
+      assertTrue(globalCount > 0);
+      assertTrue(nm.getTotalEvaluations() > 600);
+      assertTrue(nm.getTotalEvaluations() < 800);
+
+      // minimization
+      nm.optimize(fourExtrema, 100, new ValueChecker(1.0e-8), false,
+                  new double[] { -5, -5 }, new double[] { 5, 5 }, 10, 38821113105892l);
+      optima = nm.getOptima();
+      assertEquals(10, optima.length);
+      localCount  = 0;
+      globalCount = 0;
+      for (PointValuePair optimum : optima) {
+          if (optimum != null) {
+              if (optimum.getPoint()[0] < 0) {
+                  // this should be the local maximum
+                  ++localCount;
+                  assertEquals(xM,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yM,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXmYm, optimum.getValue(),     2.0e-8);
+              } else {
+                  // this should be the global maximum
+                  ++globalCount;
+                  assertEquals(xP,        optimum.getPoint()[0], 1.0e-3);
+                  assertEquals(yP,        optimum.getPoint()[1], 1.0e-3);
+                  assertEquals(valueXpYp, optimum.getValue(),     2.0e-8);              
+              }
+          }
+      }
+      assertTrue(localCount  > 0);
+      assertTrue(globalCount > 0);
+      assertTrue(nm.getTotalEvaluations() > 600);
+      assertTrue(nm.getTotalEvaluations() < 800);
+
+  }
+
   public void testRosenbrock()
-    throws CostException, ConvergenceException, NotPositiveDefiniteMatrixException {
+    throws ObjectiveException, ConvergenceException, NotPositiveDefiniteMatrixException {
 
-    CostFunction rosenbrock =
-      new CostFunction() {
-        public double cost(double[] x) {
+    ObjectiveFunction rosenbrock =
+      new ObjectiveFunction() {
+        private static final long serialVersionUID = -7039124064449091152L;
+        public double objective(double[] x) {
           ++count;
           double a = x[1] - x[0] * x[0];
           double b = 1.0 - x[0];
@@ -90,7 +174,7 @@
     count = 0;
     NelderMead nm = new NelderMead();
     try {
-      nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
+      nm.optimize(rosenbrock, 100, new ValueChecker(1.0e-3), true,
                   new double[][] {
                     { -1.2, 1.0 }, { 3.5, -2.3 }, { 0.4, 1.5 }
                   }, 1, 5384353l);
@@ -103,19 +187,19 @@
     }
 
     count = 0;
-    PointCostPair optimum =
-        nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3),
+    PointValuePair optimum =
+        nm.optimize(rosenbrock, 100, new ValueChecker(1.0e-3), true,
                     new double[][] {
                       { -1.2, 1.0 }, { 0.9, 1.2 }, { 3.5, -2.3 }
                     }, 10, 1642738l);
 
     assertTrue(count > 700);
     assertTrue(count < 800);
-    assertEquals(0.0, optimum.getCost(), 5.0e-5);
+    assertEquals(0.0, optimum.getValue(), 5.0e-5);
     assertEquals(1.0, optimum.getPoint()[0], 0.01);
     assertEquals(1.0, optimum.getPoint()[1], 0.01);
 
-    PointCostPair[] minima = nm.getMinima();
+    PointValuePair[] minima = nm.getOptima();
     assertEquals(10, minima.length);
     assertNotNull(minima[0]);
     assertNull(minima[minima.length - 1]);
@@ -126,7 +210,7 @@
             }
         } else {
             if (i > 0) {
-                assertTrue(minima[i-1].getCost() <= minima[i].getCost());
+                assertTrue(minima[i-1].getValue() <= minima[i].getValue());
             }
         }
     }
@@ -138,20 +222,21 @@
                                               new double[] { 0.2, 0.2 },
                                               new UniformRandomGenerator(rg));
     optimum =
-        nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3), rvg);
-    assertEquals(0.0, optimum.getCost(), 2.0e-4);
+        nm.optimize(rosenbrock, 100, new ValueChecker(1.0e-3), true, rvg);
+    assertEquals(0.0, optimum.getValue(), 2.0e-4);
     optimum =
-        nm.minimize(rosenbrock, 100, new ValueChecker(1.0e-3), rvg, 3);
-    assertEquals(0.0, optimum.getCost(), 3.0e-5);
+        nm.optimize(rosenbrock, 100, new ValueChecker(1.0e-3), true, rvg, 3);
+    assertEquals(0.0, optimum.getValue(), 3.0e-5);
 
   }
 
   public void testPowell()
-    throws CostException, ConvergenceException {
+    throws ObjectiveException, ConvergenceException {
 
-    CostFunction powell =
-      new CostFunction() {
-        public double cost(double[] x) {
+    ObjectiveFunction powell =
+      new ObjectiveFunction() {
+        private static final long serialVersionUID = -7681075710859391520L;
+        public double objective(double[] x) {
           ++count;
           double a = x[0] + 10 * x[1];
           double b = x[2] - x[3];
@@ -163,13 +248,13 @@
 
     count = 0;
     NelderMead nm = new NelderMead();
-    PointCostPair optimum =
-      nm.minimize(powell, 200, new ValueChecker(1.0e-3),
+    PointValuePair optimum =
+      nm.optimize(powell, 200, new ValueChecker(1.0e-3), true,
                   new double[] {  3.0, -1.0, 0.0, 1.0 },
                   new double[] {  4.0,  0.0, 1.0, 2.0 },
                   1, 1642738l);
     assertTrue(count < 150);
-    assertEquals(0.0, optimum.getCost(), 6.0e-4);
+    assertEquals(0.0, optimum.getValue(), 6.0e-4);
     assertEquals(0.0, optimum.getPoint()[0], 0.07);
     assertEquals(0.0, optimum.getPoint()[1], 0.07);
     assertEquals(0.0, optimum.getPoint()[2], 0.07);
@@ -183,10 +268,10 @@
       this.threshold = threshold;
     }
 
-    public boolean converged(PointCostPair[] simplex) {
-      PointCostPair smallest = simplex[0];
-      PointCostPair largest  = simplex[simplex.length - 1];
-      return (largest.getCost() - smallest.getCost()) < threshold;
+    public boolean converged(PointValuePair[] simplex) {
+      PointValuePair smallest = simplex[0];
+      PointValuePair largest  = simplex[simplex.length - 1];
+      return (largest.getValue() - smallest.getValue()) < threshold;
     }
 
     private double threshold;

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/direct/NelderMeadTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/EstimatedParameterTest.java (from r746504, commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/EstimatedParameterTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/EstimatedParameterTest.java?p2=commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/EstimatedParameterTest.java&p1=commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/EstimatedParameterTest.java&r1=746504&r2=748274&rev=748274&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/EstimatedParameterTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/EstimatedParameterTest.java Thu Feb 26 19:17:39 2009
@@ -15,9 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.estimation;
+package org.apache.commons.math.optimization.general;
 
-import org.apache.commons.math.estimation.EstimatedParameter;
 
 import junit.framework.*;
 



Mime
View raw message