- 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), 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 + and -. Let E, E1, E2 be an expression, and L be a list of expressions [E1,E2,...,En]. The following are valid expressions as well.
- if(Cond,ThenE,ElseE) 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): 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 Xs be a list of expressions [E1,...,En]. The constraint is equivalent to C1*E1+...+Cn*En R E.
Neng-Fa Zhou
2012-01-03