Overview | Group | Tree | Graph | Index | Concepts |
This function creates and returns a goal, a primitive in the algorithms that search
for solutions. The goal IlcInstantiate
assigns a value to a constrained variable.
It uses choice points so that if a failure occurs as a result of that reversible assignment,
another value will be assigned to the constrained variable so that the search can continue.
If var
has already been bound, then IlcInstantiate
does nothing and
succeeds. Otherwise, IlcInstantiate
sets a choice point, then assigns a value to the
constrained variable. In case of failure, the tried-and-failed value is removed from the domain of
the constrained variable, and another value not yet used is tried until a value assignment succeeds
or the domain is exhausted. In that latter case, the domain becomes empty, and failure occurs. The
values are selected by the select
object, if it is provided. Otherwise, values are
tried by default in ascending order.
Implementation
Here's how we could define that goal for IlcIntVar
, using the constraints
==
and !=
directly as goals themselves.
static ILCGOAL2(IlcIntInstantiate, IlcIntVar, var, IlcIntSelectI*, select) { if (var.isBound()) return 0; IlcInt val = (select)? select->select(var) : var.getMin(); return IlcOr(var == val, IlcAnd(var != val, this)); } IlcGoal IlcInstantiate(IlcIntVar var){ return IlcIntInstantiate(var, 0); } IlcGoal IlcInstantiate(IlcIntVar var, IlcIntSelect sel){ return IlcIntInstantiate(var, sel.getImpl()); }
For more information, see the concept Choice Point.
See Also:
IlcAnySelect, IlcBestInstantiate, IlcDichotomize, IlcGenerate, IlcGoal, IlcIntSelect
This function creates and returns a goal, a primitive in the algorithms that search for
solutions. The goal IlcInstantiate
assigns a value to a constrained variable.
It uses choice points so that if a failure occurs as a result of that reversible assignment,
another value will be assigned to the constrained variable so that the search can continue.
Its behavior varies slightly, depending on the class of its arguments.
If var
has already been bound, IlcInstantiate
does nothing and
succeeds. Otherwise, IlcInstantiate
sets a choice point, then adds an element of
the possible set to the required set of var
. The added element
is chosen by select
, if it is provided. If select
has not been provided,
the values are tried in ascending order when the values are integers. If failure occurs, the element
is removed from the possible set of var
, and another element is tried.
For more information, see the concept Choice Point.
See Also:
IlcAnySetSelect, IlcAnySetVar, IlcBestGenerate, IlcBestInstantiate, IlcGenerate, IlcIntSetSelect, IlcIntSetVar
This function creates and returns a goal, a primitive in the algorithms that search for solutions. Its behavior varies slightly, depending on the class of its arguments.
The algorithm that IlcInstantiate
uses for constrained integer variables and constrained
enumerated variables tries every value in the domain. Since the number of elements in the domain of a constrained
floating-point variable is very high (typically millions), that approach would not be very efficient.
Consequently, IlcInstantiate
handles the domain of a constrained floating-point variable
differently. The idea is to recursively split the domain of the constrained floating-point variable into two parts.
If var
is already bound, then IlcInstantiate
does nothing and succeeds. Otherwise,
IlcInstantiate
sets a choice point, then replaces the domain of var
by one
of its halves, and calls itself recursively. The function stops when the variable is bound or when it
is known with a precision smaller than prec
. If a failure occurs, then the domain is replaced by
the other half, and IlcInstantiate
is called recursively.
The optional argument increaseMin
should be a Boolean value, either IlcTrue
or
IlcFalse
. If increaseMinFirst
is IlcTrue
, then the upper half domain
is tried first; otherwise, the lower half is tried first.
This algorithm is available explicitly for constrained integer variables as the function
IlcDichotomize
.
For more information, see the concept Choice Point.
See Also:
IlcBestInstantiate, IlcDichotomize, IlcGenerate, IlcGoal