
This module provides Finite Domain (FD) constraints and enumerating predicates for FD variables. See clpfd_doc for more details about the Ciao FD solver.
This module provides two kinds of contraints: basic constraints (such as domain/3, all_different/1, ...) that deal with FD variables or lists of FD variables, and meta-contraints (such as #=/2, #=</2, ...) that deal with arithmetic expressions over FD variables, called in the following FD expressions. Meta-constraints of this module behave as described in package clpfd, except that their arguments are interpreted at run time.
Usage:in(Var,Range)
Constrains Var to take its value in the domain described by Range.
Usage:fdvar(X)
X is a variable or an integer.
fd_range_expr(I) :-
integer(I).
fd_range_expr(..(Min,Max)) :-
integer(Min),
integer(Max).
fd_range_expr(A\/B) :-
fd_range_expr(A),
fd_range_expr(B).
an integer stands for a singleton range, Min..Max for the closed interval from Min to Max, and A\/B for the union of ranges A and B. Range expressions are used by the in/2 predciate.Usage:fd_range_expr(Expr)
Expr is a range expression.
fd_expr(Var) :-
var(Var).
fd_expr(I*Exp) :-
int(I),
fd_expr(Exp).
fd_expr(Exp*I) :-
int(I),
fd_expr(Exp).
fd_expr(Exp1+Exp2) :-
fd_expr(Exp1),
fd_expr(Exp2).
fd_expr(Exp1-Exp2) :-
fd_expr(Exp1),
fd_expr(Exp2).
fd_expr(-Exp) :-
fd_expr(Exp).
FD expressions are used by meta-constraints.Usage:fd_expr(Expr)
Expr is an FD expression.
Usage:#=(A,B)
Constrains the interpretation of A to be equal to the interpretation of B.
Usage:#\=(A,B)
Constrains the interpretation of A to be different from the interpretation of B
Usage:#<(A,B)
Constrains the interpretation of A to be smaller than the interpretation of B.
Usage:#=<(A,B)
Constrains A to be smaller or equal to B.
Usage:#>(A,B)
Constrains the interpretation of A to be greater than the interpretation of B.
Usage:#>=(A,B)
Constrains the interpretation of A to be greater or equal than the interpretation of B.
Usage:domain(Vars,Min,Max)
Constrains each element of Vars to take its value between Min and Max (included). This predicate is generally used to set the initial domain of an interval
Usage:in(Var,Range)
Constrains Var to take its value in the domain described by Range.
Usage:all_different(Vars)
Constrains all elements in Vars to take distinct values. This is equivalent to posting an inequality constraint for each pair of variables. This constraint is triggered when a variable becomes ground, removing its value from the domain of the other variables.
Usage:labeling(Options,Vars)
Assigns a value to each variable in Vars according to the labeling options given by Options. This predicate is re-executable on backtracking.
The different options are :
Usage:labeling(Options,Vars)
Assigns a value to each variable in Vars according to the labeling options given by Options. This predicate is re-executable on backtracking.
The different options are :