AMPLRepn
(class from pyomo.repn.ampl
)
- class pyomo.repn.ampl.AMPLRepn(const, linear, nonlinear)[source]
Bases:
object
The “compiled” representation of an expression in AMPL NL format.
This stores a compiled form of an expression in the AMPL “NL” format. The data structure contains 6 fields:
- mult
A constant multiplier applied to this expression. The :py:class`AMPLRepn` returned by the :py:class`AMPLRepnVisitor` should always have mult == 1.
- Type:
- nonlinear
The general nonlinear portion of the compiled expression as a tuple of two parts:
the nl template string: this is the NL string with placeholders (
%s
) for all the variables that appear in the expression.an iterable if the
VarData
IDs that correspond to the placeholders in the nl template string
This is None if there is no general nonlinear part of the expression. Note that this can be a list of tuple fragments within AMPLRepnVisitor, but that list is concatenated to a single tuple when exiting the AMPLRepnVisitor.
- named_exprs
A set of IDs point to named expressions (
Expression
) objects appearing in this expression.
- nl
This holds the complete compiled representation of this expression (including multiplier, constant, linear terms, and nonlinear fragment) using the same format as the nonlinear attribute. This field (if not None) should be considered authoritative, as there are NL fragments that are not representable by {mult, const, linear, nonlinear} (e.g., string arguments).
Methods
__init__
(const, linear, nonlinear)append
(other)Append a child result from acceptChildResult
compile_nonlinear_fragment
()compile_repn
([prefix, args, named_exprs])duplicate
()to_expr
(var_map)Attributes
Member Documentation