Skip to main content
NEXT CLASS

 

Class IloConstraint

IloConstraint
Caution:
For technical reasons, the lower and upper bound properties LB and UB are currently accessible only during postprocessing and flow control in constraints assigned in a forall declaration. The undefined value is returned instead. You can nevertheless modify the bounds.
Example:
dvar float x in 5..20;
dvar float y in 0..20;

maximize x+y;

subject to
{
 ct1:2*x+y<=10;
 ct2:x<=7;  
}
 
execute
{
 writeln( ct1.name," ",ct1.UB," ",ct1.LB," ",ct1.dual," ",ct1.slack); 
 writeln( ct2.name," ",ct2.UB," ",ct2.LB," ",ct2.dual," ",ct2.slack); 
}
After execution, the Scripting log shows:
ct1 10 -Infinity 1 0
ct2 7 -Infinity 0 2
Iterating properties:
Default behavior.
Index resolution:
Default behavior.
OPL type:
constraint

Property Summary
Field Attributes Field Name and Description
postprocessing
flow control

Dual value in a solution.

postprocessing
flow control (write only)
LB

Lower bound.

postprocessing
flow control

Name of the constraint.

postprocessing
flow control

Slack value in a solution.

postprocessing
flow control (write only)
UB

Upper bound.

Method Summary
Method Attributes Method Name and Description
all
setBounds(lb, ub)

Sets lb as the lower bound and ub as the upper bound of the invoking numeric variable.

all
setCoef(dvar, coef)

Changes the coefficient of a decision variable in the invoking constraint.

Property Detail
dual
{float} dual

Dual value in a solution. Exists only for linear problems with CPLEX.

Available for:
postprocessing
flow control

LB
{float} LB

Lower bound.

Available for:
postprocessing
flow control (write only)

name
{string} name

Name of the constraint.

Available for:
postprocessing
flow control

slack
{float} slack

Slack value in a solution.

Exists only for CPLEX linear mixed integer problems.

Available for:
postprocessing
flow control

UB
{float} UB

Upper bound.

Available for:
postprocessing
flow control (write only)
Method Detail
setBounds
setBounds(lb, ub)

Sets lb as the lower bound and ub as the upper bound of the invoking numeric variable.

The member functionsetBounds notifies Concert Technology algorithms about the change of bounds in the numeric variable.
Parameters:
lb - Lower bound.
ub - Upper bound.
See also:
IloCplex
Available for:
all

setCoef
setCoef(dvar, coef)

Changes the coefficient of a decision variable in the invoking constraint. This method is limited to constraints that use simple real linear expressions with no aggregation. In other cases, use the method from the IloCplex class.

Parameters:
dvar - Decision variable.
coef - The new linear coefficient.
See also:
IloCplex
Available for:
all

©Copyright IBM Corp. 1987-2011.