commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-1376) SimplexOptimizer.doOptimize(): Wrong Iteration Number (0) Passed to Convergence Checker
Date Sat, 11 Jun 2016 19:32:20 GMT

     [ https://issues.apache.org/jira/browse/MATH-1376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gilles resolved MATH-1376.
--------------------------
       Resolution: Fixed
    Fix Version/s: 4.0

Fix applied in branch "develop".
Thanks for the report.

> SimplexOptimizer.doOptimize(): Wrong Iteration Number (0) Passed to Convergence Checker
> ---------------------------------------------------------------------------------------
>
>                 Key: MATH-1376
>                 URL: https://issues.apache.org/jira/browse/MATH-1376
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Thomas Weise
>            Priority: Minor
>              Labels: Convergence, Iterations, SimplexOptimizer
>             Fix For: 4.0
>
>   Original Estimate: 20m
>  Remaining Estimate: 20m
>
> The convergence checker used in method doOptimize() of SimplexOptimizer always receives
0 as iteration counter. This can very easily be fixed. Check this out:
> Original (with added comments):
> {code}
> int iteration = 0; // XXXXXXXXX set to zero and never update
>         final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
>         while (true) {
>             if (getIterations() > 0) {
>                 boolean converged = true;
>                 for (int i = 0; i < simplex.getSize(); i++) {
>                     PointValuePair prev = previous[i];
>                     converged = converged && // XXXXXXXXX ouch below
>                         checker.converged(iteration, prev, simplex.getPoint(i));
>                 }
>                 if (converged) {
>                     // We have found an optimum.
>                     return simplex.getPoint(0);
>                 }
>             }
> {code}
> should be (with added comments)
> {code}
> int iteration = 0;
>         final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
>         while (true) {
>             iteration = getIterations(); // XXXXXXXX CHANGE 1
>             if (iteration > 0) {  // XXXXXXXX CHANGE 2
>                 boolean converged = true;
>                 for (int i = 0; i < simplex.getSize(); i++) {
>                     PointValuePair prev = previous[i];
>                     converged = converged &&
>                         checker.converged(iteration, prev, simplex.getPoint(i));
>                 }
>                 if (converged) {
>                     // We have found an optimum.
>                     return simplex.getPoint(0);
>                 }
>             }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message