ConstraintInstance¶

class
ampl::
ConstraintInstance
¶ This class represent an instance of a constraint.
In general, all AMPL suffixes for a constraint are available through methods with the same name in this class. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes.
Note that, since this class represents instances of both algebraic and logical constraints, some suffixes might not be available for every instance. If a wrong suffix for the specific class of constraint is accessed, an std::logic_error is thrown.
All the accessors in this class throw an std::runtime_error if the instance has been deleted in the underlying AMPL interpreter.
Public Functions

void
drop
()¶ Drop this constraint instance, corresponding to the AMPL code:
drop constraintname;
.

void
restore
()¶ Restore this constraint instance, corresponding to the AMPL code:
restore constraintname;
.

double
body
() const¶ Get the current value of the constraint’s body.

std::string
astatus
() const¶ Get the current AMPL status (dropped, presolved, or substituted out)

int
defvar
() const¶ Get the index in
_var
of “defined variable” substituted out by the constraint.

double
dinit
() const¶ Get the current initial guess for the constraint’s dual variable.

double
dinit0
() const¶ Get the original initial guess for the constraint’s dual variable.

double
dual
() const¶ Get the current value of the constraint’s dual variable.
Note that dual values are often reset by the underlying AMPL interpreter by the presolve functionalities triggered by some methods. A possible workaround is to set the option
presolve;
tofalse
(see setBoolOption).

double
lb
() const¶ Get the current value of the constraint’s lower bound.

double
ub
() const¶ Get the current value of the constraint’s upper bound.

double
lbs
() const¶ Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables)

double
ubs
() const¶ Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables)

double
ldual
() const¶ Get the current dual value associated with the lower bound.

double
udual
() const¶ Get the current dual value associated with the upper bounds.

double
lslack
() const¶ Get the slack at lower bound
body  lb

double
uslack
() const¶ Get the slack at upper bound
ub  body

double
slack
() const¶ Constraint slack (the lesser of lslack and uslack)

std::string
sstatus
() const¶ Get the solver status (basis status of constraint’s slack or artificial variable)

std::string
status
() const¶ Get the AMPL status if not
in
, otherwise solver status.

void
setDual
(double dual)¶ Set the value of the dual variable associated to this constraint.
Equivalent to the AMPL statement:
let c := dual;
Note that dual values are often reset by the underlying AMPL interpreter by the presolve functionalities triggered by some methods. A possible workaround is to set the option
presolve
tofalse
(see setBoolOption). Parameters
dual
The value to be assigned to the dual variable

void