Return-Path:
Delivered-To: apmail-commons-commits-archive@minotaur.apache.org
Received: (qmail 71997 invoked from network); 6 Jun 2010 14:02:13 -0000
Received: from unknown (HELO mail.apache.org) (140.211.11.3)
by 140.211.11.9 with SMTP; 6 Jun 2010 14:02:13 -0000
Received: (qmail 69540 invoked by uid 500); 6 Jun 2010 14:02:13 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 69285 invoked by uid 500); 6 Jun 2010 14:02:13 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 69278 invoked by uid 99); 6 Jun 2010 14:02:13 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jun 2010 14:02:13 +0000
X-ASF-Spam-Status: No, hits=-1139.1 required=10.0
tests=ALL_TRUSTED,AWL
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jun 2010 14:02:12 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 5284F23889C5; Sun, 6 Jun 2010 14:01:52 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r951864 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math/optimization/general/ site/xdoc/
test/java/org/apache/commons/math/optimization/general/
Date: Sun, 06 Jun 2010 14:01:52 -0000
To: commits@commons.apache.org
From: luc@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20100606140152.5284F23889C5@eris.apache.org>
Author: luc
Date: Sun Jun 6 14:01:51 2010
New Revision: 951864
URL: http://svn.apache.org/viewvc?rev=951864&view=rev
Log:
Added a setQRRankingThreshold method to Levenberg-Marquardt optimizer to improve robustness of rank determination.
JIRA: MATH-352
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java
commons/proper/math/trunk/src/site/xdoc/changes.xml
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java?rev=951864&r1=951863&r2=951864&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java Sun Jun 6 14:01:51 2010
@@ -21,6 +21,7 @@ import java.util.Arrays;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.VectorialPointValuePair;
+import org.apache.commons.math.util.MathUtils;
/**
@@ -140,16 +141,20 @@ public class LevenbergMarquardtOptimizer
* and the columns of the jacobian. */
private double orthoTolerance;
+ /** Threshold for QR ranking. */
+ private double qrRankingThreshold;
+
/**
* Build an optimizer for least squares problems.
* The default values for the algorithm settings are:
*
- * - {@link #setConvergenceChecker vectorial convergence checker}: null
- * - {@link #setInitialStepBoundFactor initial step bound factor}: 100.0
- * - {@link #setMaxIterations maximal iterations}: 1000
- * - {@link #setCostRelativeTolerance cost relative tolerance}: 1.0e-10
- * - {@link #setParRelativeTolerance parameters relative tolerance}: 1.0e-10
- * - {@link #setOrthoTolerance orthogonality tolerance}: 1.0e-10
+ * - {@link #setConvergenceChecker(VectorialConvergenceChecker) vectorial convergence checker}: null
+ * - {@link #setInitialStepBoundFactor(double) initial step bound factor}: 100.0
+ * - {@link #setMaxIterations(int) maximal iterations}: 1000
+ * - {@link #setCostRelativeTolerance(double) cost relative tolerance}: 1.0e-10
+ * - {@link #setParRelativeTolerance(double) parameters relative tolerance}: 1.0e-10
+ * - {@link #setOrthoTolerance(double) orthogonality tolerance}: 1.0e-10
+ * - {@link #setQRRankingThreshold(double) QR ranking threshold}: {@link MathUtils#SAFE_MIN}
*
*
* These default values may be overridden after construction. If the {@link
@@ -168,6 +173,7 @@ public class LevenbergMarquardtOptimizer
setCostRelativeTolerance(1.0e-10);
setParRelativeTolerance(1.0e-10);
setOrthoTolerance(1.0e-10);
+ setQRRankingThreshold(MathUtils.SAFE_MIN);
}
@@ -216,6 +222,19 @@ public class LevenbergMarquardtOptimizer
this.orthoTolerance = orthoTolerance;
}
+ /**
+ * Set the desired threshold for QR ranking.
+ *
+ * If the squared norm of a column vector is smaller or equal to this threshold
+ * during QR decomposition, it is considered to be a zero vector and hence the
+ * rank of the matrix is reduced.
+ *
+ * @param qrRankingThreshold threshold for QR ranking
+ */
+ public void setQRRankingThreshold(final double qrRankingThreshold) {
+ this.qrRankingThreshold = qrRankingThreshold;
+ }
+
/** {@inheritDoc} */
@Override
protected VectorialPointValuePair doOptimize()
@@ -805,7 +824,7 @@ public class LevenbergMarquardtOptimizer
ak2 = norm2;
}
}
- if (ak2 == 0) {
+ if (ak2 <= qrRankingThreshold) {
rank = k;
return;
}
Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=951864&r1=951863&r2=951864&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Sun Jun 6 14:01:51 2010
@@ -52,6 +52,10 @@ The type attribute can be add,u
If the output is not quite correct, check for invisible trailing spaces!
-->
+
+ Added a setQRRankingThreshold method to Levenberg-Marquardt optimizer to improve robustness
+ of rank determination.
+
Added random data generation methods to RandomDataImpl for the remaining distributions in the
distributions package. Added a generic nextInversionDeviate method that takes a discrete
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=951864&r1=951863&r2=951864&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java Sun Jun 6 14:01:51 2010
@@ -505,10 +505,12 @@ public class LevenbergMarquardtOptimizer
problem.addPoint (2, -2.1488478161387325);
problem.addPoint (3, -1.9122489313410047);
problem.addPoint (4, 1.7785661310051026);
- new LevenbergMarquardtOptimizer().optimize(problem,
- new double[] { 0, 0, 0, 0, 0 },
- new double[] { 0.0, 4.4e-323, 1.0, 4.4e-323, 0.0 },
- new double[] { 0, 0, 0 });
+ LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
+ optimizer.setQRRankingThreshold(0);
+ optimizer.optimize(problem,
+ new double[] { 0, 0, 0, 0, 0 },
+ new double[] { 0.0, 4.4e-323, 1.0, 4.4e-323, 0.0 },
+ new double[] { 0, 0, 0 });
fail("an exception should have been thrown");
} catch (OptimizationException ee) {
// expected behavior