[ library(gfd) | Reference Manual | Alphabetic Index ]

# <ConsistencyModule:> sum(+Collection,+Rel,?Sum,?Bool)

Reflect into Bool the truth of the sum of the elements of Collection satisfying the relation sum(Collection) Rel Sum.

Collection
  Collection of integers or (domain) variables.
RelOp
  One of the atom: #>, #>=, #<, #=<, #=, #\=
Sum
  (Domain) variable or integer (array notation accepted)
Bool
  (Domain) variable or the integer 0 or 1 (array notation accepted)

## Description

This is the reified form of sum/3, which constrains the sum of the elements in Collection to satisfy the relation sum(Collection) Rel Sum.

Rel can be one of #>, #>=, #<, #=<, #=, #\= (or equivalently, >, >=, <, =<, =, \=).

Any input variables which are not already domain variable will be turn into domain variables with default bounds.

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_bc for bounds consistency

This constraint is implemented using Gecode's linear() constraint (reified version).

## See Also

sum / 3