
1.4. FD Constraints 13
• Type declaration:
sum :: [int] → (int → int → bool) → int → bool
• Definition: sum L Op V is true if the sum of all elements in L is related with
V via the relational operator Op. i.e., if Σ
e∈L
Op V .
• Example at the TOY(FD) command level:
Next goal returns true and constrains X, Y and Z to be 1.
TOY(FD)> L == [X,Y,Z], domain L 1 3, sum L (#<) 4
yes
L == [ 1, 1, 1 ]
Z == 1
Y == 1
X == 1
Elapsed time: 0 ms.
scalar product/4
• Type declaration:
scalar product :: [int] → [int] → (int → int → bool) → int → bool
• Definition: ’scalar product L1 L2 Op V’ is true if the scalar product (in the
sense of FD constraint solving) of the integers or FD variables in L1 and L2 is
related with the value V via the operator Op, i.e., if ’(L1 ∗
s
L2) Op V’ is satisfied
is satisfied with ∗
s
defined as the usual scalar product of integer vectors.
• Example at the TOY(FD) command level:
TOY(FD)> domain [X,Y,Z] 1 10, scalar_product [1,2,3] [X,Y,Z] (#<) 10
yes
Z in 1..2
Y in 1..2
X in 1..4
Elapsed time: 0 ms.
As expected, the expressions constructed from both arithmetic and relational con-
straints may be non-linear.
1.4.5 Combinatorial Constraints
Combinatorial Constraints include well-known global constraints that are useful to
solve problems defined on discrete domains. Often, these constraints are also called
symbolic constraints Beldiceanu, 2000.
assignment/2
Kommentare zu diesen Handbüchern