
1.4. FD Constraints 17
all different/1
all different’/2
all distinct/1
all distinct’/2
• Type declaration:
all different :: [int] → bool
all different’ :: [int] → [options] → bool
all distinct :: [int] → bool
all distinct’ :: [int] → [options] → bool
• Definition:
• ‘all different L’ and ‘all distinct L’ are true if each variable in L is constrained to
have a value that is unique in the list L and there are no duplicate integers in the
list L, i.e., this is equivalent to say that for all X, Y ∈ L, X 6= Y . The difference
between both constraints is that all different/1 uses a complete algorithm that
maintains the domain consistency R´egin, 1994 whereas all distinct/1 uses an
incomplete one.
There are extended versions that allow one more argument which is a list of
options, where each option may have one of the following values
1. ‘on value’, ‘on domains’ or ‘on range’ to specify that the constraint has to be
woken up, respectively, when a variable becomes ground, when the domain
associated to a variable changes, or when a bound of the domain (in interval
form) associated to a variable changes.
2. ‘complete true’ or ‘complete false’ to specify if the propagation algorithm to
apply is complete or incomplete.
• Example at the TOY(FD) command level:
TOY(FD)> L== [X,1,Z], domain L 1 3,
all_different’ L [complete true, on range]
yes
L == [ X, 1, Z ]
Z in 2..3
X in 2..3
Elapsed time: 0 ms.
1.4.6 Enumeration Constraints
Enumeration constraints reactivate the search process when no more constraint prop-
agation is possible. TOY(FD) provides two enumeration constraints:
indomain/1
Kommentare zu diesen Handbüchern