Skip to main content

Module nl_fbbt_translate

Module nl_fbbt_translate 

Source
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 strategy nl_tape::Tape::build already uses for AD tapes.
  • Operators FBBT can reason about become the corresponding FbbtOp variants.
  • 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 i together with its linear coefficients into a single tape. Returns None if neither part contributes anything (no nonlinear expression and no linear coefficients) — there’s nothing for FBBT to tighten against.