# Constraint sum

The constraint *sum* is one of the most important constraint. When the optional element coeffs is missing, it is assumed that all coefficients are equal to 1. The constraint is subject to a numerical condition

#### Syntax

```
<sum>
<list> (intVar wspace)2+ </list>
[ <coeffs> (intVal wspace)2+ | (intVar wspace)2+ </coeffs> ]
<condition> "(" operator "," operand ")" </condition>
</sum>
```

The following constraint states that the values taken by variables x1 ,x2, x3 and y must respect the linear function

#### Example

```
<sum>
<list> x1 x2 x3 </list>
<coeffs> 1 2 3 </coeffs>
<condition> (gt,y) </condition>
</sum>
```

A form of *sum*, sometimes called *subset-sum* or *knapsack*, see [T03] and [PQ08], involves the operator ``in’’, and ensures that the obtained sum belongs (or not) to a specified interval. The following constraint states that the values taken by variables y1,y2,y3,y4 must respect 2 $\leq$ y1 * 4 + y2 * 2 + y3 * 3 + y4 * 1 $\leq$ 5.

#### Example

```
<sum>
<list> y1 y2 y3 y4 </list>
<coeffs> 4 2 3 1 </coeffs>
<condition> (in,2..5) </condition>
</sum>
```