Class IloConstraint
Definition file: ilconcert/iloexpression.h
An instance of this class is a constraint in a model. To create a
constraint, you can:
- use a constructor from a subclass of
IloConstraint
,
such as IloRange
, IloAllDiff
, etc. For example:
IloAllDiff allDiff(env, vars);
- use a logical operator between constraints to return a
constraint. For example, you can use the logical operators on other
constraints, like this:
IloOr or = myConstraint1 ||
myConstraint2;
- use an arithmetic operator between a numeric variable and an
expression to return a constraint. For example, you can use the arithmetic
operators on numeric variables or expressions, like this:
IloRange rng = ( x + 3*y <= 7 );
After you create a constraint, you must explicitly add it to the model in
order for it to be taken into account. To do so, use the member function
IloModel::add
or the template IloAdd
. Then extract the model for an algorithm with the
member function IloAlgorithm::extract
.
Most member functions in this class contain assert
statements. For an explanation of the macro NDEBUG
(a way to
turn on or turn off these assert
statements), see the concept
Assert and NDEBUG.
See Also:
IloConstraintArray, IloModel, IloRange
Method Summary |
---|
public IloConstraint::ImplClass * | getImpl() |
public IloConstraint()
This constructor creates an empty handle. You must initialize it before you use it.
public IloConstraint(IloConstraint::ImplClass * impl)
This constructor creates a handle object from a pointer to an implementation object.
public IloConstraint::ImplClass * getImpl()
This member function returns a pointer to the implementation object of the invoking handle.