commons-issues mailing list archives

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

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

Stephen Crowley commented on MATH-1433:
---------------------------------------

Sure thing.. I'll try to get to it soon. It was a bug in my random 
vector guess generating code that just took a while to track down. The 
code as is, just ignores it as a "bad guess" and ends up returning the

initial starting point results and only throws the exception if the 
initial starting point isn't there. I'm thinking something like an 
exception in the initial guess should go ahead and cause the entire 
optimize() call to fail since

one would think that the caller always wants to know something is messed 
up first.




> 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