FRAMES NO FRAMES

Class IlcAnyVar

Definition file: ilsolver/anyexp.h
Include file: <ilsolver/ilosolver.h>

In order to state constraints on arbitrary objects, Solver defines classes of constrained enumerated variables and expressions. IlcAnyVar, the class of constrained enumerated variables, derives from its root class, IlcAnyExp, the class of constrained enumerated expressions.

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.

Backtracking and Reversibility

All the member functions and operators defined for this class and capable of modifying constrained variables are reversible. In particular, the changes made by constraint-posting functions are made with reversible assignments. Thus, the value, the domain, and the constraints posted on any constrained variable are restored when Solver backtracks.

Domain-Delta and Propagation

When a propagation event is triggered for a constrained variable, the variable is pushed into the propagation queue if it was not already in the queue. Moreover, the modifications of the domain of the constrained variable are stored in a special set called the domain-delta. This domain-delta can be accessed during the propagation of the constraints posted on that variable. When all the constraints posted on that variable have been processed, then the domain-delta is cleared. If the variable is modified again, then the whole process begins again. The state of the domain-delta is reversible.

See Also:

Constructor Summary
public IlcAnyVar(IloSolver solver, const IlcAnyArray values, const char * name=0)
public IlcAnyVar()
public IlcAnyVar(IlcIntExpI * impl)
public IlcAnyVar(const IlcAnyExp exp)
Method Summary
public IlcBoolisInDelta(IlcAny value) const
public IlcBoolisInProcess() const
public voidoperator=(const IlcAnyExp & exp)
public voidoperator=(const IlcAnyVar & exp)
Inherited Methods from IlcAnyExp
getCopy, getImpl, getName, getObject, getSize, getSolver, getSolverI, getValue, isBound, isInDomain, operator=, removeDomain, removeDomain, removeValue, setDomain, setDomain, setDomain, setName, setObject, setValue, whenDomain, whenValue
Constructor Detail

IlcAnyVar

public IlcAnyVar(IloSolver solver, const IlcAnyArray values, const char * name=0)

This constructor creates a constrained enumerated variable with a domain containing exactly those pointers that belong to values, an array of pointers. The optional argument name, if provided, becomes the name of the constrained enumerated variable.


IlcAnyVar

public IlcAnyVar()

This constructor creates a constrained enumerated variable which is empty, that is, whose handle pointer is null. This object must then be assigned before it can be used, exactly as when you, as a developer, declare a pointer.


IlcAnyVar

public IlcAnyVar(IlcIntExpI * impl)

This constructor creates a handle object (an instance of the class IlcAnyVar) from a pointer to an object (an instance of the implementation class IlcIntExpI).


IlcAnyVar

public IlcAnyVar(const IlcAnyExp exp)

To transform a constrained enumerated expression (which computes its domain from its subexpressions) into a constrained enumerated variable (which stores its domain), you can use this constructor. It associates a domain with the constrained enumerated expression exp. This expression thus becomes a constrained enumerated variable. Moreover, the newly created constrained enumerated variable points to the same implementation object as exp. (You can also use the assignment operator for the same purpose.)


Method Detail

isInDelta

public IlcBool isInDelta(IlcAny value) const

This member function returns IlcTrue if the argument value belongs to the domain-delta of the invoking constrained variable. This member function can be applied only to the variable currently in process.


isInProcess

public IlcBool isInProcess() const

This member function returns IlcTrue if the invoking constrained variable is currently being processed by the constraint propagation algorithm. Only one variable can be in process at a time.


operator=

public void operator=(const IlcAnyExp & exp)

This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the argument exp. After the execution of this operator, the invoking object and the exp object both point to the same implementation object. Moreover, this assignment operator associates a domain with the constrained enumerated expression exp, which is thus transformed into a constrained enumerated variable.


operator=

public void operator=(const IlcAnyVar & exp)

This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the argument exp. After the execution of this operator, the invoking object and the exp object both point to the same implementation object. This assignment operator has no effect on its argument.