Templates
Description
fd_all_different(List) constrains all variables in List 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.
Errors
List is a partial list | instantiation_error | |
List is neither a partial list nor a list | type_error(list, List) | |
an element E of the List list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | |
Portability
GNU Prolog predicate.
Templates
Description
fd_element(I, List, X) constraints X to be equal to the Ith integer (from 1) of List.
Errors
I is neither a variable nor an FD variable nor an integer | type_error(fd_variable, I) | |
X is neither a variable nor an FD variable nor an integer | type_error(fd_variable, X) | |
List is a partial list or a list with an element E which is a variable | instantiation_error | |
List is neither a partial list nor a list | type_error(list, List) | |
an element E of the List list is neither a variable nor an integer | type_error(integer, E) | |
Portability
GNU Prolog predicate.
Templates
Description
fd_element_var(I, List, X) constraints X to be equal to the Ith variable (from 1) of List. This constraint is similar to fd_element/3 (section 8.8.2) but List can also contain FD variables (rather than just integers).
Errors
I is neither a variable nor an FD variable nor an integer | type_error(fd_variable, I) | |
X is neither a variable nor an FD variable nor an integer | type_error(fd_variable, X) | |
List is a partial list | instantiation_error | |
List is neither a partial list nor a list | type_error(list, List) | |
an element E of the List list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | |
Portability
GNU Prolog predicate.
Templates
Description
fd_atmost(N, List, V) posts the constraint that at most N variables of List are equal to the value V.
fd_atleast(N, List, V) posts the constraint that at least N variables of List are equal to the value V.
fd_exactly(N, List, V) posts the constraint that at exactly N variables of List are equal to the value V.
These constraints are special cases of fd_cardinality/2 (section 8.7.3) but their implementation is more efficient.
Errors
N is a variable | instantiation_error | |
N is neither a variable nor an integer | type_error(integer, N) | |
V is a variable | instantiation_error | |
V is neither a variable nor an integer | type_error(integer, V) | |
List is a partial list | instantiation_error | |
List is neither a partial list nor a list | type_error(list, List) | |
an element E of the List list is neither a variable nor an FD variable nor an integer | type_error(fd_variable, E) | |
Portability
GNU Prolog predicates.
Templates
Description
fd_relation(Relation, Vars) constraints the tuple of variables Vars to be equal to one tuple of the list Relation. A tuple is represented by a list.
Example: definition of the boolean AND relation so that X AND Y ⇔ Z:
and(X,Y,Z):- fd_relation([[0,0,0],[0,1,0],[1,0,0],[1,1,1]], [X,Y,Z]).
fd_relationc(Columns, Vars) is similar to fd_relation/2 except that the relation is not given as the list of tuples but as the list of the columns of the relation. A column is represented by a list.
Example:
and(X,Y,Z):- fd_relationc([[0,0,1,1],[0,1,0,1],[0,0,0,1]], [X,Y,Z]).
Errors
Relation is a partial list or a list with a sub-term E which is a variable | instantiation_error | |
Relation is neither a partial list nor a list | type_error(list, Relation) | |
an element E of the Relation list is neither a variable nor an integer | type_error(integer, E) | |
Vars is a partial list | instantiation_error | |
Vars is neither a partial list nor a list | type_error(list, Vars) | |
an element E of the Vars list is neither a variable nor an integer nor an FD variable | type_error(fd_variable, E) | |
Portability
GNU Prolog predicates.