Expand description
Translate parsed .nl constraint expressions into an
FbbtTape for the presolve FBBT pass (issue #62).
The Expr tree pounce reads from a .nl file uses a richer
operator set than FBBT supports (extern function calls,
variable-exponent powers, AMPL log10, n-ary sums) and embeds
common subexpressions via Rc sharing. This module flattens
the tree into a tape where:
- Every
Expr::Cse(rc)is emitted once and re-referenced by slot index on every subsequent occurrence — matching the per-Rc-pointer caching strategynl_tape::Tape::buildalready uses for AD tapes. - Operators FBBT can reason about become the corresponding
FbbtOpvariants. - Anything else collapses to
FbbtOp::Opaque, which forward / reverse interval passes treat as “no information here.” A single unsupported sub-expression doesn’t poison the whole constraint — intervals just stop tightening through that subtree.
The full constraint expression on row i is con_nonlinear[i] + Σ_k coef_k · x_{var_k}. The linear part is folded in after the
nonlinear translation, so the resulting tape has one root
representing the entire constraint.
Functions§
- translate_
constraint - Translate the nonlinear part of constraint
itogether with its linear coefficients into a single tape. ReturnsNoneif neither part contributes anything (no nonlinear expression and no linear coefficients) — there’s nothing for FBBT to tighten against.