You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2010/06/06 16:01:52 UTC
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/
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.
* <p>The default values for the algorithm settings are:
* <ul>
- * <li>{@link #setConvergenceChecker vectorial convergence checker}: null</li>
- * <li>{@link #setInitialStepBoundFactor initial step bound factor}: 100.0</li>
- * <li>{@link #setMaxIterations maximal iterations}: 1000</li>
- * <li>{@link #setCostRelativeTolerance cost relative tolerance}: 1.0e-10</li>
- * <li>{@link #setParRelativeTolerance parameters relative tolerance}: 1.0e-10</li>
- * <li>{@link #setOrthoTolerance orthogonality tolerance}: 1.0e-10</li>
+ * <li>{@link #setConvergenceChecker(VectorialConvergenceChecker) vectorial convergence checker}: null</li>
+ * <li>{@link #setInitialStepBoundFactor(double) initial step bound factor}: 100.0</li>
+ * <li>{@link #setMaxIterations(int) maximal iterations}: 1000</li>
+ * <li>{@link #setCostRelativeTolerance(double) cost relative tolerance}: 1.0e-10</li>
+ * <li>{@link #setParRelativeTolerance(double) parameters relative tolerance}: 1.0e-10</li>
+ * <li>{@link #setOrthoTolerance(double) orthogonality tolerance}: 1.0e-10</li>
+ * <li>{@link #setQRRankingThreshold(double) QR ranking threshold}: {@link MathUtils#SAFE_MIN}</li>
* </ul>
* </p>
* <p>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.
+ * <p>
+ * 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.
+ * </p>
+ * @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 <action> type attribute can be add,u
If the output is not quite correct, check for invisible trailing spaces!
-->
<release version="2.2" date="TBD" description="TBD">
+ <action dev="luc" type="fix" issue="MATH-352" >
+ Added a setQRRankingThreshold method to Levenberg-Marquardt optimizer to improve robustness
+ of rank determination.
+ </action>
<action dev="psteitz" type="update" issue="MATH-310">
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