diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java index a3a20367c..be0d4a40b 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java @@ -138,16 +138,14 @@ public class SimplexOptimizer extends MultivariateOptimizer { simplex = simplex.translate(getStartPoint()).evaluate(evalFunc, comparator); Simplex previous = null; - int iteration = 0; final ConvergenceChecker checker = getConvergenceChecker(); while (true) { - iteration = getIterations(); - if (iteration > 0) { + if (previous != null) { // Skip check at first iteration. boolean converged = true; for (int i = 0; i < simplex.getSize(); i++) { PointValuePair prev = previous.get(i); converged = converged && - checker.converged(iteration, prev, simplex.get(i)); + checker.converged(getIterations(), prev, simplex.get(i)); if (!converged) { // Short circuit, since "converged" will stay "false".