stanfordnlp/CoreNLP · error · java.lang.UnsupportedOperationException
Doesn't support floats yet
Error message
Doesn't support floats yet
What it means
QNMinimizer has a constructor taking a FloatFunction that is intentionally unimplemented: it always throws UnsupportedOperationException("Doesn't support floats yet"). L-BFGS in this library is implemented for double precision only, so float-based monitoring/evaluation is not available.
Solutions
- Use the double-precision constructors, e.g. new QNMinimizer(Function) or new QNMinimizer()
- Convert your objective to implement the double-based Function interface
- If float monitoring is needed, wrap it and pass a double-based Function monitor instead
Example fix
// before QNMinimizer minimizer = new QNMinimizer((FloatFunction) objective); // after QNMinimizer minimizer = new QNMinimizer((Function) objective);
Defensive patterns
Strategy: validation
Validate before calling
if (monitor instanceof FloatFunction) throw new IllegalArgumentException("QNMinimizer only supports double-based Function monitors");
QNMinimizer m = new QNMinimizer((Function) monitor); Type guard
boolean usableWithQN = !(monitor instanceof FloatFunction); // must be double-based Function
Try / catch
try { m = new QNMinimizer(monitor); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("Doesn't support floats")) { m = new QNMinimizer(toDoubleFunction(monitor)); } else throw e; } Prevention
- Implement objectives against the double-based Function interface only
- Avoid generic factory code that may pick the FloatFunction constructor
- Check constructor overloads before wrapping float-based code
When it happens
Trigger: Invoking new QNMinimizer(FloatFunction) — any call to that constructor.
Common situations: Code written against an API that advertises float support; porting code from another optimizer library that uses floats; generic code that instantiates QNMinimizer with either Function or FloatFunction.
Related errors
- Attempt to use ExternalFiniteDifference without passing…
- If you want to ask for the probability, you must train a…
- NO SAMPLING METHOD SELECTED
- Vector of incorrect size passed to applyInitialHessian in…
- prior is specified to be ae-lasso or g-lasso, but function…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b5a7f45f0ee7af52.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/optimization/QNMinimizer.java:186
public QNMinimizer(Function monitor) {
this.monitor = monitor;
}
public QNMinimizer(Function monitor, int m) {
this(monitor, m, false);
}
public QNMinimizer(Function monitor, int m, boolean useRobustOptions) {
this.monitor = monitor;
mem = m;
if (useRobustOptions) {
this.setRobustOptions();
}
}
public QNMinimizer(FloatFunction monitor) {
throw new UnsupportedOperationException("Doesn't support floats yet");
}
public void setOldOptions() {
useAveImprovement = true;
useRelativeNorm = false;
useNumericalZero = false;
lsOpt = eLineSearch.BACKTRACK;
scaleOpt = eScaling.SCALAR;
}
public final void setRobustOptions() {
useAveImprovement = true;
useRelativeNorm = true;
useNumericalZero = true;
lsOpt = eLineSearch.MINPACK;
scaleOpt = eScaling.DIAGONAL;
}
View on GitHub (pinned to 1b7edd19c4)