ConstraintInstance

class 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 error is thrown.

All the accessors in this class throw an error if the instance has been deleted in the underlying AMPL interpreter.

ConstraintInstance.name()

Returns the name of this instance.

Returns:Name of the instance.
ConstraintInstance.toString()

Returns a string representation of this instance.

Returns:String representation of this instance.
ConstraintInstance.drop()

Drop this constraint instance, corresponding to the AMPL code: drop constraintname;

ConstraintInstance.restore()

Restore this constraint instance, corresponding to the AMPL code: restore constraintname;

ConstraintInstance.body()

Get the current value of the constraint’s body.

Returns:The current value of the constraint’s body.
ConstraintInstance.astatus()

Get the current AMPL status (dropped, presolved, or substituted out).

Returns:The current AMPL status.
ConstraintInstance.defvar()

Get the index in _var of “defined variable” substituted out by the constraint.

Returns:The index of the variable substituted out by the constraint.
ConstraintInstance.dinit()

Get the current initial guess for the constraint’s dual variable.

Returns:The current initial guess for the constraint’s dual variable.
ConstraintInstance.dinit0()

Get the original initial guess for the constraint’s dual variable.

Returns:The original initial guess for the constraint’s dual variable.
ConstraintInstance.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; to false (see setOption).

Returns:The current value of the constraint’s dual variable.
ConstraintInstance.lb()

Get the current value of the constraint’s lower bound.

Returns:The current value of the constraint’s lower bound.
ConstraintInstance.ub()

Get the current value of the constraint’s upper bound.

Returns:The current value of the constraint’s upper bound.
ConstraintInstance.lbs()

Get the constraint lower bound sent to the solver (reflecting adjustment for fixed variables).

Returns:The constraint lower bound sent to the solver.
ConstraintInstance.ubs()

Get the constraint upper bound sent to the solver (reflecting adjustment for fixed variables).

Returns:The constraint upper bound sent to the solver.
ConstraintInstance.ldual()

Get the current dual value associated with the lower bound.

Returns:The current dual value associated with the lower bound.
ConstraintInstance.udual()

Get the current dual value associated with the upper bounds

Returns:The current dual value associated with the upper bound.
ConstraintInstance.lslack()

Get the slack at lower bound body - lb.

Returns:The slack at lower bound.
ConstraintInstance.uslack()

Get the slack at upper bound ub - body

Returns:The slack at upper bound.
ConstraintInstance.slack()

Constraint slack (the lesser of lslack and uslack).

Returns:The constraint slack.
ConstraintInstance.sstatus()

Get the solver status (basis status of constraint’s slack or artificial variable)

Returns:The solver status.
ConstraintInstance.status()

Get the AMPL status if not in, otherwise solver status.

Returns:The AMPL status.
ConstraintInstance.setDual(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 to false (see setOption).

Parameters:dual (float) – The value to be assigned to the dual variable.
ConstraintInstance.val()

Get the AMPL val suffix. Valid only for logical constraints.

Returns:The val suffix.