Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.6.1
-
None
-
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); } }