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. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1179947 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a339a751b9
commit
0251da64fd
|
@ -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>
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ public class BaseMultiStartMultivariateRealOptimizer<FUNC extends MultivariateRe
|
|||
|
||||
// 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 BaseMultiStartMultivariateRealOptimizer<FUNC extends MultivariateRe
|
|||
lastException = mue;
|
||||
optima[i] = null;
|
||||
}
|
||||
// CHECKSTYLE: resume IllegalCatch
|
||||
|
||||
totalEvaluations += optimizer.getEvaluations();
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public class BaseMultiStartMultivariateVectorialOptimizer<FUNC extends Multivari
|
|||
// 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 BaseMultiStartMultivariateVectorialOptimizer<FUNC extends Multivari
|
|||
lastException = mue;
|
||||
optima[i] = null;
|
||||
}
|
||||
// CHECKSTYLE: resume IllegalCatch
|
||||
|
||||
totalEvaluations += optimizer.getEvaluations();
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ public class MultiStartUnivariateRealOptimizer<FUNC extends UnivariateRealFuncti
|
|||
|
||||
// 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 MultiStartUnivariateRealOptimizer<FUNC extends UnivariateRealFuncti
|
|||
lastException = mue;
|
||||
optima[i] = null;
|
||||
}
|
||||
// CHECKSTYLE: resume IllegalCatch
|
||||
|
||||
totalEvaluations += optimizer.getEvaluations();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue