commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1433) BaseMultiStartMultivariateOptimizer.doOptimize() swallows exceptions
Date Wed, 04 Oct 2017 16:06:01 GMT

    [ https://issues.apache.org/jira/browse/MATH-1433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16191496#comment-16191496
] 

Gilles commented on MATH-1433:
------------------------------

Could you provide a fully working code that illustrates the issue (e.g. a "Junit" test)?

The exceptions are swallowed on the assumption that they could only be raised by a bad starting
point.  You are right that it was sloppy to catch {{RuntimeException}} rather than more specific
types.

But why is the RNG throwing an exception?  I'd guess that it should not happen...


> BaseMultiStartMultivariateOptimizer.doOptimize() swallows exceptions
> --------------------------------------------------------------------
>
>                 Key: MATH-1433
>                 URL: https://issues.apache.org/jira/browse/MATH-1433
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6
>         Environment:         // Multi-start loop.
>         for (int i = 0; i < starts; i++) {
>             // CHECKSTYLE: stop IllegalCatch
>             try {
>                 // Decrease number of allowed evaluations.
>                 optimData[maxEvalIndex] = new MaxEval(maxEval - totalEvaluations);
>                 // New start value.
>                 double[] s = null;
>                 if (i == 0) {
>                     s = startPoint;
>                 } else {
>                     int attempts = 0;
>                     while (s == null) {
>                         if (attempts++ >= getMaxEvaluations()) {
>                             throw new TooManyEvaluationsException(getMaxEvaluations());
>                         }
>                         s = generator.nextVector();
>                         for (int k = 0; s != null && k < s.length; ++k) {
>                             if ((min != null && s[k] < min[k]) || (max !=
null && s[k] > max[k])) {
>                                 // reject the vector
>                                 s = null;
>                             }
>                         }
>                     }
>                 }
>                 optimData[initialGuessIndex] = new InitialGuess(s);
>                 // Optimize.
>                 final PAIR result = optimizer.optimize(optimData);
>                 store(result);
>             } catch (RuntimeException mue) {
>                 lastException = mue;
>             }
>             // CHECKSTYLE: resume IllegalCatch
>             totalEvaluations += optimizer.getEvaluations();
>         }
>            Reporter: Stephen Crowley
>              Labels: easyfix
>
> it took me a while to figure out that the random vector generator was throwing an exception
that was being swallowed. that should never happen



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message