NO FRAMES

Class IloAnd

Definition file: ilconcert/ilomodel.h
Defines a logical conjunctive-AND among other constraints.

An instance of IloAnd represents a conjunctive constraint. In other words, it defines a logical conjunctive-AND among any number of constraints. It lets you represent a constraint on constraints in your model. Since an instance of IloAnd is a constraint itself, you can build up extensive conjunctions by adding constraints to an instance of IloAnd by means of the member function IloAnd::add. You can also remove constraints from an instance of IloAnd by means of the member function IloAnd::remove.

The elements of a conjunctive constraint must be in the same environment.

In order for the constraint to take effect, you must add it to a model with the template IloAdd or the member function IloModel::add and 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.

Conjunction of Goals

If you want to represent the conjunction of goals (rather than constraints) in your model, then you should consider the function IloAndGoal (documented in the ILOG Solver Reference Manual).

What Is Extracted

All the constraints (that is, instances of IloConstraint or one of its subclasses) that have been added to a conjunctive constraint (an instance of IloAnd) and that have not been removed from it will be extracted when an algorithm such as IloCplex, IloCP, or IloSolver extracts the constraint.

Example

For example, you may write:

 IloAnd and(env);
 and.add(constraint1);
 and.add(constraint2);
 and.add(constraint3);
 

Those lines are equivalent to :

 IloAnd and = constraint1 && constraint2 && constraint3;
 

See Also:

Constructor Summary
public IloAnd()
public IloAnd(IloAndI * impl)
public IloAnd(const IloEnv env, const char * name=0)
Method Summary
public voidadd(const IloConstraintArray array) const
public voidadd(const IloConstraint constraint) const
public IloAndI *getImpl() const
public voidremove(const IloConstraintArray array) const
public voidremove(const IloConstraint constraint) const
Inherited Methods from IloConstraint
getImpl
Inherited Methods from IloIntExprArg
getImpl
Inherited Methods from IloNumExprArg
getImpl
Inherited Methods from IloExtractable
asConstraint, asIntExpr, asModel, asNumExpr, asObjective, asVariable, end, getEnv, getId, getImpl, getName, getObject, isConstraint, isIntExpr, isModel, isNumExpr, isObjective, isVariable, setName, setObject
Constructor Detail

IloAnd

public IloAnd()
This constructor creates an empty handle. You must initialize it before you use it.

IloAnd

public IloAnd(IloAndI * impl)
This constructor creates a handle object from a pointer to an implementation object.

IloAnd

public IloAnd(const IloEnv env, const char * name=0)

This constructor creates a conjunctive constraint for use in the environment env. In order for the constraint to take effect, you must add it to a model with the template IloAdd or the member function IloModel::add and extract the model for an algorithm with the member function IloAlgorithm::extract.

The optional argument name is set to 0 by default.


Method Detail

add

public void add(const IloConstraintArray array) const

This member function makes all the elements in array elements of the invoking conjunctive constraint. In other words, it applies the invoking conjunctive constraint to all the elements of array.

Note
The member function add notifies Concert Technology algorithms about this change to the invoking object.

add

public void add(const IloConstraint constraint) const

This member function makes constraint one of the elements of the invoking conjunctive constraint. In other words, it applies the invoking conjunctive constraint to constraint.

Note
The member function add notifies Concert Technology algorithms about this change to the invoking object.

getImpl

public IloAndI * getImpl() const
This member function returns a pointer to the implementation object of the invoking handle.

remove

public void remove(const IloConstraintArray array) const

This member function removes all the elements of array from the invoking conjunctive constraint so that the invoking conjunctive constraint no longer applies to any of those elements.

Note
The member function remove notifies Concert Technology algorithms about this change to the invoking object.

remove

public void remove(const IloConstraint constraint) const

This member function removes constraint from the invoking conjunctive constraint so that the invoking conjunctive constraint no longer applies to constraint.

Note
The member function remove notifies Concert Technology algorithms about this change to the invoking object.