The library ic_kernel provides a number of facilities useful for implementing IC constraints or otherwise extending the facilities provided by the standard IC library.
While the ic_kernel library exposes the structure of the IC attribute to the programmer (see below), accessing it directly is strongly discouraged (if for no other reason, the internals of IC may continue to evolve). For accessing information about a variable and its domain, use the predicates described earlier in section 3.2.7 “Variable query predicates”. For modifying a variable, it is particularly important to go through the access predicates, in order to make sure that the internal state remains consistent, that appropriate constraints are scheduled for execution as a result of the change, etc. The predicates available for modifying a variable are discussed in the next section.
When using IC variables in normal code, one would typically use the
$\=
, $=<
and $>=
family of constraints to (resp.)
remove a value, reduce the upper bound or increase the lower bound of a
variable.
While these constraints are good for normal CSP solving, they have a number of properties which may be less desirable when writing new constraints. In particular, they may leave unwanted delayed goals behind and may perform extra propagation before returning (it may be desirable to perform all required bound updates before allowing further propagation to occur).
To give the constraint writer more control over such matters, special predicates exist in the ic_kernel module which allow direct modification of the domain without the waking of goals (they are scheduled for execution but not actually executed). These predicates generally accept an IC variable, a non-IC variable (which will be constrained to make it a real IC variable) or a number.
Full details on these predicates can be found in the reference manual; they are listed here for completeness. Note that with the exception of impose_bounds/3 none of the goals call wake/0, so the programmer is free to do so at a convenient time.
The IC attribute is a meta-term which is attached to all variables which take part in IC constraints. ic_kernel defines the IC attribute as a structure of the following form:
ic{var_type:Type, lo:Lo, hi:Hi, bitmap:Bitmap, min:SuspMin, max:SuspMax, hole:SuspHole, type:SuspType }
This structure holds:
undefined
.
The suspension list names can be used in suspend/3 and related predicates to denote an appropriate waking condition.
The attribute of a domain variable can be accessed with the predicate get_ic_attr/2.
As noted above, direct access and manipulation of the attribute is discouraged; use the access predicates instead.