Overview | Group | Tree | Graph | Index | Concepts |
The class IlcIntVarArray
is the class for an array
of instances of IlcIntVar
. Three
integers—indexMin
, indexMax
, and
indexStep
—play an important role in such an array of
constrained integer variables. The index of those variables ranges from
indexMin
, inclusive, to indexMax
, exclusive, in
steps of indexStep
. The index of the first variable in the
array is indexMin
; the second one is
indexMin+indexStep
, and so forth. The quantity
indexMax-indexMin
must be a multiple of
indexStep
.
Generic Constraints
The array makes it easier to implement generic constraints. In this context, a generic constraint is a constraint that applies to all of the variables in the array. Member functions of the array class are available to post such generic constraints. A generic constraint is then allocated and recorded only once for all the variables in the array. This fact represents a significant economy in memory, compared to allocating and recording one constraint per variable.
Interval Constraints
Arrays of constrained variables also allow you to define interval
constraints which propagate in a global way when the domains of one or
more constrained variables in the array are modified. Propagation is then
performed through a goal. Member functions such as
whenValueInterval
, whenRangeInterval
, or
whenDomainInterval
associate goals with propagation events for
this purpose.
Backtracking and Reversibility
All the functions and member functions capable of modifying arrays of constrained integer variables are reversible. In particular, when modifiers and functions that post constraints are called, the state before their call will be saved by Solver.
Empty Handle or Null Array
It is possible to create a null array, or in other words, an empty handle. When you do so, only these operations are allowed on that null array:
getSize
for the null array returns 0 (zero).
ok
returns
IlcFalse
for a null array.Attempts to access a null array in any other way will throw an exception
(an instance of IloSolver::SolverErrorException
).
See Also:
IlcAbstraction, IlcIndex, IlcIntVar, IlcIntVarArrayIterator, operator<<
Constructor Summary | |
---|---|
public | IlcIntVarArray() |
public | IlcIntVarArray(IlcIntVarArrayI * impl) |
public | IlcIntVarArray(IloSolver solver, IlcInt size) |
public | IlcIntVarArray(IloSolver solver, IlcInt size ILCPARAM, const IlcIntVar v1, const IlcIntVar v2) |
public | IlcIntVarArray(IloSolver solver, IlcInt size, IlcInt min, IlcInt max) |
public | IlcIntVarArray(IloSolver s, IlcInt indexMin, IlcInt indexMax, IlcInt indexStep, const IlcIntVar prototype) |
Method Summary | |
---|---|
public IlcIntVarArray | getCopy(IloSolver solver) const |
public IlcInt | getDomainIndexMax() const |
public IlcInt | getDomainIndexMin() const |
public IlcIntVarArrayI * | getImpl() const |
public IlcInt | getIndexMax() const |
public IlcInt | getIndexMin() const |
public IlcInt | getIndexStep() const |
public IlcInt | getIndexValue() const |
public IlcInt | getMaxMax() const |
public IlcInt | getMaxMax(IlcInt indexMin, IlcInt indexMax) const |
public IlcInt | getMaxMin() const |
public IlcInt | getMaxMin(IlcInt indexMin, IlcInt indexMax) const |
public IlcInt | getMinMax() const |
public IlcInt | getMinMax(IlcInt indexMin, IlcInt indexMax) const |
public IlcInt | getMinMin() const |
public IlcInt | getMinMin(IlcInt indexMin, IlcInt indexMax) const |
public const char * | getName() const |
public IlcInt | getRangeIndexMax() const |
public IlcInt | getRangeIndexMin() const |
public IlcInt | getSize() const |
public IloSolver | getSolver() const |
public IloSolverI * | getSolverI() const |
public IlcInt | getValueIndexMax() const |
public IlcInt | getValueIndexMin() const |
public IlcIntVar | getVariable(IlcInt index, IlcBool before=IlcFalse) const |
public void | operator=(const IlcIntVarArray & h) |
public IlcIntExp | operator[](const IlcIntExp exp) const |
public IlcIntExp | operator[](IlcIndex & I) const |
public IlcIntVar & | operator[](IlcInt index) const |
public void | setName(const char * name) const |
public void | whenDomain(const IlcDemon demon) |
public void | whenDomainInterval(const IlcDemon demon) |
public void | whenRange(const IlcDemon demon) |
public void | whenRangeInterval(const IlcDemon demon) |
public void | whenValue(const IlcDemon demon) |
public void | whenValueInterval(const IlcDemon demon) |
Constructor Detail |
---|
This constructor creates an uninitialized array of length
size
. The argument size
must be strictly
greater than 0 (zero). The index range of the array is
[0 size)
. Each element of the array must be assigned
before the array can be used.
This constructor creates an array of length size
. Its
constrained integer variables are initialized with the list of variables
provided as arguments to the constructor. The number of
IlcIntVar
arguments must be equal to size
. The
argument size
must be strictly greater than 0 (zero).
This constructor creates an array of size
constrained
integer variables. The argument size
must be strictly
greater than 0 (zero). Each constrained integer variable has a domain
containing all integer values between min
and
max
.
This constructor creates an array of copies of the given constrained
integer variable prototype
. Each copy initially has the same
domain as prototype
currently has, but the copies do not
share the constraints of prototype
. That is, they are
independent of it.
The index range of the array is [indexMin indexMax)
.
The step of the array is indexStep
. Solver will throw an
exception (an instance of IloSolver::SolverErrorException
)
if any of the following conditions occur:
indexMin
is not strictly less than
indexMax
;
indexStep
is not strictly positive;
(indexMax-indexMin)
is not a multiple of
indexStep
.This constructor keeps no pointer to the prototype
variable. That variable may be an automatic object allocated on the
C++ stack.
Method Detail |
---|
This member function returns a copy of the invoking array of
constrained variables and associates that copy with solver
.
When it is called during the execution of a goal associated with an
array by the member function whenDomainInterval
, this
member function returns the maximum of the range of the array
[indexMin indexMax)
over which some removal of values has
occurred. The returned value of this member function is not meaningful
outside the execution of a goal associated with the array by the member
function whenDomainInterval
.
When it is called during the execution of a goal associated with an
array by the member function whenDomainInterval
, this
member function returns the minimum of the range of the array
[indexMin indexMax)
over which some removal of values has
occurred. The returned value of this member function is not meaningful
outside the execution of a goal associated with the array by the member
function whenDomainInterval
.
This member function returns the maximal index of the invoking array of constrained integer variables.
This member function returns the minimal index of the invoking array of constrained integer variables.
This member function returns the index step of the invoking array of
constrained integer variables. The meaning of this index step is that
the indexed variable value may change only at indices equal to
(getIndexMin() + i * getIndexStep())
.
When it is called during the execution of a constraint or demon
associated with an array by the member functions
whenValue, whenDomain,
or whenRange
, this
member function returns the index in the invoking array of the
constrained variable that triggered the propagation event. Calling this
member function outside the execution of the goal will throw an exception
(an instance of IloSolver::SolverErrorException
) with the
message “unbound index
”.
This member function returns the largest of the maximal values of the variables belonging to the invoking array of constrained integer variables.
This member function returns the largest of the maximal values of the
variables belonging to the invoking array of constrained integer variables.
The arguments indexMin
and indexMax
are provided, only those variables that correspond to indices in the
range [indexMin indexMax)
are considered. Solver will throw
an exception (an instance of IloSolver::SolverErrorException
with the message "bad index interval"
if the given
indexMin
and indexMax
are not valid indices
for the invoking array of constrained variables or if indexMin
is not strictly less than indexMax
.
This member function returns the largest of the minimal values of the variables belonging to the invoking array of constrained integer variables.
This member function returns the largest of the minimal values of
the variables belonging to the invoking array of constrained integer
variables. The arguments indexMin
and indexMax
are provided, only those variables that correspond to indices in the
range [indexMin indexMax)
are considered. Solver will throw
an exception (an instance of IloSolver::SolverErrorException
with the message "bad index interval"
if the given
indexMin
and indexMax
are not valid indices
for the invoking array of constrained variables or if indexMin
is not strictly less than indexMax
.
This member function returns the smallest of the maximal values of the variables belonging to the invoking array of constrained integer variables.
This member function returns the smallest of the maximal values
of the variables belonging to the invoking array of constrained integer
variables. The arguments indexMin
and indexMax
are provided, only those variables that correspond to indices in the
range [indexMin indexMax)
are considered. Solver will throw
an exception (an instance of IloSolver::SolverErrorException
with the message "bad index interval"
if the given
indexMin
and indexMax
are not valid indices
for the invoking array of constrained variables or if
indexMin
is not strictly less than indexMax
.
This member function returns the smallest of the minimal values of the variables belonging to the invoking array of constrained integer variables.
This member function returns the smallest of the minimal values
of the variables belonging to the invoking array of constrained integer
variables. The arguments indexMin
and indexMax
are provided, only those variables that correspond to indices in the
range [indexMin indexMax)
are considered. Solver will
throw an exception (an instance of
IloSolver::SolverErrorException
with the message
"bad index interval"
if the given
indexMin
and indexMax
are not valid indices for the invoking array of constrained variables
or if indexMin
is not
strictly less than indexMax
.
When it is called during the execution of a goal associated with an
array by the member function whenRangeInterval
, this member
function returns the maximum of the range of the array
[indexMin indexMax)
over which some removal of values has
occurred. The returned value of this member function is not meaningful
outside the execution of a goal associated with the array by the member
function whenRangeInterval
.
When it is called during the execution of a goal associated with an
array by the member function whenRangeInterval
, this member
function returns the minimum of the range of the array
[indexMin indexMax)
over which some removal of values has
occurred. The returned value of this member function is not meaningful
outside the execution of a goal associated with the array by the member
function whenRangeInterval
.
This member function returns the number of variables in the invoking array.
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.
When it is called during the execution of a goal associated with an
array by the member function whenValueInterval
, this member
function returns the maximum of the range of the array
[indexMin indexMax)
over which some binding has occurred.
The returned value of this member function is not meaningful outside the
execution of a goal associated with the array by the member function
whenValueInterval
.
When it is called during the execution of a goal associated with an
array by the member function whenValueInterval
, this member
function returns the minimum of the range of the array
[indexMin indexMax)
over which some binding has occurred.
The returned value of this member function is not meaningful outside the
execution of a goal associated with the array by the member function
whenValueInterval
.
This member function returns the variable corresponding to the given
index
in the invoking array of constrained integer variables.
However, if before
is IlcTrue
, then
getVariable
returns the variable before the variable at the
given index
. Solver will throw an exception (an instance of
IloSolver::SolverErrorException
) with the message
"bad index
" if the given index
is not a valid
one for the invoking array of constrained integer variables.
If t
is an array of constrained integer variables, then
these three expressions return the same value:
t.getVariable(index, IlcFalse) t.getVariable(index + 1, IlcTrue) t[index]
This subscripting operator returns a constrained integer expression. For
clarity, let's call A
the invoking array. When
exp
is bound to the value i
, then the domain of
the expression is the domain of A[i]
. More generally, the
domain of the expression is the union of the domains of the expressions
A[i]
where the i
are in the domain of
exp
.
This operator returns a generic variable, which is a constrained
variable representing an element of the array. That generic
variable is said to stem from the index i
.
This subscripting operator returns a reference to a constrained
integer variable corresponding to the given index
in the
invoking array of constrained integer variables. Solver will throw an
exception (an instance of IloSolver::SolverErrorException
)
with the message "bad index
" if the given index
is not a valid one for the invoking array of constrained integer
variables.
This member function associates demon
with the domain
propagation event of every variable in the invoking array. Whenever a
value is removed from the domain of any of the variables in the
invoking array, the demon will be executed immediately.
When the demon is executed, the index of the constrained variable
that triggered the domain event can be known by a call to the member
function getIndexValue
.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever a value is removed from the domain of any of the variables in the invoking array, the constraint will be propagated.
This member function associates demon
with the domain
propagation event of every variable in the invoking array. It specifies
that a given demon reacts globally to modifications of the domains of a
collection of variables in the array. Whenever a domain propagation event
or a series of such events occurs, 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 a domain propagation event or a series of such events occurs, the constraint will be propagated.
A call to the demon signifies that some removal of values
from domain(s) occurred over the index range
[indexMin indexMax)
. It does not mean that values
have been removed from the domains of all the variables in the range.
This member function associates demon
with the range
propagation event of every variable in the invoking array. Whenever any
bound of any of the variables in the array is modified, the demon will
be executed immediately.
When the demon is executed, the index of the constrained integer
variable that has triggered the range event can be known by a call
to the member function getIndexValue
.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. Whenever any bound of any of the variables in the array is modified, the constraint will be propagated.
This member function associates demon
with the range
propagation event of every variable in the invoking array. It specifies
that a given demon reacts globally to modifications of the boundaries
of a collection of variables in the array. Whenever a range propagation
event or a series of such events occurs, 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 a range propagation event or a series of such events occurs, the constraint will be propagated.
A call to the demon signifies that some modification of
the boundaries occurred to variables over the index range
[indexMin indexMax)
. It does not mean that all
the variables in the range had their boundaries modified.
This member function associates demon
with the value
propagation event of every variable in the invoking array. When one of
the variables in the array receives a value, the demon will be executed
immediately.
When the demon is executed, the index of the bound constrained variable
can be known by a call to the member function
getIndexValue
.
Since a constraint is also a demon, a constraint can also be passed as an argument to this member function. When one of the variables in the array receives a value, the constraint will be propagated.
This member function associates demon
with the value
propagation event of every variable in the invoking array. It specifies
that a given demon reacts globally to the binding of a collection of
variables in the array. When a value propagation event or a series of
such events occurs, 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. When a value propagation event or a series of such events occurs, the constraint will be propagated.
A call to the demon signifies that some variable binding
occurred over the index range [indexMin indexMax)
. It does
not mean that all the variables in the range have been bound.