jaxglobal.nl¶
Read AMPL .nl files (text format) into JAX functions.
read_nl(path) returns an :class:NLModel with f, ineq, eq and
the variable bounds in the form minimize takes, so any model written by
AMPL, Pyomo, GAMS (convert) or downloaded from MINLPLib becomes a jaxglobal
problem. The expression trees are compiled to plain jax.numpy code: the
solver sees an ordinary traced function, exactly as for hand-written models.
Supported: text ("g") and binary ("b") formats, nonlinear expressions, linear
parts (J/G segments), defined variables (V segments), ranges, bounds and
initial points. Not supported: imported functions, suffixes, logical
constraints and complementarity. Integer variables are read as a mask
(NLModel.integer) with integers="mask". By default ("error") a model
with integer variables raises NLError, because passing only f, the
constraints and the bounds to a solver would solve its continuous relaxation and
report that optimum as the model's; "relax" reads it as that relaxation.
Reference: D. M. Gay, "Writing .nl Files" (Sandia report SAND2005-7907P).
NLError ¶
Bases: ValueError
The file uses a feature this reader does not support.
parse_nl ¶
parse_nl(data, name='model', integers='error')
Parse .nl contents (bytes or str, text or binary format).
integers: for a model with integer variables, "error" raises
NLError, "mask" sets NLModel.integer, and "relax" reads the
continuous relaxation (integer all False).