## 5.294. sliding_sum

Origin

CHIP

Constraint

$\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }\left(\mathrm{\pi »\pi Ύ\pi },\mathrm{\pi \pi Ώ},\mathrm{\pi \pi ΄\pi },\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$

Arguments
 $\mathrm{\pi »\pi Ύ\pi }$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi Ώ}$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi ΄\pi }$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right)$
Restrictions
 $\mathrm{\pi \pi Ώ}\beta ₯\mathrm{\pi »\pi Ύ\pi }$ $\mathrm{\pi \pi ΄\pi }>0$ $\mathrm{\pi \pi ΄\pi }\beta €|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi \pi \pi }\right)$
Purpose

Constrains all sequences of $\mathrm{\pi \pi ΄\pi }$ consecutive variables of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ so that the sum of the variables belongs to interval $\left[\mathrm{\pi »\pi Ύ\pi },\mathrm{\pi \pi Ώ}\right]$.

Example
$\left(\begin{array}{c}3,7,4,β©\begin{array}{c}\mathrm{\pi \pi \pi }-1,\hfill \\ \mathrm{\pi \pi \pi }-4,\hfill \\ \mathrm{\pi \pi \pi }-2,\hfill \\ \mathrm{\pi \pi \pi }-0,\hfill \\ \mathrm{\pi \pi \pi }-0,\hfill \\ \mathrm{\pi \pi \pi }-3,\hfill \\ \mathrm{\pi \pi \pi }-4\hfill \end{array}βͺ\hfill \end{array}\right)$

The example considers all sliding sequences of $\mathrm{\pi \pi ΄\pi }=4$ consecutive values of $\beta ©1,4,2,0,0,3,4\beta ͺ$ collection and constraints the sum to be in $\left[\mathrm{\pi »\pi Ύ\pi },\mathrm{\pi \pi Ώ}\right]=\left[3,7\right]$. The $\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }$ constraint holds since the sum associated with the corresponding subsequences $1420$, $4200$, $2003$, and $0034$ are respectively 7, 6, 5 and 7.

Symmetry

Items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ can be reversed.

Algorithm

Beldiceanu and CarlssonΒ [BeldiceanuCarlsson01] have proposed a first incomplete filtering algorithm for the $\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }$ constraint. In 2008, Maher et al. showed inΒ [MaherNarodytskaQuimperWalsh08] that the $\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi }$ constraint has a solution βif and only there are no negative cycles in the flow graph associated with the dual linear programβ that encodes the conjunction of inequalities. They derive a bound-consistency filtering algorithm from this fact.

Keywords
Arc input(s)

$\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$

Arc generator
$\mathrm{\pi \pi ΄\pi \pi »}$$\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$

Arc arity
$\mathrm{\pi \pi ΄\pi }$
Arc constraint(s)
 $\beta ’$$\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi },\beta ₯,\mathrm{\pi »\pi Ύ\pi }\right)$ $\beta ’$$\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi },\beta €,\mathrm{\pi \pi Ώ}\right)$
Graph property(ies)
$\mathrm{\pi \pi \pi \pi }$$=|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-\mathrm{\pi \pi ΄\pi }+1$

Graph model

We use $\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$ as an arc constraint. $\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$ takes a collection of domain variables as its first argument.

PartsΒ (A) andΒ (B) of FigureΒ 5.294.1 respectively show the initial and final graph associated with the Example slot. Since all arc constraints hold (i.e.,Β because of the graph property $\mathrm{\pi \pi \pi \pi }=|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-\mathrm{\pi \pi ΄\pi }+1$) the final graph corresponds to the initial graph.

Signature

Since we use the $\mathrm{\pi \pi ΄\pi \pi »}$ arc generator with an arity of $\mathrm{\pi \pi ΄\pi }$ on the items of the $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ collection, the expression $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-\mathrm{\pi \pi ΄\pi }+1$ corresponds to the maximum number of arcs of the final graph. Therefore we can rewrite the graph property $\mathrm{\pi \pi \pi \pi }=|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-\mathrm{\pi \pi ΄\pi }+1$ to $\mathrm{\pi \pi \pi \pi }\beta ₯|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|-\mathrm{\pi \pi ΄\pi }+1$ and simplify $\underset{Μ²}{\stackrel{Β―}{\mathrm{\pi \pi \pi \pi }}}$ to $\stackrel{Β―}{\mathrm{\pi \pi \pi \pi }}$.