stanfordnlp/CoreNLP · warning · edu.stanford.nlp.optimization.QNMinimizer.MaxEvaluationsExceeded

Exceeded during linesearch() Function.

Error message

Exceeded during linesearch() Function.

What it means

The backtracking lineSearch() helper throws MaxEvaluationsExceeded when the function evaluation counter fevals exceeds maxFevals during the line search phase. Same budget guard as the main loop, applied inside the (overloaded) backtracking search.

Solutions

  1. Raise maxFevals to accommodate line search evaluations.
  2. Catch MaxEvaluationsExceeded and restart from a better-scaled initial point.
  3. Normalize features / adjust functionTolerance so the line search succeeds in fewer evaluations.

Example fix

// before
minimizer.setMaxFevals(10); // exceeded inside lineSearch
// after
minimizer.setMaxFevals(1000);
Defensive patterns

Strategy: try-catch

Validate before calling

if (maxFevals < 100) log.warning("maxFevals too low; line search alone can exceed it");

Try / catch

try {
  x = minimizer.minimize(f, tol, init);
} catch (MaxEvaluationsExceeded e) {
  minimizer.setMaxFevals(maxFevals * 4);
  x = minimizer.minimize(f, tol, init);
}

Prevention

When it happens

Trigger: A minimize() run whose line search performs many small-step evaluations (very small c1 multiplier, bad initial step) pushes fevals past maxFevals while still searching for a valid step length.

Common situations: Poorly scaled objectives or bad initial parameters forcing tiny steps; too-low maxFevals budgets; oscillating objectives where backtracking never satisfies the Armijo condition quickly.

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


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/9d92936b14e107c1. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/optimization/QNMinimizer.java:1318

      if (newPoint[f] <= lastValue + c * dgtest)
        break;
      else {
        if (newPoint[f] < lastValue) {
          // an improvement, but not good enough... suspicious!
          sb.append('!');
        } else {
          sb.append('.');
        }
      }

      step = c1 * step;
    }

    newPoint[a] = step;
    fevals += 1;
    if (fevals > maxFevals) {
      throw new MaxEvaluationsExceeded("Exceeded during linesearch() Function.");
    }

    return newPoint;
  }


  /*
   * lineSearchBacktrack is the original line search used for the first version
   * of QNMinimizer. It only satisfies sufficient descent not the Wolfe conditions.
   */
  private double[] lineSearchBacktrack(Function func, double[] dir, double[] x,
      double[] newX, double[] grad, double lastValue, StringBuilder sb)
      throws MaxEvaluationsExceeded {

    double normGradInDir = ArrayMath.innerProduct(dir, grad);
    sb.append('(').append(nf.format(normGradInDir)).append(')');
    if (normGradInDir > 0 && !quiet) {
      log.info("{WARNING--- direction of positive gradient chosen!}");

View on GitHub (pinned to 1b7edd19c4)