The Constraint object stores the information regarding a constraint in the algebraic
model.
It can contain multiple constraint instances, or can be scalar. Generally, numerical values are available
for each ConstraintInstance
, which are accessible through the function Constraint.get
.
For scalar constraints, direct accessors to the values are available (see functions Constraint.body
or Constraint.dual
below).
For ease of use, values for the entire algebraic entity can be accessed directly and assigned to MATLAB vectors using the
DataFrame
object. To assign values in this way, see AMPL.setData
. To get the values use
Constraint.getValues
.
body()
-
classmethod Constraint.body()
Description
v = body()
FOR SCALAR CONSTRAINTS ONLY: Get the current value of the constraint’s body
**Output Arguments**
v
The current body of the constraint
Example
Create a scalar constraint c (using AMPL.eval
) and get its body.
ampl.eval('var x := 4.2;');
ampl.eval('c : 0<= x <= 5;');
c = ampl.getConstraint('c');
c.body
gives: