pub struct NlProblem {Show 20 fields
pub n: usize,
pub m: usize,
pub num_obj: usize,
pub minimize: bool,
pub obj_nonlinear: Expr,
pub obj_linear: Vec<(usize, f64)>,
pub obj_constant: f64,
pub con_nonlinear: Vec<Expr>,
pub con_linear: Vec<Vec<(usize, f64)>>,
pub x_l: Vec<f64>,
pub x_u: Vec<f64>,
pub g_l: Vec<f64>,
pub g_u: Vec<f64>,
pub x0: Vec<f64>,
pub lambda0: Vec<f64>,
pub suffixes: NlSuffixes,
pub ampl_options: Vec<i64>,
pub imported_funcs: Vec<ImportedFunc>,
pub var_names: Vec<String>,
pub con_names: Vec<String>,
}Expand description
Parsed .nl problem in the form needed by NlTnlp.
Fields§
§n: usize§m: usize§num_obj: usize§minimize: bool§obj_nonlinear: Expr§obj_linear: Vec<(usize, f64)>§obj_constant: f64§con_nonlinear: Vec<Expr>Per-constraint nonlinear part (length m).
con_linear: Vec<Vec<(usize, f64)>>Per-constraint linear part (length m), each a list of (var, coef).
x_l: Vec<f64>§x_u: Vec<f64>§g_l: Vec<f64>§g_u: Vec<f64>§x0: Vec<f64>§lambda0: Vec<f64>§suffixes: NlSuffixesAMPL suffix dictionaries. Variable / constraint / objective
suffixes are stored as dense vectors (length n / m / num_obj)
with the sparse .nl S-segment entries scattered in, default
zero. The integer / real split matches the S-segment header’s
kind bit (0x4 ⇒ real, else integer). See
https://ampl.com/REFS/hooking2.pdf §6 and the upstream .nl
reader in ref/Ipopt/src/Apps/AmplSolver/AmplTNLP.cpp.
ampl_options: Vec<i64>The model’s own AMPL option words, taken verbatim from .nl
header line 0 (g<count> <opt0> <opt1> ...). A solver echoes
these back in the .sol Options block rather than interpreting
them — see crate::sol_writer::format_sol_with_options. Empty
for problems not built from a .nl file.
imported_funcs: Vec<ImportedFunc>AMPL imported (external) functions declared via top-level F segments.
Empty unless the .nl file calls compiled-C user functions (typically
emitted by IDAES property packages — see issue #49).
var_names: Vec<String>Variable names from the sibling .col file, index-aligned to x
(one name per line, column order). Empty when no .col file was
found — AMPL only emits it under option auxfiles rc;.
Carrying names lets diagnostics report flow_balance / T_reactor
instead of c[3] / x[132]. Lee et al. (2024) identify the gap
between detecting an issue and tracing it to a named equation as a
central roadblock for equation-oriented model debugging; threading
names through to the solver/debugger is the prerequisite for closing
it. See https://doi.org/10.69997/sct.147875.
con_names: Vec<String>Constraint names from the sibling .row file, index-aligned to g
(one name per line, row order). Empty when no .row file was found.
See NlProblem::var_names for why names are captured.
Implementations§
Source§impl NlProblem
impl NlProblem
Sourcepub fn from_expressions(parts: NlProblemParts) -> Result<NlProblem, String>
pub fn from_expressions(parts: NlProblemParts) -> Result<NlProblem, String>
Assemble a problem from expression trees, with no .nl file
anywhere in the loop (issue #469).
A modeling frontend that already has its own expression DAG should
come in here rather than serialize to .nl and re-parse: the round
trip is not only slower, it is lossy, because .nl writers
routinely refuse operators this tape supports natively (atan2,
min/max, and — with no .nl opcode at all — UnaryOp::Erf).
The result is an ordinary NlProblem, so it feeds
NlTnlp::try_new and gets exactly the evaluators a parsed model
does: objective, gradient, constraints, Jacobian + structure,
Lagrangian Hessian + structure, and
NlTnlp::hessian_vector_product.
Errors on a length mismatch or on a Var(i) index at or beyond n
— the latter would otherwise be an out-of-bounds read in the tape’s
forward sweep, so it must be caught while it is still a diagnosable
user error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NlProblem
impl RefUnwindSafe for NlProblem
impl Send for NlProblem
impl Sync for NlProblem
impl Unpin for NlProblem
impl UnsafeUnpin for NlProblem
impl UnwindSafe for NlProblem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more