reifiabledefines an arithmetic constraint. The syntax for Expr and RelOp is defined by a grammar (see Syntax of Arithmetic Expressions). Note that the expressions are not restricted to being linear. Constraints over nonlinear expressions, however, will usually yield less constraint propagation than constraints over linear expressions.
Arithmetic constraints can be reified as e.g.:
| ?- X in 1..2, Y in 3..5, X#=<Y #<=> B. B = 1, X in 1..2, Y in 3..5
Linear arithmetic constraints, except equalities, maintain bounds-consistency. Their reified versions detect bounds-entailment and -disentailment.
The following constraints are among the library constraints that general arithmetic constraints compile to. They express a relation between a sum or a scalar product and a value, using a dedicated algorithm, which avoids creating any temporary variables holding intermediate values. If you are computing a sum or a scalar product, it can be much more efficient to compute lists of coefficients and variables and post a single sum or scalar product constraint than to post a sequence of elementary constraints.
sum(
+Xs,
+RelOp,
?Value)
sum(
Xs)
RelOp Value.
Corresponds roughly to sumlist/2
in library(lists)
.
scalar_product(
+Coeffs,
+Xs,
+RelOp,
?Value)
scalar_product(
+Coeffs,
+Xs,
+RelOp,
?Value,
+Options)
sum(
Coeffs*Xs)
RelOp Value.
Options is a list that may include the following options:
among(
Least,
Most,
Range)
since release 4.3.1consistency(
Cons)
domain
#=
, and requires that any domain variables have finite bounds.
bounds
value
The following constraints constrain a value to be the minimum (maximum) of a given list of values.
minimum(
?Value,
+Xs)
min_member/2
in
library(lists)
and to minimum/2
in MiniZinc.
maximum(
?Value,
+Xs)
max_member/2
in
library(lists)
and to maximum/2
in MiniZinc.