FRAMES NO FRAMES

Class IlcIntSetVar

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

A constrained set variable is any instance of the class IlcIntSetVar or IlcAnySetVar. The value of a variable belonging to the class IlcIntSetVar is an instance of the class IlcIntSet. The value of a variable belonging to the class IlcAnySetVar is an instance of the class IlcAnySet. These two classes are handle classes. They both have the same implementation class, IlcIntSetVarI.

Domain

The domain associated with a constrained set variable is a set of sets. Solver represents this kind of domain by its upper and lower bounds. The upper bound is the union of all the possible values for the variable, that is the union of all the element-sets of the domain. The lower bound is the intersection of all the possible values of the variables, that is the intersection of all the element-sets of the domain.

In other words, the domain of a constrained set variable is represented by two sets:

The possible set contains the required set by construction. The value, the possible set, and the required set of a constrained set variable are all instances of the classes IlcAnySet or IlcIntSet. When a constrained set variable is bound, the required elements are the same as the possible ones, and they are the elements of the value of the variable.

Delta Sets and Propagation

When a propagation event is triggered for a constrained set variable, the variable is pushed into the constraint propagation queue if it was not already in the queue. Moreover, the modifications of the domain of the constrained set variable are stored in two special sets. The first set stores the values removed from the possible set of the constrained set variable, and it is called the possible-delta set. The second one stores the values added to the required set of the constrained set variable, and it is called the required-delta set. These delta sets 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 delta sets are cleared. If the variable is modified again, then the whole process begins again. The state of the delta sets is reversible.

Failure

The domain of a constrained set variable can be reduced until it is empty, that is, to the point that the required set is not included in the possible set. In such a case, failure is triggered since at that point, no solution is possible.

Cardinality (Size of Set)

It is also possible to constrain the cardinality of the value of a constrained set variables. A constrained set variables contains a data member that is constrained integer variable (called the cardinality variable); it represents how many elements are in the value of the set variable. The minimum of the cardinality variable is always greater than or equal to the size of the required set. Its maximum is always less than or equal to the size of the possible set. The functions IlcCard (for sets and for indices) access cardinality.

Backtracking and Reversibility

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

A modifier is a member function that reduces the domain of a constrained integer set variable, if it can. The modifier is not stored, in contrast to a constraint. If the domain becomes empty, a failure occurs. Modifiers are usually used to define new classes of constraints.

See Also:

Constructor Summary
public IlcIntSetVar()
public IlcIntSetVar(IlcIntSetVarI * impl)
public IlcIntSetVar(IloSolver solver, IlcInt min, IlcInt max, const char * name=0)
public IlcIntSetVar(IloSolver solver, const IlcIntArray array, const char * name=0)
Method Summary
public voidaddRequired(IlcInt elt) const
public IlcIntSetVargetCopy(IloSolver solver) const
public IlcIntSetVarI *getImpl() const
public const char *getName() const
public IlcAnygetObject() const
public IlcIntSetgetPossibleSet() const
public IlcIntSetgetRequiredSet() const
public IlcIntgetSize() const
public IloSolvergetSolver() const
public IloSolverI *getSolverI() const
public IlcIntSetgetValue() const
public IlcBoolisBound() const
public IlcBoolisInDomain(IlcIntSet set) const
public IlcBoolisInProcess() const
public IlcBoolisPossible(IlcInt elt) const
public IlcBoolisRequired(IlcInt elt) const
public voidoperator=(const IlcIntSetVar & h)
public voidremovePossible(IlcInt elt) const
public voidsetDomain(IlcIntSetVar var) const
public voidsetName(const char * name) const
public voidsetObject(IlcAny object) const
public voidwhenDomain(IlcDemon demon) const
public voidwhenValue(IlcDemon demon) const
Constructor Detail

IlcIntSetVar

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

IlcIntSetVar

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

IlcIntSetVar

public IlcIntSetVar(IloSolver solver, IlcInt min, IlcInt max, const char * name=0)

This constructor creates a constrained set of integers with no required elements; its possible elements range from min to max, included. If min is greater than max, this constructor will throw an exception (an instance of IloSolver::SolverErrorException).


IlcIntSetVar

public IlcIntSetVar(IloSolver solver, const IlcIntArray array, const char * name=0)

This constructor creates a constrained set of integers with no required elements; its possible elements are the integers in array, an array of integers.


Method Detail

addRequired

public void addRequired(IlcInt elt) const

The way this member function behaves depends on whether its argument elt is a member of the required or possible set of the invoking object. If elt is already in the required set of the invoking object, then this member function does nothing. If elt is in the possible set of the invoking object, but not yet in the required set, then this member function adds elt to the required set. If elt is not in the possible set of the invoking object, then this member function indicates a failure.


