Next: , Previous: , Up: Defining Global Constraints   [Contents][Index]


10.9.9.2 Reflection Predicates

The constraint solving method needs access to information about the current domains of variables. This is provided by the following predicates, all of which which are constant time operations, except fd_degree/2.

fd_var(?X)

Checks that X is currently an unbound variable that is known to the CLPFD solver.

fd_min(?X, ?Min)

where X is a domain variable. Min is unified with the smallest value in the current domain of X, i.e. an integer or the atom inf denoting minus infinity.

fd_max(?X, ?Max)

where X is a domain variable. Max is unified with the upper bound of the current domain of X, i.e. an integer or the atom sup denoting plus infinity.

fd_size(?X, ?Size)

where X is a domain variable. Size is unified with the size of the current domain of X, if the domain is bounded, or the atom sup otherwise.

fd_set(?X, ?Set)

where X is a domain variable. Set is unified with an FD set denoting the internal representation of the current domain of X; see below.

fd_dom(?X, ?Range)

where X is a domain variable. Range is unified with a ConstantRange (see Syntax of Indexicals) denoting the current domain of X.

fd_degree(?X, ?Degree)

where X is a domain variable. Degree is unified with the number of constraints that are attached to X.

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.

fd_failures(?X, ?Failures)   since release 4.7.0

where X is a domain variable. Failures is unified with the number of times that X has been involved in a failure, as far as the solver can detect it. This number affects the variable selection methods impact and dom_w_deg. Please note: the number is not reset on backtracking, and so it is a counter for the whole search.

fd_set_failures(?X, +Failures)   since release 4.7.0

where X is a domain variable. The failure count of X is set to Failures, which should be a small integer. This can be useful for repeated searches or similar circumstances.

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)

Given a domain variable Var, Neighbors is the set of other variables, domain or otherwise, that occur with Var in some constraint.

fd_closure(+Vars, -Closure)

Given a list Vars of domain variables, Closure is the set of variables (including Vars) that can be transitively reached via constraints. Thus, fd_closure/2 is the transitive closure of fd_neighbors/2.



Send feedback on this subject.