ConstraintInstance¶
-
public class
ConstraintInstance
extends Instance<Constraint>¶ 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
IllegalStateException
if the instance has been deleted in the underlying AMPL interpreter.
Methods¶
-
public double
body
()¶ Body of the constraint
Returns: Value
-
public int
defvar
()¶ Get the index in _var of “defined variable” substituted out by the constraint
-
public double
dinit
()¶ Get the current initial guess for the constraint’s dual variable
-
public double
dinit0
()¶ Get the original initial guess for the constraint’s dual variable
-
public void
drop
()¶ Drop this constraint instance
-
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
).
-
public double
lb
()¶ Get the current value of the constraint’s lower bound
-
public double
lbs
()¶ Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables)
-
public double
ldual
()¶ Get the current dual value associated with the lower bound
-
public double
lslack
()¶ Get the slack at lower bound
body - lb
-
public void
restore
()¶ Restore this constraint instance (if it had been dropped, no effect otherwise)
-
public 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
(seeAMPL.setBoolOption
).Parameters: - dual – The value to be assigned to the dual variable
-
public double
slack
()¶ Constraint slack (the lesser of lslack and uslack)
-
public String
sstatus
()¶ Get the solver status (basis status of constraint’s slack or artificial variable)
-
public String
toString
()¶ Returns a string representation of this instance. Returns the equivalent to the AMPL statement:
expand instanceName;
-
public double
ub
()¶ Get the current value of the constraint’s upper bound
-
public double
ubs
()¶ Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables)
-
public double
udual
()¶ Get the current dual value associated with the upper bounds
-
public double
uslack
()¶ Get the slack at upper bound
ub - body
-
public double
val
()¶ Get the AMPL val suffix. Valid only for logical constraints.