it.grypho.scala.leonardo.optimize
Optimization: finding, classifying and certifying optima (F_0010).
The symbolic half is the point of the package. Almost every optimization library is numeric; what a CAS can do that they cannot is derive the conditions and solve them exactly. So most of this package is symbolic:
- stationaryPoints solves
∇f = 0and classifyStationary reads the Hessian there; - convexity decides convexity from the principal minors of the symbolic Hessian;
- lagrangePoints handles equality constraints with Lagrange multipliers;
- kktConditions states the Karush–Kuhn–Tucker conditions in the language, and kktPoints solves them by active-set enumeration.
Every one of them rests on eliminate, a solver for the nonlinear polynomial systems those conditions produce — equation.solveSystem is linear-only, which was the survey finding that shaped the whole entry.
A modest numeric tier covers what has no closed form: minimize (gradient descent, Newton, BFGS and a projected BFGS for box constraints, each named explicitly), qpSolve for convex quadratic programs (F_0053), lsqfit / curveFit for nonlinear least squares (F_0063), and nlpSolve for constrained nonlinear programs by SQP over qpSolve or an augmented Lagrangian (F_0066) — each declining rather than returning a point it could not certify. lpSolve is the exception that needs no certificate: a linear program solved exactly over the rationals, where termination is the proof (F_0011). Large-scale numerical optimization is out of scope.
Refusal is the common thread. A list of stationary points is read as all of them, so an incomplete list is a confident wrong answer; the solver declines when it cannot prove completeness. convex answers false only with a witness. minimize checks a scale-free stationarity certificate (F_0095), qp and nlp the KKT conditions and lsqfit the cosine between the residual and each Jacobian column, all before answering.
Layering: imports core, scalar, matrix, equation, vector and logic, and nothing imports it except parser.
Attributes
Members list
Type members
Classlikes
Why minimizeDerivativeFree declined (F_0302).
Why minimizeDerivativeFree declined (F_0302).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The derivative-free methods, always named by the caller (F_0302; the c2d rule).
The derivative-free methods, always named by the caller (F_0302; the c2d rule).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why the search stopped with an answer (F_0302).
Why the search stopped with an answer (F_0302).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why lpSolve declined (F_0052 Decision A's mechanism: a reason at the Scala level).
Why lpSolve declined (F_0052 Decision A's mechanism: a reason at the Scala level).
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
An optimal vertex of a linear program.
An optimal vertex of a linear program.
Value parameters
- active
-
the inequality rows and bounds holding with equality, named as in
qp - iterations
-
simplex pivots, both phases
- objective
-
fᵀxthere, in the same tier - x
-
the minimiser: exact rationals when every coefficient was exact,
Doubles otherwise (the exact optimum of the givenDoubles, rounded once at the end)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A certified least-squares fit.
A certified least-squares fit.
Value parameters
- active
-
the indices of the parameters held at a bound, ascending
- covariance
-
σ²·(RᵀR)⁻¹,σ² = ‖r‖²/(m − n); absent whenm = n(no residual degrees of freedom) or when a bound is active (the linearised Gaussian approximation does not hold at a boundary) - iterations
-
how many iterations the solver took
- p
-
the parameters
- residualNorm
-
‖r(p)‖
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why minimize declined (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). The node itself stays symbolic; this is what explains it.
Why minimize declined (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). The node itself stays symbolic; this is what explains it.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
MinimizeMethod.type
The numeric minimisation methods, always named by the caller (F_0010 slice 5).
The numeric minimisation methods, always named by the caller (F_0010 slice 5).
Never a hidden default, the c2d rule: two methods can stop at different points of a non-convex function, so a silent choice would make two correct-looking answers disagree.
Attributes
A certified minimiser.
A certified minimiser.
Value parameters
- gradientNorm
-
‖∇f‖∞there, projected under bounds — reported, not the certificate, which is the scale-freestationarity(F_0095) - iterations
-
how many iterations the method took
- value
-
fthere - x
-
the point
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why nlpSolve declined (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). The node itself stays symbolic.
Why nlpSolve declined (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). The node itself stays symbolic.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The constrained nonlinear programming methods, always named by the caller (F_0066).
The constrained nonlinear programming methods, always named by the caller (F_0066).
Never a hidden default, the c2d rule: on a non-convex problem the two can stop at different KKT points, so a silent choice would make two correct-looking answers disagree.
Attributes
A certified KKT point of min f subject to g ≤ 0, h = 0, lb ≤ x ≤ ub.
A certified KKT point of min f subject to g ≤ 0, h = 0, lb ≤ x ≤ ub.
Value parameters
- active
-
the inequalities with a positive multiplier, ascending
- bounded
-
the variables held at a bound, ascending
- equalityMultipliers
-
λ, one per equality, in the same Lagrangian - inequalityMultipliers
-
μ ≥ 0, one per inequality, inL = f + μᵀg + λᵀh - iterations
-
SQP iterations, or augmented-Lagrangian rounds
- kktResidual
-
the relative KKT residual the certificate measured, at most the tolerance
- value
-
fthere - x
-
the point
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
One constraint of a qpSolve problem, named the way a reader names it: a row of A, or the lower or upper bound of one variable. Indices are zero-based; the REPL prints them from one. The name is what makes a warm start survive a perturbed problem: it does not depend on which bounds happen to be finite this time.
One constraint of a qpSolve problem, named the way a reader names it: a row of A, or the lower or upper bound of one variable. Indices are zero-based; the REPL prints them from one. The name is what makes a warm start survive a perturbed problem: it does not depend on which bounds happen to be finite this time.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why qpSolve gave no answer (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). An MPC reacts differently to each — relax the targets, fix the model, hold the last input — which is why Left(this) alone would not do.
Why qpSolve gave no answer (F_0052 Decision A: a reason at the Scala level, which the REPL appends as a note). An MPC reacts differently to each — relax the targets, fix the model, hold the last input — which is why Left(this) alone would not do.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The Lagrange multipliers at a QP's optimum (F_0066), in the convention of L = ½ zᵀHz + fᵀz + μᵀ(Az − b) + λᵀ(Aeq·z − beq) + νₗᵀ(lb − z) + νᵤᵀ(z − ub): an inequality or bound multiplier is ≥ 0 and zero when its constraint is inactive, an equality multiplier has either sign, and Hz + f + Aᵀμ + Aeqᵀλ − νₗ + νᵤ = 0 at the optimum.
The Lagrange multipliers at a QP's optimum (F_0066), in the convention of L = ½ zᵀHz + fᵀz + μᵀ(Az − b) + λᵀ(Aeq·z − beq) + νₗᵀ(lb − z) + νᵤᵀ(z − ub): an inequality or bound multiplier is ≥ 0 and zero when its constraint is inactive, an equality multiplier has either sign, and Hz + f + Aᵀμ + Aeqᵀλ − νₗ + νᵤ = 0 at the optimum.
Value parameters
- equality
-
one per row of
Aeq - inequality
-
one per row of
A - lower
-
one per variable, for
lb - upper
-
one per variable, for
ub
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A certified optimum of qpSolve.
A certified optimum of qpSolve.
Value parameters
- active
-
the inequalities and bounds holding with equality — pass it back as
warmfor the next, similar problem (X-04: state in, state out) - iterations
-
active-set changes (additions and drops) the solve took
- kktResidual
-
the relative KKT residual the certificate measured, at most the tolerance
- multipliers
-
the Lagrange multipliers at
z— what an SQP iteration built on this solver reads as its multiplier estimate (F_0066) - objective
-
½ zᵀHz + fᵀzatz - z
-
the minimiser
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Why nsolve declined (F_0319, AIACE L_0011). The node stays symbolic; the REPL appends why.
Why nsolve declined (F_0319, AIACE L_0011). The node stays symbolic; the REPL appends why.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A certified root of a square nonlinear system (F_0319).
A certified root of a square nonlinear system (F_0319).
Value parameters
- active
-
the indices of the unknowns held at a bound, ascending
- iterations
-
how many dogleg steps the solver took, rejected ones included
- residual
-
|F(x)|, the Euclidean norm - x
-
the root
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
What the second-order test says about a stationary point.
What the second-order test says about a stationary point.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A point the derivative-free search stopped at (F_0302). Uncertified by its type: nothing proves it a minimiser, local or global, and it is never a MinimizeResult (the odeStep precedent).
A point the derivative-free search stopped at (F_0302). Uncertified by its type: nothing proves it a minimiser, local or global, and it is never a MinimizeResult (the odeStep precedent).
Value parameters
- evaluations
-
how many times
fwas called - step
-
the final step per coordinate (pattern search), or the final simplex's extent per coordinate (Nelder–Mead), in the coordinate's own units
- stop
-
why the search stopped
- value
-
fthere - x
-
the best point found
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
convex(f, x, y, …) — true, false, or symbolic when neither can be established (F_0010 slice 2; see convexity for what each answer requires).
convex(f, x, y, …) — true, false, or symbolic when neither can be established (F_0010 slice 2; see convexity for what each answer requires).
Value parameters
- f
-
the function
- vars
-
the variables, an ordered tuple
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
lsqfit(model, t, T, Y, [[a], [b]], p0[, lb, ub][, cov]) — the curve-fit form (F_0063 Decision D): fits model in t to the data columns T and Y (scipy's curve_fit shape). Told apart from _LsqFit by its second argument, one bare name rather than a column.
lsqfit(model, t, T, Y, [[a], [b]], p0[, lb, ub][, cov]) — the curve-fit form (F_0063 Decision D): fits model in t to the data columns T and Y (scipy's curve_fit shape). Told apart from _LsqFit by its second argument, one bare name rather than a column.
t and the parameters are binders, excluded from children.
Value parameters
- bounds
-
the lower and upper bounds
- cov
-
whether to answer the covariance too
- model
-
the model, an expression in
tand the parameters - p0
-
the starting point
- params
-
the parameters, in the order of
p0 - t
-
the independent variable
- tdata
-
the values of
t, a row or column - ydata
-
the observations, a row or column of the same length
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
kkt(f, g, h, x, y, …) — the Karush–Kuhn–Tucker conditions of min f subject to g ≤ 0 and h = 0, stated as one conjunction of relations (F_0010 slice 4).
kkt(f, g, h, x, y, …) — the Karush–Kuhn–Tucker conditions of min f subject to g ≤ 0 and h = 0, stated as one conjunction of relations (F_0010 slice 4).
Evaluates to the conditions rather than to their solutions: the conditions are an equivalent restatement anyone can read, check and hand to solve, while solving them is kktPoints, library API. Pass 0 for an absent group — the constraint 0 ≤ 0 (or 0 = 0) holds trivially and is dropped.
Value parameters
- f
-
the objective
- g
-
the inequality group, cells meaning
g ≤ 0(or written asl = r) - h
-
the equality group, cells meaning
h = 0(or written asl = r) - vars
-
the variables, an ordered tuple
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
lp(f, A, b[, Aeq, beq], lb, ub) — the linear program min fᵀx subject to A x ≤ b, Aeq x = beq, lb ≤ x ≤ ub, solved exactly (F_0011).
lp(f, A, b[, Aeq, beq], lb, ub) — the linear program min fᵀx subject to A x ≤ b, Aeq x = beq, lb ≤ x ≤ ub, solved exactly (F_0011).
qp's shape without the Hessian: an absent group is 0, an absent bound -inf / inf, a number for lb or ub applies to every variable. Answers the minimiser as a column — exact cells when every coefficient was exact — and stays as written when lpSolve declines; the REPL appends why, or the optimal value and the active constraints.
Value parameters
- a
-
the inequality matrix, or
0 - b
-
its right-hand side, or
0 - eq
-
the equality matrix and right-hand side, when given
- f
-
the cost vector
- lb
-
the lower bounds
- ub
-
the upper bounds
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
lagrange(f, [[g1], [g2]], x, y, …) — the stationary points of f on g = 0, by Lagrange multipliers (F_0010 slice 3). Same answer shape as _Stationary.
lagrange(f, [[g1], [g2]], x, y, …) — the stationary points of f on g = 0, by Lagrange multipliers (F_0010 slice 3). Same answer shape as _Stationary.
A constraint cell is an expression meaning g = 0 or an equation l = r; a single constraint may be written without the matrix.
Value parameters
- constraints
-
the constraint group
- f
-
the objective
- vars
-
the variables, an ordered tuple
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
lsqfit(r, [[a], [b]], p0[, lb, ub][, cov]) — nonlinear least squares over a residual column (F_0063). Evaluates to the fitted parameters as an n×1 column, or with the slot word cov (not reserved, the svd(A, full) precedent) to the row [[p, C]]; stays symbolic whenever lsqfit declines, and the REPL appends why.
lsqfit(r, [[a], [b]], p0[, lb, ub][, cov]) — nonlinear least squares over a residual column (F_0063). Evaluates to the fitted parameters as an n×1 column, or with the slot word cov (not reserved, the svd(A, full) precedent) to the row [[p, C]]; stays symbolic whenever lsqfit declines, and the REPL appends why.
The parameters are binders, excluded from children. A residual over data is written cell by cell — transpose(tabulate(at(Y, k, 1) - a*exp(b*at(T, k, 1)), k, 1, N)) — since Y - a*exp(b*T) with T a column stays an unevaluated product; the curve-fit form _CurveFit builds that residual itself.
Value parameters
- bounds
-
the lower and upper bounds
- cov
-
whether to answer the covariance too
- p0
-
the starting point
- params
-
the parameters, in the order of
p0 - r
-
the residual column
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
minimize(f, [[x], [y]], x0, method) and minimize(f, [[x], [y]], x0, lb, ub, method) — the numeric minimiser as an n×1 column (F_0010 slice 5).
minimize(f, [[x], [y]], x0, method) and minimize(f, [[x], [y]], x0, lb, ub, method) — the numeric minimiser as an n×1 column (F_0010 slice 5).
The variables are a column, unlike the symbolic four, because a varargs tuple cannot be followed by a starting point, bounds and a method; the column is also the shape x0 and the answer have, so one is a drop-in warm start for the next. The variables are binders (the answer does not mention them), excluded from children.
Declines — stays symbolic — whenever minimize does; the REPL appends why.
Value parameters
- bounds
-
the lower and upper bounds, same shape, entries may be
inf/-inf - f
-
the objective
- method
-
the method, always named
- vars
-
the variables, in the order of
x0 - x0
-
the starting point: an
n×1column, or a number whenn = 1
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
nsolve(F, [[x], [y]], x0[, lb, ub]) -- the root of a square nonlinear system as an n x 1 column (F_0319, Decision C). A cell of F is an expression meaning F_i = 0 or an equation l = r; the unknowns are a column of names, minimize's shape, and binders excluded from children. Stays symbolic whenever nsolve declines, and the REPL appends why.
nsolve(F, [[x], [y]], x0[, lb, ub]) -- the root of a square nonlinear system as an n x 1 column (F_0319, Decision C). A cell of F is an expression meaning F_i = 0 or an equation l = r; the unknowns are a column of names, minimize's shape, and binders excluded from children. Stays symbolic whenever nsolve declines, and the REPL appends why.
Value parameters
- bounds
-
the lower and upper bounds
- f
-
the system
- vars
-
the unknowns, in the order of
x0 - x0
-
the starting point
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
nlp(f, [[x], [y]], x0, g, h, method) and nlp(f, [[x], [y]], x0, g, h, lb, ub, method) — a KKT point of min f subject to g ≤ 0, h = 0 and lb ≤ x ≤ ub, as an n×1 column (F_0066, MPC T3-02).
nlp(f, [[x], [y]], x0, g, h, method) and nlp(f, [[x], [y]], x0, g, h, lb, ub, method) — a KKT point of min f subject to g ≤ 0, h = 0 and lb ≤ x ≤ ub, as an n×1 column (F_0066, MPC T3-02).
The variables are a column of names, the minimize shape; a constraint group is a column, one expression, or 0 when absent (the kkt reading: a cell means g ≤ 0 or h = 0, or is written as a relation l = r, l = r); bounds are a number for every variable or a column, -inf/inf for none (the qp reading). Declines — stays symbolic — whenever nlpSolve does; the REPL appends why.
Value parameters
- bounds
-
the lower and upper bounds
- f
-
the objective
- g
-
the inequality group
- h
-
the equality group
- method
-
the method, always named
- vars
-
the variables, in the order of
x0 - x0
-
the starting point: an
n×1column, or a number whenn = 1
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
qp(H, f, A, b[, Aeq, beq], lb, ub) — the convex quadratic program min ½ zᵀHz + fᵀz subject to A z ≤ b, Aeq z = beq, lb ≤ z ≤ ub (F_0053).
qp(H, f, A, b[, Aeq, beq], lb, ub) — the convex quadratic program min ½ zᵀHz + fᵀz subject to A z ≤ b, Aeq z = beq, lb ≤ z ≤ ub (F_0053).
An absent group is 0 (Decision A, the kkt precedent): qp(H, f, 0, 0, lb, ub) has no inequalities. An absent bound is -inf / inf, and a number for lb or ub applies to every variable, so lb = 0 reads as "all non-negative". Evaluates to the n×1 minimiser and stays symbolic whenever qpSolve declines; the REPL appends why, or, on success, which constraints are active (Decision C). The warm start is library API only.
Value parameters
- a
-
the inequality matrix, or
0 - b
-
its right-hand side, or
0 - eq
-
the equality matrix and right-hand side, when given
- f
-
the linear term
- h
-
the Hessian, symmetric positive definite
- lb
-
the lower bounds
- ub
-
the upper bounds
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
stationary(f, x, y, …) — every stationary point of f (F_0010 slice 1).
stationary(f, x, y, …) — every stationary point of f (F_0010 slice 1).
Evaluates to the points as a k×n matrix with one row of v = value per point (the solveSystem row shape), to false when there provably are none, and stays symbolic when the set cannot be proved complete. Unlike solve, the REPL does not bind the answer: several points cannot all be the value of x.
The variables follow the _Taylor convention: free in the result, so excluded from children and carried through rebuild, which keeps substitute from renaming them.
Value parameters
- f
-
the objective
- vars
-
the variables, an ordered tuple
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Types
A solution of a system: each unknown's name mapped to its value.
A solution of a system: each unknown's name mapped to its value.
A value is a number when the system had numeric coefficients, and an expression in the free parameters when it did not.
Attributes
Value members
Concrete methods
The second-order test at a stationary point: the signs of the Hessian's eigenvalues.
The second-order test at a stationary point: the signs of the Hessian's eigenvalues.
An eigenvalue counts as zero when it is below 1e-9 of the largest in magnitude — a relative test, so the verdict does not move when f is rescaled (the units rule).
Value parameters
- env
-
bindings and precision
- f
-
the objective
- point
-
the stationary point, every coordinate numeric
- vars
-
the variables, in the order the point is written in
Attributes
- Returns
-
the classification, or
Nonewhen the Hessian does not evaluate there
Whether f is convex in vars (F_0010 slice 2): Some(true), Some(false), or None when neither can be established.
Whether f is convex in vars (F_0010 slice 2): Some(true), Some(false), or None when neither can be established.
true needs a proof, false needs a witness, and anything short of either stays symbolic — failing to prove that a minor is non-negative is not a proof that it is negative.
true: every principal minor of the symbolic Hessian is provably non-negative, so the Hessian is positive semidefinite everywhere. Principal, not leading: Sylvester's leading-minor test proves definiteness; semidefiniteness needs every principal minor, and the leading ones alone reportdiag(0, −1)as convex. The proof is also required to hold on a convex set, sotrueis answered only whenfis defined everywhere — for1/x²the Hessian is positive wherever it exists, but the domainx ≠ 0is not convex and neither is the function on it.false: a principal minor provably negative, or a point wherefis real-valued and the numeric Hessian has a negative eigenvalue, found on a small fixed grid. The point must be one wherefis defined:x·ln(x)has a negative second derivative atx = −1, where it is not real, and is convex where it is.
Capped at MaxConvexityVariables, the cofactor expansion's own cap.
Value parameters
- env
-
bindings and precision
- f
-
the function
- vars
-
the variables, an ordered tuple
Attributes
- Returns
-
the verdict, or
Nonewhen it cannot be established
Fits model to data (tₖ, yₖ) by minimising Σ (yₖ − model(tₖ, p))² — the curve-fit form of lsqfit (F_0063 Decision D), with the same solver and certificate.
Fits model to data (tₖ, yₖ) by minimising Σ (yₖ − model(tₖ, p))² — the curve-fit form of lsqfit (F_0063 Decision D), with the same solver and certificate.
The model is compiled once over t and the parameters, so the residual and its Jacobian are evaluated sample by sample rather than built as m trees.
Value parameters
- bounds
-
lower and upper bounds, entries may be infinite;
Nonewhen unbounded - env
-
bindings and precision
- model
-
the model, an expression in
tand the parameters - p0
-
the starting point
- params
-
the parameters, in the order of
p0 - t
-
the independent variable
- tdata
-
the values of
t - ydata
-
the observations, one per value of
t
Attributes
- Returns
-
the certified fit, or why there is none
Every real solution of eqs = 0 in unknowns, or None when that set cannot be proved complete (F_0010, Decision B: elimination with case splits).
Every real solution of eqs = 0 in unknowns, or None when that set cannot be proved complete (F_0010, Decision B: elimination with case splits).
equation.solveSystem is linear-only, and the conditions an optimum must satisfy are not linear in general — a nonlinear constraint makes λ·∇g bilinear, and even the decoupled x³ − 3x + y² has a quadratic gradient. This solver reaches them by elimination:
- An equation linear in some unknown with a constant coefficient is solved for it and substituted — no branching, and exact on exact input, so a linear system comes out in the exact tier.
- An equation in a single unknown is solved for every real root (square-free factorisation, then the roots of each part — the 2.5 rule, since QR can fail on a repeated root) and the search branches on each.
- An equation linear in an unknown whose coefficient
cdepends on the others is solved for it on one branch, and on a second branch replaced byc = 0and the constant term= 0. The second branch is the point: dividing bycsilently drops every solution wherecvanishes, and a stationary-point list is read as all of them. - A branch the steps decline, or where none applies, is handed to groebnerBasis when its equations are polynomials with numeric coefficients (F_0068): a lexicographic basis of the same ideal is triangular, which steps 1 and 2 then finish. It comes after the steps, so every answer they give is unchanged; it reaches the genuinely coupled systems (every equation non-linear in every unknown) and those where step 3's division led to rational equations no step solves.
Substituting an inexact root drops the coefficients it leaves at the rounding level of the terms that cancelled (withoutRounding): read as values, they turn 0·x = 0 into x = 0 and lose the branch's points, which is how the first F_0068 test found five of nine.
It declines — None — when no step applies and no basis helps, when a branch is left with free unknowns and no equations (a continuum of solutions, which no list can hold), when a univariate equation's roots cannot be enumerated (a transcendental equation, or symbolic coefficients above degree one), and past MaxEliminationSteps. It never returns what it found so far as though it were everything.
Every candidate is verified against the original equations under the tolerance = uses (0.5·10^-precision). A candidate at which an equation is undefined is dropped — that is the artefact of a step-3 division where the coefficient vanished, which the second branch covers. A candidate that is defined but misses the tolerance makes the whole answer decline, since that is not an artefact the algorithm can explain. A candidate carrying free parameters is verified numerically at fixed sample values of those parameters.
Symbolic coefficients are allowed where step 1 or 3 handles them, and are assumed non-zero there — the convention solveSystem's symbolic path already follows.
Value parameters
- env
-
bindings and precision; a bound parameter is substituted, a bound unknown is ignored (it is being solved for)
- eqs
-
the left-hand sides of
eq = 0 - unknowns
-
the unknowns, in the order the answer reports them
Attributes
- Returns
-
every real solution, deduplicated;
Some(Nil)when there provably are none
The reduced Gröbner basis of the polynomials eqs in unknowns, under the lexicographic order unknowns(0) > unknowns(1) > … (F_0068), by Buchberger's algorithm.
The reduced Gröbner basis of the polynomials eqs in unknowns, under the lexicographic order unknowns(0) > unknowns(1) > … (F_0068), by Buchberger's algorithm.
Why lexicographic: a lex basis of a system with finitely many solutions is triangular — an element in the last unknown alone, then elements bringing in one more unknown at a time — which is exactly the shape eliminate finishes: a univariate equation to root-find, then substitution. So the basis is a front end to the elimination solver, never a replacement.
Exact arithmetic, always. A coefficient is read as the rational it is: a _Rational as itself, a Double as the dyadic rational the hardware holds, so no tolerance ever decides that a coefficient is zero — the decision Buchberger's algorithm makes at every step, and the one a floating-point implementation gets wrong. The answer is written back in the input's tier: exact when every coefficient was exact, Double otherwise.
Declines (None) on anything that is not a polynomial in the unknowns with numeric coefficients — a free parameter, a transcendental function, a negative or fractional power — and past any of the caps on the basis's size, degree, coefficient size and work, which are what exact Buchberger needs, since its intermediate growth is notoriously unbounded. An inconsistent system has the basis [1].
Value parameters
- env
-
bindings: a bound parameter is substituted
- eqs
-
the polynomials, each meaning
= 0 - unknowns
-
the unknowns, in decreasing lexicographic order
Attributes
- Returns
-
the reduced, monic basis in increasing order of its leading terms, or
None
The Karush–Kuhn–Tucker conditions of min f subject to g ≤ 0, h = 0, stated in the language as one conjunction (F_0010 slice 4).
The Karush–Kuhn–Tucker conditions of min f subject to g ≤ 0, h = 0, stated in the language as one conjunction (F_0010 slice 4).
Stationarity ∂f/∂xᵢ + Σμⱼ∂gⱼ/∂xᵢ + Σλₖ∂hₖ/∂xᵢ = 0, primal feasibility gⱼ ≤ 0 and hₖ = 0, dual feasibility μⱼ ≥ 0, complementary slackness μⱼ·gⱼ = 0 — every one a relation the language has had since 4.R, so no new carrier. The convention is minimisation with g ≤ 0, stated because the literature also writes g ≥ 0 and maximisation, and the sign of every multiplier depends on which. The multipliers are named mu0, mu1, … and lambda0, lambda1, … through freshVar, so they never capture a name the problem already uses.
Value parameters
- env
-
bindings and precision
- f
-
the objective
- g
-
the inequality group, each cell meaning
gⱼ ≤ 0 - h
-
the equality group, each cell meaning
hₖ = 0 - vars
-
the variables, an ordered tuple
Attributes
- Returns
-
the conditions, or
Nonewhen a group is malformed
The KKT points of min f subject to g ≤ 0, h = 0, by active-set enumeration.
The KKT points of min f subject to g ≤ 0, h = 0, by active-set enumeration.
For every subset A of the inequalities, the active ones are equalities with a multiplier and the inactive ones have none; each such system goes to eliminate, and its solutions are kept when μⱼ ≥ 0 on A and gⱼ ≤ 0 off it. The union is every KKT point.
Necessary, not sufficient: a KKT point is a candidate minimum under a constraint qualification, and on a non-convex problem it may be a maximum or a saddle.
Declines (None) when any subsystem declines — a missing active set could hide a point — when feasibility cannot be decided numerically, and past MaxKKTInequalities.
Attributes
- Returns
-
the variables' coordinates at every KKT point, or
None
Every stationary point of f on the surface g = 0, by Lagrange multipliers (F_0010 slice 3).
Every stationary point of f on the surface g = 0, by Lagrange multipliers (F_0010 slice 3).
Solves ∇f = Σλᵢ∇gᵢ together with gᵢ = 0 for the variables and the multipliers, and reports the variables only. The multipliers are invented names, so they come from freshVar (prefix __lambda, the 2.12 rule): a literal name would be captured by a parameter that happened to share it. A point whose multipliers are not determined (a degenerate constraint, where the constraint qualification fails) leaves a continuum in the multipliers, and the solver declines rather than drop it.
Value parameters
- constraints
-
the constraint expressions, each meaning
gᵢ = 0 - env
-
bindings and precision
- f
-
the objective
- vars
-
the variables, an ordered tuple
Attributes
- Returns
-
every constrained stationary point,
Some(Nil)when provably none, orNone
Minimises fᵀx subject to A x ≤ b, Aeq x = beq and lb ≤ x ≤ ub, exactly (F_0011).
Minimises fᵀx subject to A x ≤ b, Aeq x = beq and lb ≤ x ≤ ub, exactly (F_0011).
The two-phase simplex method over the rationals with Bland's rule — the lowest-index entering column and the lowest-index leaving variable on a tie — which cannot cycle, so a degenerate problem (Beale's example) terminates. Exact arithmetic is the point, the entry's reason for building this rather than leaving LP to a numeric library: every pivot decision a floating-point simplex makes with a tolerance ("is this reduced cost negative?", "is this ratio a tie?") is decided exactly, so Infeasible and Unbounded are proofs, not guesses, and the optimum needs no certificate beyond the termination itself. A Double coefficient is read as the dyadic rational it holds, and the answer is rounded to Double once, at the end.
When the optimum is not unique the vertex Bland's rule reaches is returned — deterministic, stated because another solver may return another optimal vertex.
Value parameters
- a
-
the inequality rows and their right-hand side, or
None - eq
-
the equality rows and their right-hand side, or
None - f
-
the cost vector
- lb
-
lower bounds,
-inffor none - ub
-
upper bounds,
inffor none
Attributes
- Returns
-
the optimal vertex, or why there is none
Minimises ‖r(p)‖² for an m×1 residual column r, optionally inside lb ≤ p ≤ ub (F_0063, MPC T2-05).
Minimises ‖r(p)‖² for an m×1 residual column r, optionally inside lb ≤ p ≤ ub (F_0063, MPC T2-05).
Levenberg–Marquardt with Moré's scaling, the step solved by QR of the augmented [J·D⁻¹; √λ·I] — never JᵀJ, which squares the condition number (the conditioning rule, and F_0062's ridge shape). D = diag(‖Jⱼ‖) (a running maximum) makes the step invariant to the units of each parameter, where plain damping λI is a claim about them. The damping follows Nielsen's gain-ratio update. Under bounds the method is projected with an active set: a parameter on a bound with the gradient pushing outward is held there.
The certificate always decides (Decision A): small steps or a stalled damping only stop the iteration, and the point is answered only if every free Jacobian column is orthogonal to the residual within the precision's tolerance — |Jⱼᵀr| ≤ 0.5·10⁻ᵖ·‖Jⱼ‖·‖r‖, a cosine, invariant to rescaling r and any parameter — or the residual is at the rounding level of the terms it cancels (an exact fit, where the cosine is noise). A rank-deficient Jacobian at the answer declines (Decision B).
r is evaluated with the parameters renamed to fresh names, so a session binding of a parameter's name cannot fold a cell to a constant.
Value parameters
- bounds
-
lower and upper bounds, entries may be infinite;
Nonewhen unbounded - env
-
bindings and precision
- p0
-
the starting point
- params
-
the parameters, in the order of
p0 - r
-
the residual: an
m×1column of expressions, or one expression
Attributes
- Returns
-
the certified fit, or why there is none
Minimises f over vars from x0, optionally inside the box lb ≤ x ≤ ub (F_0010 slice 5).
Minimises f over vars from x0, optionally inside the box lb ≤ x ≤ ub (F_0010 slice 5).
The gradient is the symbolic derivative, evaluated at each iterate; Newton also uses the symbolic Hessian. Two tolerances on one measure, deliberately: the iteration runs until stationarity is below 1e-10 or progress stops, and the answer is then certified against the precision's tolerance 0.5·10^-precision — the number = uses (X-02). So a well-conditioned problem is answered far more accurately than the certificate demands, and an answer is never returned that fails it. The measure is a pure number, so the verdict does not depend on the units of f or of any variable (F_0095). Under bounds it reads the projected gradient, which is zero at a constrained minimum where the gradient is not.
Value parameters
- bounds
-
lower and upper bounds, entries may be infinite;
Nonewhen unbounded - env
-
bindings and precision
- f
-
the objective
- method
-
the method
- vars
-
the variables, in the order of
x0 - x0
-
the starting point
Attributes
- Returns
-
the certified minimiser, or why it was not found
Minimises a numeric callback without derivatives (F_0302), uncertified: the answer is an UncertifiedMinimum, never a certified MinimizeResult.
Minimises a numeric callback without derivatives (F_0302), uncertified: the answer is an UncertifiedMinimum, never a certified MinimizeResult.
For an objective with no formula, no gradient, possibly non-smooth and expensive — a closed-loop simulation scoring a controller tuning, say. The method is always named. Steps and tolerances are relative to each variable's own scale (the units rule): the bound width when both bounds are finite, else |x0ᵢ|; a real variable with neither declines, an integer one takes unit scale, and a variable with equal bounds is held fixed. The initial step is a quarter of the scale (pattern search) or a twentieth (Nelder–Mead's simplex), the stopping step 0.5·10⁻ᵖ of it, so rescaling a variable by a power of two rescales the iterates exactly. A non-finite f at a trial point counts as +∞; at the start it declines. Deterministic: no random numbers, so a deterministic f gives the same path on every platform. Not addressed: a noisy objective, on which both methods may stop early or wander.
Value parameters
- env
-
the precision that sets the stopping step, and the evaluation budget
- f
-
the objective, called with a fresh array it may not keep
- hi
-
upper bounds,
+∞for none - lo
-
lower bounds,
-∞for none - method
-
the method, named
- x0
-
the start, within the bounds
Attributes
- Returns
-
the point the search stopped at, or why it did not
Minimises f over vars subject to g ≤ 0, h = 0 and lb ≤ x ≤ ub (F_0066, MPC T3-02).
Minimises f over vars subject to g ≤ 0, h = 0 and lb ≤ x ≤ ub (F_0066, MPC T3-02).
The convention is minimisation with g ≤ 0 (the kkt convention), stated because the literature also writes g ≥ 0, and the sign of every multiplier depends on which.
Two methods, always named (NlpMethod); both answer only a point that passes one KKT certificate (X-02) against the = tolerance 0.5·10⁻ᵖ:
- stationarity,
∇f + Σμⱼ∇gⱼ + Σλₖ∇hₖ, each component relative to the magnitudes of the terms that cancel in it — so the verdict does not move whenfor a variable is rescaled (the units rule; an absolute bound on a gradient is the bug F_0095 fixed inminimize). A component at an active bound is absorbed when its sign is the bound multiplier's; - primal feasibility, each violation relative to its constraint's terms;
- dual feasibility,
μ ≥ 0, and complementarity,μⱼ·gⱼ = 0.
A local KKT point is answered, the minimize precedent: on a non-convex problem it may be a local minimum other than the global one, or (rarely) a saddle of the Lagrangian. The variables are renamed to fresh names first, so a session binding of a variable's name cannot fold the problem (the lsqfit rule).
Value parameters
- bounds
-
lower and upper bounds, entries may be infinite;
Nonewhen unbounded - env
-
bindings and precision
- f
-
the objective
- g
-
the inequality constraints, each meaning
gⱼ ≤ 0 - h
-
the equality constraints, each meaning
hₖ = 0 - method
-
the method
- vars
-
the variables, in the order of
x0 - x0
-
the starting point; projected into the bounds
Attributes
- Returns
-
the certified KKT point, or why there is none
Solves the square nonlinear system F(x) = 0, F an n x 1 column of expressions in the n unknowns, from x0, optionally inside lb <= x <= ub (F_0319, AIACE L_0011).
Solves the square nonlinear system F(x) = 0, F an n x 1 column of expressions in the n unknowns, from x0, optionally inside lb <= x <= ub (F_0319, AIACE L_0011).
Powell's dogleg trust region with More's column scaling (Decision A, MINPACK's hybrj): the Newton step J p = -F when it fits the region, the scaled steepest-descent step when the region is smaller than that, and the dogleg between the two otherwise, the region grown or shrunk by the ratio of the actual to the predicted decrease of |F|^2. The Jacobian is the symbolic one (vector._Jacobian, one definition), compiled once with F -- lsqfit's Residual. Under bounds the method is projected with an active set: an unknown on a bound with the gradient of |F|^2 pushing outward is held there.
The certificate is a root, not a minimum (the units rule): every equation must vanish against the size of its own terms, |F_i(x)| <= 0.5 * 10^-p * sum_j |t_ij(x)|, so the verdict does not move when an equation or an unknown is rescaled; and the Jacobian at the root must have full numerical rank (the column-normalised one, at rankTolerance), so an isolated root is answered and a continuum declined. A stationary point of |F|^2 that is not a root -- what a least-squares fit certifies -- is declined as RootFailure.NotARoot. A start already at the root answers in no iterations, which is what a warm start from the previous step's solution wants.
Value parameters
- bounds
-
lower and upper bounds, entries may be infinite;
Nonewhen unbounded - env
-
bindings and precision
- f
-
the system: an
n x 1column of expressions, each meaningF_i = 0, or one expression - vars
-
the unknowns, in the order of
x0 - x0
-
the starting point
Attributes
- Returns
-
the certified root, or why there is none
Minimises ½ zᵀHz + fᵀz subject to A z ≤ b, Aeq z = beq and lb ≤ z ≤ ub (F_0053).
Minimises ½ zᵀHz + fᵀz subject to A z ≤ b, Aeq z = beq and lb ≤ z ≤ ub (F_0053).
Goldfarb–Idnani dual active set (Decision B): it starts at the unconstrained minimum, needs no feasible starting point, and adds the most violated constraint each step, dropping any whose multiplier would turn negative — so it stays dual-feasible and detects infeasibility by itself (a violated constraint that no step can reach). It requires H positive definite, the case of every MPC Hessian ΓᵀQΓ + R with R ≻ 0; a merely semidefinite H is never regularised but goes to the primal active-set method from an exact lpSolve feasible point (F_0074), and so inherits that LP's caps (F_0106). Ties — equally violated constraints, equal step ratios — go to the lowest index, so a run is deterministic.
Each step solves the reduced system afresh rather than updating a factorisation: at the stated size an O(n³) recompute is affordable, and code without incremental updates has no drift to repair.
Certified before it answers (X-02): stationarity, primal and dual feasibility and complementarity, each relative to the problem's scale (the 2.11 units rule), against the = tolerance 0.5·10^-precision — the minimize arrangement. A point that fails is never returned.
Value parameters
- env
-
supplies the precision the certificate is held to, and the budgets (F_0124): core.Limit.MaxQpVariables,
MaxQpConstraints,MaxQpIterations, and the LP's caps for a semidefiniteH's feasible start - eq
-
AeqandbeqofAeq z = beq, orNone - f
-
the linear term,
nentries - h
-
the Hessian,
n×n, symmetric positive definite - ineq
-
A(m×n) andb(mentries) ofA z ≤ b, orNone - lb
-
lower bounds,
nentries,-∞for none - ub
-
upper bounds,
nentries,+∞for none - warm
-
constraints believed active, typically the previous solve's QpResult.active; only the iteration count depends on it, never the answer
Attributes
- Returns
-
the certified optimum, or why there is none
Every stationary point of f, the solutions of ∇f = 0 (F_0010 slice 1).
Every stationary point of f, the solutions of ∇f = 0 (F_0010 slice 1).
The gradient's components are ordinary derivatives in the given order, solved by eliminate; the answer inherits its completeness guarantee — None whenever the set cannot be proved complete, never a partial list.
Value parameters
- env
-
bindings and precision
- f
-
the objective
- vars
-
the variables, an ordered tuple (the
gradconvention)
Attributes
- Returns
-
every stationary point,
Some(Nil)when there provably are none, orNone
Concrete fields
The augmented Lagrangian's cap on rounds, each one a full inner minimisation.
The augmented Lagrangian's cap on rounds, each one a full inner minimisation.
Attributes
The most variables convexity accepts.
The most variables convexity accepts.
The cofactor expansion behind a symbolic det stops at six (matrix's own cap, private there); past it the full-size minor stays symbolic and no true could ever be proved, so a higher cap here would buy nothing but a slower None. Kept as a separate constant because the other is not visible, and documented as its mirror so the two move together.
Attributes
Upper bound on the recursive steps one eliminate call may take.
Upper bound on the recursive steps one eliminate call may take.
Each step is one elimination (a substitution or a branch on roots); the bound caps the branching, which is what can grow. Measured, not round (F_0010, JVM): the acceptance systems take 3 to 8 steps. A system whose stationary points double with every variable (Σ xᵢ³ − 3xᵢ) takes 2ⁿ⁺¹ − 1 steps — 2047 steps and 0.13 s for its 1024 points at n = 10 — and at n = 11 (2048 points) passes the cap and declines after 0.16 s. So the cap bounds an answer near two thousand points and its cost well under a second.
Attributes
The largest basis groebnerBasis builds before declining. Measured (F_0068, JVM / Node): the test systems end with 2–4 elements and solve in tens of milliseconds — the nine-point stationary problem in 0.19 s on Node, three dense quadratics in three unknowns in 0.33 / 0.48 s, Katsura-3 in under 0.15 s. The caps bound the cost of a decline, not only of an answer.
The largest basis groebnerBasis builds before declining. Measured (F_0068, JVM / Node): the test systems end with 2–4 elements and solve in tens of milliseconds — the nine-point stationary problem in 0.19 s on Node, three dense quadratics in three unknowns in 0.33 / 0.48 s, Katsura-3 in under 0.15 s. The caps bound the cost of a decline, not only of an answer.
24, re-measured by F_0122 (2026-10-15). It was 40, and cyclic-5 — whose lexicographic basis is notoriously large — then grew 32 elements and coefficients near the 4096-bit cap before declining, in 0.6–0.9 s on the JVM and 3–5 s on Node; F_0068 had recorded 0.13 / 0.16 s, which no build reached (re-run at F_0068's own commit: 0.9–3.4 s). The last elements cost the most, since their coefficients are the widest. Every basis a successful solve builds, in the suite and in decimal-coefficient variants of its systems, holds at most 6 elements before minimisation; at 24 cyclic-5 declines in 0.2–0.7 s on the JVM and 0.75–0.9 s on Node, and every one of them still answers. The coefficient cap could not be the lever: a 2×2 system with general decimal coefficients needs 1259 bits, since a Double is read as the dyadic rational it holds.
This and the three caps below are the defaults of their core.Limits (F_0124); a caller raises one through core.Environment.withLimit.
Attributes
The largest coefficient, in bits of numerator plus denominator, before groebnerBasis declines: exact arithmetic does not round, it grows, and a lex basis is where it grows. Checked at every reduction step, which is what bounds a decline's time: without it, cyclic-5's reduction ran for minutes (F_0122). A 2×2 system with decimal coefficients needs 1259 bits, so neither 512 nor 1024 is enough.
The largest coefficient, in bits of numerator plus denominator, before groebnerBasis declines: exact arithmetic does not round, it grows, and a lex basis is where it grows. Checked at every reduction step, which is what bounds a decline's time: without it, cyclic-5's reduction ran for minutes (F_0122). A 2×2 system with decimal coefficients needs 1259 bits, so neither 512 nor 1024 is enough.
Attributes
The highest total degree an element of the basis may reach before groebnerBasis declines — a lex basis's last element carries the whole system's Bézout number as its degree, which is what the elimination solver then root-finds.
The highest total degree an element of the basis may reach before groebnerBasis declines — a lex basis's last element carries the whole system's Bézout number as its degree, which is what the elimination solver then root-finds.
Attributes
The S-polynomial reductions groebnerBasis may perform before declining.
The most inequality constraints kktPoints enumerates active sets for.
The most inequality constraints kktPoints enumerates active sets for.
The enumeration solves 2ᵐ subsystems, so the cost at least doubles per constraint. Measured (F_0010, JVM) on min Σ(xᵢ − 2)² subject to xᵢ ≤ 1, one variable per constraint: 0.11 s at m = 8, 0.16 s at 9, 0.44 s at 10 — growing by two to three per constraint, so ten keeps the worst case under half a second on the JVM. The browser is slower, which is what recurrent task F_0019 re-measures after every release.
Attributes
The widest integer, in bits, the fraction-free tableau may hold before lpSolve declines: an entry or the common denominator, the actual entries being their quotients (F_0115). A bound on memory and on one pivot's cost; the time is bounded by MaxLpWork.
The widest integer, in bits, the fraction-free tableau may hold before lpSolve declines: an entry or the common denominator, the actual entries being their quotients (F_0115). A bound on memory and on one pivot's cost; the time is bounded by MaxLpWork.
Measured on every entry a pivot writes (F_0105): every rewritten row, the right-hand sides and the reduced costs. The input is not measured on its own: a large coefficient costs nothing until a pivot combines it, and the first pivot that does is measured.
Attributes
The largest number of constraint rows (inequalities and equalities); see MaxLpVariables.
The pivot cap. Bland's rule cannot cycle, but its worst case is exponential; at the sizes accepted the measured problems take tens of pivots.
The pivot cap. Bland's rule cannot cycle, but its worst case is exponential; at the sizes accepted the measured problems take tens of pivots.
Attributes
The largest number of variables lpSolve accepts, checked before any work.
The largest number of variables lpSolve accepts, checked before any work.
Measured on Node, the slowest platform, random dense integer problems over four seeds: at 40 variables and 80 constraints 0.05–0.3 s on the JVM and 0.1–1.7 s on Node; at 50 × 100 one seed took 1.2 s on the JVM and 7.4 s on Node. The dimension does not bound the time, and neither does MaxLpBits (F_0105): dense integer problems at 40 × 80 took 3–139 s on Node in spire rationals, and never reached it. MaxLpWork is the cap that does (F_0115); these are input validation.
This and the caps below are the defaults of their core.Limits (F_0124): a library caller raises one through core.Environment.withLimit or the lpSolve overload taking core.Limits.
Attributes
The arithmetic lpSolve may do, in work units, before it declines MaxWork (F_0115): the cap that bounds the time.
The arithmetic lpSolve may do, in work units, before it declines MaxWork (F_0115): the cap that bounds the time.
Each tableau entry a pivot rewrites, (p·a − f·b)/d, costs 80 + w(p)·w(a) + w(f)·w(b) + w(q)·w(d) units, w counting 32-bit words and q the quotient: schoolbook multiplication and division, plus a fixed cost per entry. Measured on Node, over F_0105's dense problems (sixteen at 30 × 60 and 40 × 80): a unit is ~16–20 ns there and the fixed cost ~1.5 µs, which a micro-benchmark of BigInteger arithmetic confirms. At this default a decline comes after 2.1 s on Node and 0.55 s on the JVM (the MaxLsqWork figure); fifteen of the sixteen answer, the slowest in 1.85 s on Node, and the sixteenth — 352 pivots, 7.7 s to answer — is declined. Checked after each rewritten row, so a decline overshoots by at most one row.
Attributes
The iteration cap of lsqfit and curveFit (F_0063), rejected steps included.
Measured: a·e^(b·t) on exact data converges in 8 iterations from (1, 0) and in 22–36 from (0.1, −3), (0.01, 0.01) and (10, 1); Rosenbrock's residual [[10(b − a²)], [1 − a]] in 21 from (−1.2, 1). 100 is about three times the slowest converging case.
Attributes
The iteration cap, shared by every method.
The iteration cap, shared by every method.
Measured (F_0010, JVM), Rosenbrock from (−1.2, 1): BFGS converges in 35 iterations (25 ms), Newton in 22, projected BFGS in 39 unbounded and 21 with x ≤ 0.5; gradient descent needs 94 on a condition-10 quadratic. On Rosenbrock gradient descent reaches the cap after 79 ms with the gradient still at 0.014 and declines — the honest answer for that method there, so the cap is not raised to flatter it. 2000 is more than fifty times every converging case.
The default of core.Limit.MaxMinimizeIterations (F_0124); a caller raises it through core.Environment.withLimit.
Attributes
The largest number of variables accepted, checked before any work (F_0216): the default of core.Limit.MaxMinimizeVariables, whose Scaladoc holds the measurement. At the prompt the expression-depth limit stops a sum of more than about 200 terms first; this cap binds library callers, and a column of names, which carries no depth.
The largest number of variables accepted, checked before any work (F_0216): the default of core.Limit.MaxMinimizeVariables, whose Scaladoc holds the measurement. At the prompt the expression-depth limit stops a sum of more than about 200 terms first; this cap binds library callers, and a column of names, which carries no depth.
Attributes
SQP's iteration cap. Measured (F_0066, JVM): the test problems converge in 1–42 iterations — 28 for Rosenbrock with a bound, 42 for an objective scaled by 10⁶ — and a 50-variable problem in 10; 200 is almost five times the slowest.
SQP's iteration cap. Measured (F_0066, JVM): the test problems converge in 1–42 iterations — 28 for Rosenbrock with a bound, 42 for an objective scaled by 10⁶ — and a 50-variable problem in 10; 200 is almost five times the slowest.
This, MaxAugLagRounds and MaxNlpVariables are the defaults of their core.Limits (F_0124); a caller raises one through core.Environment.withLimit.
Attributes
The penalty beyond which the augmented Lagrangian gives up on feasibility. Ten orders above the start: past it the inner problems are conditioned beyond what a Double BFGS resolves, so continuing would only manufacture an answer.
The penalty beyond which the augmented Lagrangian gives up on feasibility. Ten orders above the start: past it the inner problems are conditioned beyond what a Double BFGS resolves, so continuing would only manufacture an answer.
Attributes
The largest number of variables accepted, checked before any work. Measured on a quadratic objective with two nonlinear constraints and a bound, JVM / Node: 0.34 / 0.68 s at 50 variables, 0.39 / 1.6 s at 75, for either method — the symbolic Jacobians and their compilation dominate. Re-measured by F_0120 (2026-10-15, Σ(xᵢ − cᵢ)² under Σxᵢ² ≤ n/4, Σxᵢ³ ≤ n/10, x ≥ −1, from 0; SQP 15–17 iterations, AugLag 9 rounds): 0.1–0.8 s at 50, 0.1–0.5 s at 75 and 0.3–0.6 s at 100 on the JVM; 0.4–0.8 s, 1.1 s and 2.3–3.5 s on Node — the same as before the variables were scaled. At the prompt the expression-depth limit (core.MaxExpressionDepth) stops a sum of more than about 200 terms first, so this cap binds only library callers.
The largest number of variables accepted, checked before any work. Measured on a quadratic objective with two nonlinear constraints and a bound, JVM / Node: 0.34 / 0.68 s at 50 variables, 0.39 / 1.6 s at 75, for either method — the symbolic Jacobians and their compilation dominate. Re-measured by F_0120 (2026-10-15, Σ(xᵢ − cᵢ)² under Σxᵢ² ≤ n/4, Σxᵢ³ ≤ n/10, x ≥ −1, from 0; SQP 15–17 iterations, AugLag 9 rounds): 0.1–0.8 s at 50, 0.1–0.5 s at 75 and 0.3–0.6 s at 100 on the JVM; 0.4–0.8 s, 1.1 s and 2.3–3.5 s on Node — the same as before the variables were scaled. At the prompt the expression-depth limit (core.MaxExpressionDepth) stops a sum of more than about 200 terms first, so this cap binds only library callers.
Attributes
The iteration cap of nsolve (F_0319); the measurement is on core.Limit.MaxNsolveIterations.
The iteration cap of nsolve (F_0319); the measurement is on core.Limit.MaxNsolveIterations.
Attributes
The largest number of constraint rows (inequalities, equalities and finite bounds), the companion of MaxQpVariables: 2000 rows at 500 variables is the 4.3 s point above.
The largest number of constraint rows (inequalities, equalities and finite bounds), the companion of MaxQpVariables: 2000 rows at 500 variables is the 4.3 s point above.
Attributes
The iteration cap: additions plus drops of active constraints. Measured (F_0053, JVM, random problems with half the variables' worth of constraints active): 35 iterations at 50 variables and 200 constraints, 170 at 200 / 800, 368 at 500 / 2000 — roughly 0.7 per variable — so 2000 leaves a wide margin while bounding the worst case at the largest size to tens of seconds.
The iteration cap: additions plus drops of active constraints. Measured (F_0053, JVM, random problems with half the variables' worth of constraints active): 35 iterations at 50 variables and 200 constraints, 170 at 200 / 800, 368 at 500 / 2000 — roughly 0.7 per variable — so 2000 leaves a wide margin while bounding the worst case at the largest size to tens of seconds.
This and the two caps below are the defaults of their core.Limits (F_0124); a caller raises one through core.Environment.withLimit.
Attributes
The largest number of variables accepted, checked before any work. Measured: a cold solve takes 9.6 ms at 50 variables, 51 ms at 100, 173 ms at 200 and 4.3 s at 500, the setup growing as m·n² — 500 is where it stops being interactive, the MaxSampleCount rule in time.
The largest number of variables accepted, checked before any work. Measured: a cold solve takes 9.6 ms at 50 variables, 51 ms at 100, 173 ms at 200 and 4.3 s at 500, the setup growing as m·n² — 500 is where it stops being interactive, the MaxSampleCount rule in time.