Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1376

SimplexOptimizer.doOptimize(): Wrong Iteration Number (0) Passed to Convergence Checker

    Details

    • Flags:
      Patch

      Description

      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):

      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);
                      }
                  }
      

      should be (with added comments)

      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);
                      }
                  }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              thomasWeise Thomas Weise
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 20m
                20m
                Remaining:
                Remaining Estimate - 20m
                20m
                Logged:
                Time Spent - Not Specified
                Not Specified