commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1179947 - in /commons/proper/math/trunk: ./ src/main/java/org/apache/commons/math/optimization/ src/main/java/org/apache/commons/math/optimization/univariate/
Date Fri, 07 Oct 2011 07:25:51 GMT
Author: luc
Date: Fri Oct  7 07:25:51 2011
New Revision: 1179947

URL: http://svn.apache.org/viewvc?rev=1179947&view=rev
Log:
Added checkstyle filter for exceptional catch of RuntimeException.

These catch occur in multi-start optimizers. The exceptions are caught
and stored, and if all restarts fail, then one of the stored
RuntimeException is rethrown. The purpose of multi-start is both to
allow some trials to fail and to avoid being trapped in a local
extremum. Catching RuntimeException is therefore mandatory here, and not
dangerous since we rethrow them as needed.

Modified:
    commons/proper/math/trunk/checkstyle.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateRealOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateVectorialOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java

Modified: commons/proper/math/trunk/checkstyle.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/checkstyle.xml?rev=1179947&r1=1179946&r2=1179947&view=diff
==============================================================================
--- commons/proper/math/trunk/checkstyle.xml (original)
+++ commons/proper/math/trunk/checkstyle.xml Fri Oct  7 07:25:51 2011
@@ -178,6 +178,11 @@
     <property name="onCommentFormat"  value="CHECKSTYLE\: resume MultipleVariableDeclarations"/>
     <property name="checkFormat"      value="MultipleVariableDeclarations"/>
   </module>
+  <module name="SuppressionCommentFilter">
+    <property name="offCommentFormat" value="CHECKSTYLE\: stop IllegalCatch"/>
+    <property name="onCommentFormat"  value="CHECKSTYLE\: resume IllegalCatch"/>
+    <property name="checkFormat"      value="IllegalCatch"/>
+  </module>
 
 </module>
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateRealOptimizer.java?rev=1179947&r1=1179946&r2=1179947&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateRealOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateRealOptimizer.java
Fri Oct  7 07:25:51 2011
@@ -149,6 +149,7 @@ public class BaseMultiStartMultivariateR
 
         // Multi-start loop.
         for (int i = 0; i < starts; ++i) {
+            // CHECKSTYLE: stop IllegalCatch
             try {
                 optima[i] = optimizer.optimize(maxEval - totalEvaluations, f, goal,
                                                i == 0 ? startPoint : generator.nextVector());
@@ -156,6 +157,7 @@ public class BaseMultiStartMultivariateR
                 lastException = mue;
                 optima[i] = null;
             }
+            // CHECKSTYLE: resume IllegalCatch
 
             totalEvaluations += optimizer.getEvaluations();
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateVectorialOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateVectorialOptimizer.java?rev=1179947&r1=1179946&r2=1179947&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateVectorialOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultiStartMultivariateVectorialOptimizer.java
Fri Oct  7 07:25:51 2011
@@ -151,6 +151,7 @@ public class BaseMultiStartMultivariateV
         // Multi-start loop.
         for (int i = 0; i < starts; ++i) {
 
+            // CHECKSTYLE: stop IllegalCatch
             try {
                 optima[i] = optimizer.optimize(maxEval - totalEvaluations, f, target, weights,
                                                i == 0 ? startPoint : generator.nextVector());
@@ -160,6 +161,7 @@ public class BaseMultiStartMultivariateV
                 lastException = mue;
                 optima[i] = null;
             }
+            // CHECKSTYLE: resume IllegalCatch
 
             totalEvaluations += optimizer.getEvaluations();
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java?rev=1179947&r1=1179946&r2=1179947&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java
Fri Oct  7 07:25:51 2011
@@ -161,6 +161,7 @@ public class MultiStartUnivariateRealOpt
 
         // Multi-start loop.
         for (int i = 0; i < starts; ++i) {
+            // CHECKSTYLE: stop IllegalCatch
             try {
                 final double s = (i == 0) ? startValue : min + generator.nextDouble() * (max
- min);
                 optima[i] = optimizer.optimize(maxEval - totalEvaluations, f, goal, min,
max, s);
@@ -168,6 +169,7 @@ public class MultiStartUnivariateRealOpt
                 lastException = mue;
                 optima[i] = null;
             }
+            // CHECKSTYLE: resume IllegalCatch
 
             totalEvaluations += optimizer.getEvaluations();
         }



Mime
View raw message