## 5.354. sliding_time_window_sum

Origin

Derived from .

Constraint

Arguments
 $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi °\pi \pi Ί\pi }$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi },\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi },\mathrm{\pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right)$
Restrictions
 $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}>0$ $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }\beta ₯0$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi \pi °\pi \pi Ί\pi },\left[\mathrm{\pi \pi \pi \pi \pi \pi },\mathrm{\pi \pi \pi },\mathrm{\pi \pi \pi \pi \pi \pi }\right]\right)$ $\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\beta €\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\beta ₯0$
Purpose

For any time window of size $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}$, the sum of the points of the tasks of the collection $\mathrm{\pi \pi °\pi \pi Ί\pi }$ that overlap that time window do not exceed a given limit $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$.

Example
$\left(\begin{array}{c}9,16,β©\begin{array}{ccc}\mathrm{\pi \pi \pi \pi \pi \pi }-10\hfill & \mathrm{\pi \pi \pi }-13\hfill & \mathrm{\pi \pi \pi \pi \pi \pi }-2,\hfill \\ \mathrm{\pi \pi \pi \pi \pi \pi }-5\hfill & \mathrm{\pi \pi \pi }-6\hfill & \mathrm{\pi \pi \pi \pi \pi \pi }-3,\hfill \\ \mathrm{\pi \pi \pi \pi \pi \pi }-6\hfill & \mathrm{\pi \pi \pi }-8\hfill & \mathrm{\pi \pi \pi \pi \pi \pi }-4,\hfill \\ \mathrm{\pi \pi \pi \pi \pi \pi }-14\hfill & \mathrm{\pi \pi \pi }-16\hfill & \mathrm{\pi \pi \pi \pi \pi \pi }-5,\hfill \\ \mathrm{\pi \pi \pi \pi \pi \pi }-2\hfill & \mathrm{\pi \pi \pi }-4\hfill & \mathrm{\pi \pi \pi \pi \pi \pi }-6\hfill \end{array}βͺ\hfill \end{array}\right)$

The lower part of FigureΒ 5.354.1 indicates the different tasks on the time axis. Each task is drawn as a rectangle with its corresponding identifier in the middle. Finally the upper part of FigureΒ 5.354.1 shows the different time windows and the respective contribution of the tasks in these time windows. A line with two arrows depicts each time window. The two arrows indicate the start and the end of the time window. At the right of each time window we give its occupation. Since this occupation is always less than or equal to the limit 16, the constraint holds.

Typical
 $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}>1$ $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }>0$ $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }<$$\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\right)$ $|\mathrm{\pi \pi °\pi \pi Ί\pi }|>1$ $\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }<\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }>0$
Symmetries
• $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}$ can be decreased.

• $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$ can be increased.

• Items of $\mathrm{\pi \pi °\pi \pi Ί\pi }$ are permutable.

• $\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }$ can be decreased to any value $\beta ₯0$.

• One and the same constant can be added to the $\mathrm{\pi \pi \pi \pi \pi \pi }$ and $\mathrm{\pi \pi \pi }$ attributes of all items of $\mathrm{\pi \pi °\pi \pi Ί\pi }$.

Arg. properties

Contractible wrt. $\mathrm{\pi \pi °\pi \pi Ί\pi }$.

Usage

This constraint may be used for timetabling problems in order to put an upper limit on the cumulated number of points in a shift.

Reformulation

The constraint can be expressed in term of a set of ${|\mathrm{\pi \pi °\pi \pi Ί\pi }|}^{2}$ reified constraints and of $|\mathrm{\pi \pi °\pi \pi Ί\pi }|$ linear inequalities constraints:

1. For each pair of tasks $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right],\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ $\left(i,j\beta \left[1,|\mathrm{\pi \pi °\pi \pi Ί\pi }|\right]\right)$ of the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection we create a variable ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{ij}$ which is set to $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi \pi \pi \pi }$ if $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ intersects the time window ${\mathrm{\pi ²}}_{i}$ of size $\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}$ that starts at instant $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi }$, or 0 otherwise:

• If $i=j$ (i.e.,Β $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right]$ and $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ coincide):

• ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{ij}=\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi }$.

• If and $\stackrel{Β―}{\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi }}<\underset{Μ²}{\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi }}$ (i.e.,Β $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ for sure ends before the time window ${\mathrm{\pi ²}}_{i}$):

• ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{ij}=0$.

• If and $\underset{Μ²}{\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi \pi \pi \pi }}>\stackrel{Β―}{\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi }}+\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}-1$ (i.e.,Β $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ for sure starts after the time window ${\mathrm{\pi ²}}_{i}$):

• ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{ij}=0$.

