- E1 R E2: This is the basic form of an arithmetic constraint, where E1 and E2 are two arithmetic expressions, and R is one of the following constraint symbols:
#=
, #\=
, #>=
, #>
, #=<
, and #<
. An arithmetic expression is made of integers, variables, domain variables, and the following arithmetic functions: + (addition), - (subtraction), * (multiplication), / (division), // (integer division), div (integer division), mod, ** (power), abs, min, max, and sum. The ** operator has the highest priority, followed by *, /, //, and mod, then followed by unary minus sign -, and finally followed by + and -. Let E, E1, E2 be expressions, and let L be a list of expressions [E1,E2,...,En]. The following are valid expressions, as well.
- if(Cond,ThenE,ElseE) - This is the same as Cond*ThenE+(1-Cond)*ElseE.
- min(L) - The minimum element of L, which can be given by a list comprehension.
- max(L) - The maximum element of L, which can be given by a list comprehension.
- min(E1,E2) - The minimum of E1 and E2.
- max(E1,E2) - The maximum of E1 and E2.
- sum(L) - The sum of the elements of L, which can be given by a list comprehension.
- sum(Xs,R E): This is equivalent to sum(X) R E, where Xs must be a list of expressions.
.
- scalar_product(Coeffs, Xs, R, E): Let Coeffs be a list of integers [C1,...,Cn], and let Xs be a list of expressions [E1,...,En]. This constraint is equivalent to C1*E1+...+Cn*En R E.
Neng-Fa Zhou
2013-01-25