ConstraintInstance¶
- public class ConstraintInstance extends BasicInstance<ConstraintInstanceBase>¶
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
UnsupportedOperationException
is thrown.All the accessors in this class throw a
IllegalArgumentException
if the instance has been deleted in the underlying AMPL interpreter.
Constructors¶
ConstraintInstance¶
- ConstraintInstance(ConstraintInstanceBase impl)¶
Methods¶
astatus¶
body¶
- public double body()¶
Get the current value of the constraint’s body
defvar¶
- public int defvar()¶
Get the index in
_var
of “defined variable” substituted out by the constraint
dinit¶
- public double dinit()¶
Get the current initial guess for the constraint’s dual variable
dinit0¶
- public double dinit0()¶
Get the original initial guess for the constraint’s dual variable
drop¶
- public void drop()¶
Drop this constraint instance
dual¶
- public double dual()¶
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
(seeAMPL.setBoolOption
).
impl¶
- ConstraintInstanceBase impl()¶
lb¶
- public double lb()¶
Get the current value of the constraint’s lower bound
lbs¶
- public double lbs()¶
Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables)
ldual¶
- public double ldual()¶
Get the current dual value associated with the lower bound
lslack¶
- public double lslack()¶
Get the slack at lower bound
body - lb
restore¶
- public void restore()¶
Restore this constraint instance (if it had been dropped, no effect otherwise)
setDual¶
- public void setDual(double dual)¶
Set the value of the dual variable associated to this constraint (valid only if the constraint is scalar). 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
(seeAMPL.setBoolOption
).- Parameters
dual – The value to be assigned to the dual variable
slack¶
- public double slack()¶
Constraint slack (the lesser of lslack and uslack)
sstatus¶
status¶
ub¶
- public double ub()¶
Get the current value of the constraint’s upper bound
ubs¶
- public double ubs()¶
Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables)
udual¶
- public double udual()¶
Get the current dual value associated with the upper bounds
uslack¶
- public double uslack()¶
Get the slack at upper bound
ub - body
val¶
- public double val()¶
Get the AMPL val suffix. Valid only for logical constraints.