• Otherwise (i.e.,Β $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right]$ can potentially overlap the time window ${\mathrm{\pi ²}}_{i}$):

• ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{ij}=min\left(1,max\left(0,min\left(\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi }+\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄},\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi }\right)-max\left(\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right].\mathrm{\pi \pi \pi \pi \pi \pi },\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi \pi \pi \pi }\right)\right)\right)Β·\mathrm{\pi \pi °\pi \pi Ί\pi }\left[j\right].\mathrm{\pi \pi \pi \pi \pi \pi }$.

2. For each task $\mathrm{\pi \pi °\pi \pi Ί\pi }\left[i\right]$ $\left(i\beta \left[1,|\mathrm{\pi \pi °\pi \pi Ί\pi }|\right]\right)$ we create a linear inequality constraint ${\mathrm{\pi \pi \pi \pi \pi ‘}}_{i1}+{\mathrm{\pi \pi \pi \pi \pi ‘}}_{i2}+\beta ―+{\mathrm{\pi \pi \pi \pi \pi ‘}}_{i|\mathrm{\pi \pi °\pi \pi Ί\pi }|}\beta €\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$.

related: Β (sum of the points of intersecting tasks with sliding time window replaced by sum of intersections of tasks with sliding time window).

Keywords
Arc input(s)

$\mathrm{\pi \pi °\pi \pi Ί\pi }$

Arc generator
$\mathrm{\pi \pi Έ\pi Ώ\pi Ή}$$\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi }\right)$

Arc arity
Arc constraint(s)
$\mathrm{\pi \pi \pi \pi \pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\beta €\mathrm{\pi \pi \pi \pi \pi }.\mathrm{\pi \pi \pi }$
Graph property(ies)
$\mathrm{\pi \pi \pi \pi }$$=|\mathrm{\pi \pi °\pi \pi Ί\pi }|$

Arc input(s)

$\mathrm{\pi \pi °\pi \pi Ί\pi }$

Arc generator
$\mathrm{\pi Ά\pi Ώ\pi Ό\pi \pi \pi Έ}$$\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi }\mathtt{1},\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}\right)$

Arc arity
Arc constraint(s)
 $\beta ’\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi }\beta €\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}.\mathrm{\pi \pi \pi }$ $\beta ’\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}.\mathrm{\pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi }<\mathrm{\pi \pi Έ\pi ½\pi ³\pi Ύ\pi }_\mathrm{\pi \pi Έ\pi \pi ΄}-1$
Sets
$\begin{array}{c}\mathrm{\pi ²\pi ΄\pi ’\pi ’}\beta ¦\hfill \\ \left[\begin{array}{c}\mathrm{\pi \pi \pi \pi \pi \pi },\hfill \\ \mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi }\left(\begin{array}{c}\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),\hfill \\ \mathrm{\pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\right)\right]\hfill \end{array}\right)\hfill \end{array}\right]\hfill \end{array}$

Constraint(s) on sets
$\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi },\beta €,\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }\right)$
Graph model

We generate an arc from a task ${t}_{1}$ to a task ${t}_{2}$ if task ${t}_{2}$ does not end before the end of task ${t}_{1}$ and if task ${t}_{2}$ intersects the time window that starts at the last instant of task ${t}_{1}$. Each set generated by $\mathrm{\pi ²\pi ΄\pi ’\pi ’}$ corresponds to all tasks that intersect in time the time window that starts at instant $\mathrm{\pi \pi \pi }-1$, where $\mathrm{\pi \pi \pi }$ is the end of a given task.

PartsΒ (A) andΒ (B) of FigureΒ 5.354.2 respectively show the initial and final graph associated with the Example slot. In the final graph, the successors of a given task $t$ correspond to the set of tasks that both do not end before the $\mathrm{\pi \pi \pi }$ of task $t$, and intersect the time window that starts at the $\mathrm{\pi \pi \pi }-1$ of task $t$.

Signature

Consider the first graph constraint. Since we use the $\mathrm{\pi \pi Έ\pi Ώ\pi Ή}$ arc generator on the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection the maximum number of arcs of the final graph is equal to $|\mathrm{\pi \pi °\pi \pi Ί\pi }|$. Therefore we can rewrite $\mathrm{\pi \pi \pi \pi }=|\mathrm{\pi \pi °\pi \pi Ί\pi }|$ to $\mathrm{\pi \pi \pi \pi }\beta ₯|\mathrm{\pi \pi °\pi \pi Ί\pi }|$ and simplify $\underset{Μ²}{\stackrel{Β―}{\mathrm{\pi \pi \pi \pi }}}$ to $\stackrel{Β―}{\mathrm{\pi \pi \pi \pi }}$.