Overview | Group | Tree | Graph | Index | Concepts |
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:
IlcCard, IlcCard, IlcIntersection, IlcIntSet, IlcIntSetIterator, IlcIntSetVarArray, IlcMember, IlcUnion, operator<<
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 void | addRequired(IlcInt elt) const |
public IlcIntSetVar | getCopy(IloSolver solver) const |
public IlcIntSetVarI * | getImpl() const |
public const char * | getName() const |
public IlcAny | getObject() const |
public IlcIntSet | getPossibleSet() const |
public IlcIntSet | getRequiredSet() const |
public IlcInt | getSize() const |
public IloSolver | getSolver() const |
public IloSolverI * | getSolverI() const |
public IlcIntSet | getValue() const |
public IlcBool | isBound() const |
public IlcBool | isInDomain(IlcIntSet set) const |
public IlcBool | isInProcess() const |
public IlcBool | isPossible(IlcInt elt) const |
public IlcBool | isRequired(IlcInt elt) const |
public void | operator=(const IlcIntSetVar & h) |
public void | removePossible(IlcInt elt) const |
public void | setDomain(IlcIntSetVar var) const |
public void | setName(const char * name) const |
public void | setObject(IlcAny object) const |
public void | whenDomain(IlcDemon demon) const |
public void | whenValue(IlcDemon demon) const |
Constructor Detail |
---|
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
).
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 |
---|
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.
This member function returns a copy of the invoking constrained set variable and associates that
copy with solver
.
This member function returns the possible set of the invoking constrained set variable
This member function returns the required set of the invoking constrained set variable.
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
.
This member function returns an instance of IloSolver
associated with the invoking object.
This member function returns a pointer to the implementation object of the solver where the invoking object was extracted.
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
).
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
.
This member function returns IlcTrue
if and only if the finite set indicated by
set
satisfies the following conditions:
set
is a possible element of the invoking constrained set variable.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.
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)
.
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)
.
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.
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.
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.
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.