stanfordnlp/CoreNLP · warning · edu.stanford.nlp.optimization.QNMinimizer.MaxEvaluationsExceeded
Exceeded in minimize() loop.
Error message
Exceeded in minimize() loop.
What it means
The main minimize() loop of QNMinimizer throws MaxEvaluationsExceeded when the number of function evaluations (fevals) exceeds maxFevals. It stops the optimizer when the evaluation budget is exhausted before convergence.
Solutions
- Increase maxFevals (constructor argument or setter) to a larger budget.
- Loosen the function tolerance so convergence is detected earlier.
- Catch MaxEvaluationsExceeded and use the last iterate (the exception is thrown after x/grad were updated); improve scaling/normalization of the objective.
Example fix
// before QNMinimizer m = new QNMinimizer(); // default maxFevals m.minimize(f, 1e-6, init); // MaxEvaluationsExceeded // after QNMinimizer m = new QNMinimizer(new QNMinimizer.Record(), 100000); m.minimize(f, 1e-4, init);
Defensive patterns
Strategy: try-catch
Validate before calling
if (maxFevals <= 0 || maxFevals < 1000)
log.warning("Low maxFevals budget (" + maxFevals + "); QN may throw MaxEvaluationsExceeded"); Try / catch
try {
x = minimizer.minimize(f, tol, init);
} catch (MaxEvaluationsExceeded e) {
log.warning("QN hit evaluation budget; using last iterate");
x = minimizer.getBest();
} Prevention
- Set maxFevals generously (>= a few thousand) for large problems.
- Monitor function evaluations during development.
- Loosen functionTolerance when feasible.
- Scale/normalize features to speed convergence.
When it happens
Trigger: Calling minimize() on a hard/ill-conditioned objective so convergence takes more than maxFevals function evaluations (or maxFevals was set very low, or never raised above its default).
Common situations: Very large feature spaces, poorly scaled data, extremely tight tolerances, or an intentionally small maxFevals for quick experiments that then fails to converge.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Exceeded during linesearch() Function.
- Exceeded during lineSearch() Function.
- Exceeded during lineSearchMinPack() Function.
- Gradient is numerically zero, stopped on machine epsilon.
- Attempt to use ExternalFiniteDifference without passing…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a54981f48f825909.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/optimization/QNMinimizer.java:1068
// Add the current value and gradient to the records, this also monitors
// X and writes to output
rec.add(newValue, newGrad, newX, fevals, evalScore, sb);
// If you want to call a function and do whatever with the information ...
if (iterCallbackFunction != null) {
iterCallbackFunction.callback(newX, its, newValue, newGrad);
}
// shift
value = newValue;
// double[] temp = x;
// x = newX;
// newX = temp;
System.arraycopy(newX, 0, x, 0, x.length);
System.arraycopy(newGrad, 0, grad, 0, newGrad.length);
if (fevals > maxFevals) {
throw new MaxEvaluationsExceeded("Exceeded in minimize() loop.");
}
} catch (SurpriseConvergence s) {
if (!quiet) log.info("QNMinimizer aborted due to surprise convergence");
break;
} catch (MaxEvaluationsExceeded m) {
if (!quiet) {
log.info("QNMinimizer aborted due to maximum number of function evaluations");
log.info(m.toString());
log.info("** This is not an acceptable termination of QNMinimizer, consider");
log.info("** increasing the max number of evaluations, or safeguarding your");
log.info("** program by checking the QNMinimizer.wasSuccessful() method.");
}
break;
} catch (OutOfMemoryError oome) {
if (qn.used > 1) {
qn.removeFirst();
sb.append("{Caught OutOfMemory, changing m from ").append(qn.mem).append(" to ").append(qn.used).append("}]");
qn.mem = qn.used;View on GitHub (pinned to 1b7edd19c4)