pounce_nl/lib.rs
1//! AMPL `.nl` reader, reverse-mode AD tape, and TNLP evaluator.
2//!
3//! This crate holds the `.nl` pipeline that used to live in `pounce-cli`:
4//!
5//! - [`nl_reader`] parses a `.nl` file into an [`nl_reader::NlProblem`] (the
6//! `Expr` DAG, linear parts, bounds, names, starting point) and provides
7//! [`nl_reader::NlTnlp`], a [`pounce_nlp::tnlp::TNLP`] implementation that
8//! evaluates objective/gradient/Hessian and constraints/Jacobian.
9//! - [`nl_tape`] flattens an `Expr` DAG into a reverse-mode AD tape with
10//! colored forward-over-reverse Hessian products.
11//! - [`nl_external`] supports AMPL imported (external) functions via the
12//! `funcadd_ASL` ABI.
13//! - [`nl_fbbt_translate`] lowers an `Expr` to an `FbbtTape` for
14//! feasibility-based bound tightening.
15//! - [`nl_quadratic`] recognizes a degree-≤2 polynomial in an `Expr` DAG and
16//! reads off its Hessian, linear part, and constant — the algebra behind
17//! the CLI's LP/QP/QCQP routing, kept here so the evaluator and the
18//! extractors can share it.
19//! - [`sol_writer`] is the reader's inverse: it formats a solve's primals,
20//! duals, and suffixes as an AMPL `.sol` file. It lives here (rather than
21//! in the CLI, which owned it until the browser frontend needed it too) so
22//! every frontend emits the same file — same dual sign convention, same
23//! suffix headers.
24//!
25//! It is a leaf crate (depends only on `pounce-common` and `pounce-nlp`) so
26//! both the CLI and the Python bindings can read and evaluate `.nl` models
27//! without depending on each other.
28
29pub mod nl_external;
30pub mod nl_fbbt_translate;
31pub mod nl_quadratic;
32pub mod nl_reader;
33pub mod nl_scaling;
34pub mod nl_tape;
35pub mod sol_writer;