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

# <ConsistencyModule:> scalar_product(++Coeffs,+Collection,+Rel,?Sum)

Constrains the scalar product of the elements of Coeffs and Collection to satisfy the relation sum(Coeffs*Collection) Rel P.

Coeffs
  Collection of N integers.
Collection
  Collection of N integers or (domain) variables.
RelOp
  One of the atom: #>, #>=, #<, #=<, #=, #\=
P
  (Domain) variable or integer (array notation accepted)

## Description

Constrains the scalar product of the elements in Collection to satisfy the relation sum(Coeffs*Collection) Rel P.

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

The Scalar Product of the collection of N integers in Coeffs and the collection of N domain variables or integers in Collection is the sum of all Ci*Vi, where Ci is a element in Coeffs and Vi the corresponding element in Collection.

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

You may find it more convenient to embed `scalar_product` in a constraint expression.

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_bc for bounds consistency, and gfd_gac for domain (generalised arc) consistency.

Domain consistency is different from bounds consistency only if Rel is #=.

This constraint is known as scalar_product in the global constraint catalog, and is implemented using Gecode's linear() constraint.