getCopy

public IlcIntSetVar getCopy(IloSolver solver) const

This member function returns a copy of the invoking constrained set variable and associates that copy with solver.


getImpl

public IlcIntSetVarI * getImpl() const
This constructor creates an object by copying another one. This constructor creates an object by copying another one. This member function returns a pointer to the implementation object of the invoking handle.

getName

public const char * getName() const
This member function returns the name of the invoking object.

getObject

public IlcAny getObject() const
This member function returns a pointer to the external object associated with the invoking object, if there is such an association. It returns 0 (zero) otherwise.

getPossibleSet

public IlcIntSet getPossibleSet() const

This member function returns the possible set of the invoking constrained set variable


getRequiredSet

public IlcIntSet getRequiredSet() const

This member function returns the required set of the invoking constrained set variable.


getSize

public IlcInt getSize() const

This member function returns one plus the difference between the cardinality of the set of possible elements and the cardinality of the set of required elements. Don't confuse the size of the domain of the constrained set variable (returned by this member function) with the cardinality of the set to which the variable is bound (that is, the size of the value of the variable). The cardinality of the set variable itself is a constrained integer variable returned by the function IlcCard.


getSolver

public IloSolver getSolver() const

This member function returns an instance of IloSolver associated with the invoking object.


getSolverI

public IloSolverI * getSolverI() const

This member function returns a pointer to the implementation object of the solver where the invoking object was extracted.


getValue

public IlcIntSet getValue() const

This member function returns the value of the invoking constrained set variable if that variable has been bound; otherwise, it will throw an exception (an instance of IloSolver::SolverErrorException).


isBound

public IlcBool isBound() const

This member function returns IlcTrue if the constrained set variable has been bound, that is, if its set of required elements is equal to its set of possible elements. Otherwise, the member function returns IlcFalse.


isInDomain

public IlcBool isInDomain(IlcIntSet set) const

This member function returns IlcTrue if and only if the finite set indicated by set satisfies the following conditions:


isInProcess

public IlcBool isInProcess() const

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


isPossible

public IlcBool isPossible(IlcInt elt) const

This member function returns IlcTrue if elt is a possible element in the invoking constrained set variable. It returns IlcFalse otherwise. This member function could be defined as getPossibleSet().isIn(elt).


isRequired

public IlcBool isRequired(IlcInt elt) const

This member function returns IlcTrue if elt is a required element in the invoking constrained set variable. It returns IlcFalse otherwise. This member function could be defined as getRequiredSet().isIn(elt).


operator=

public void operator=(const IlcIntSetVar & h)
This operator assigns an address to the handle pointer of the invoking object. That address is the location of the implementation object of the provided argument.

removePossible

public void removePossible(IlcInt elt) const

The way this member function behaves depends on whether its argument elt is a member of the required set of the invoking object. If elt is in the required set of the invoking object, then this member function indicates a failure. If elt is in the possible set of the invoking object, but not in the required set, then this member function removes elt from the possible set.


setDomain

public void setDomain(IlcIntSetVar var) const

This member function reduces the domain of the invoking constrained set variable so that its domain becomes included in the domain of the constrained set variable var.

If the invoking variable is already bound, then this member function considers whether its value belongs to the domain of var. If its value does not belong to the domain of var, then the member function indicates failure.

If the invoking variable is not yet bound, then its required set is replaced by its union with the required set of var, and its possible set is replaced by its intersection with the possible set of var. If the resulting required set is not included in the resulting possible set, then the member function indicates failure. If the resulting required set contains the same elements as the resulting possible set, then the invoking variable is bound to that remaining value. In any case, if the invoking variable is modified, the constraints posted on it are activated.

The effects of this member function are reversible.


setName

public void setName(const char * name) const
This member function sets the name of the invoking object to a copy of name. This assignment is a reversible action.

setObject

public void setObject(IlcAny object) const
This member function establishes a link between the invoking object and an external object of which the invoking object might be a data member.

whenDomain

public void whenDomain(IlcDemon demon) const

This member function associates demon with the domain propagation event of the invoking constrained set variable. Whenever the domain of the invoking constrained set variable changes, the demon will be executed immediately.

Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever the domain of the invoking constrained set variable changes, the constraint will be propagated.


whenValue

public void whenValue(IlcDemon demon) const

This member function associates demon with the value propagation event of the invoking constrained set variable. Whenever the invoking constrained set variable becomes bound, the demon will be executed immediately.

Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever the invoking constrained set variable becomes bound, the constraint will be propagated.