The constraint solving method needs access to information about the current domains of variables. This is provided by the following predicates, which are all constant time operations.
fd_var(
?X)
fd_min(
?X,
?Min)
inf
denoting minus infinity.
fd_max(
?X,
?Max)
sup
denoting infinity.
fd_size(
?X,
?Size)
sup
otherwise.
fd_set(
?X,
?Set)
fd_dom(
?X,
?Range)
fd_degree(
?X,
?Degree)
Please note: this number may include some constraints that have been detected as entailed. Also, Degree is not the number of neighbors of X in the constraint network.
The following predicates can be used for computing the set of variables that are (transitively) connected via constraints to some given variable(s).
fd_neighbors(
+Var,
-Neighbors)
fd_closure(
+Vars,
-Closure)
fd_closure/2
is the transitive closure of fd_neighbors/2
.
The following predicate can be used for computing a symbolic form of the constraints that are transitively attached to some term. This is useful e.g. in the context of asserting or copying terms, as these operations are not supported on terms containing domain variables:
fd_copy_term(
+Term,
-Template,
-Body)
For example:
| ?- X in 0..1, Y in 10..11, X+5 #=< Y, fd_copy_term(f(X,Y), Template, Body). Body = _A in_set[[0|1]],_B in_set[[10|11]],clpfd:'t>=u+c'(_B,_A,5), Template = f(_A,_B), X in 0..1, Y in 10..11