4

I have a binary variable $y_{t}$ that is equal to $1$ iff the job is scheduled at slot $t$. I need to write constraints that guarantee that if the job is scheduled somewhere, then it must be scheduled for a period of $A$ consecutive slots. I tried to write it this way:

$\sum_{t'=t}^{t+A-1}y_{t'}\geqslant A y_t$ for all $t$.

Here I can see that if $y_t=1$ then I must have $y_{t+1}=\ldots=y_{t+A-1}=1$. The problem with this is that I will have $y_{t'}=1$ for all $t'\geqslant t$ because of the recurrence relation I have in my constraints.

After some effort, I found this way to do it: introduce binary variable $z_t$and add the constraints

$\sum_{t}z_t\leqslant 1$and $z_t\sum_{t'=t}^{t+A-1}y_{t'}\geqslant A y_t z_t$ for all $t$.

But, if I am correct, this is a non-linear constraint.

zdm87
  • 99
  • Is the formulation not under your control? Why can't you make $y_t$ mean that the job is scheduled for the $A$ slots starting at slot $t$? – saulspatz Jan 12 '18 at 03:02
  • Thanks for your comment. I thought about this but I prefer to keep $y_t$ as defined. – zdm87 Jan 12 '18 at 03:06

2 Answers2

4

What about introducing a set of binary variables $s_i$ to indicate the start times? Then, for all $T$, require $$ y_T+y_{T+1}+\cdots+y_{T+A-1} \ge A s_T $$ together with $$ y_T \ge s_T. $$ Does that work for you?

  • 2
    Why do you add only three terms $y_T+y_{T+1}+y_{T+A-1}$? – zdm87 Jan 12 '18 at 03:20
  • 1
    That was a typo, and is now fixed. – Matthew Conroy Jan 12 '18 at 03:21
  • I think that we have to add $\sum_{t}s_t\leqslant 1$, otherwise, we can find a period of more than $A$ consecutive slots which is feasible. – zdm87 Jan 12 '18 at 15:32
  • Also, $y_t=1$ for some $t$ is always feasible. I mean, say for $t=1$, I have $y_1=1$ and $s_1=0$. I could set $y_2=y_3=\ldots=0$ and $s_1=s_2=\ldots=0$. Maybe we have to add a constraint that guarantee that if $y_t=1$ then there must exists some slot $t'\leq t$ such that $s_{t'}=1$. – zdm87 Jan 12 '18 at 17:10
  • @zbir Yes, there may be other constraints needed based on your particular problem, which you have not fully specified. – Matthew Conroy Jan 12 '18 at 19:50
3

I would recommend using binary variables for start times and continuous variables in $[0,1]$ to indicate whether the job is in process at each time. However, if you really have to use binary variables for the in-process indicators, and if $A$ is not too large, I think the following constraint at each $t$ might do the job: $$y_{t}\ge y_{t-1}-\frac{1}{A}\sum_{s=t-A}^{t-1}y_{s}.$$ Obviously, the starting index of the summation would have to be adjusted near the start of the time frame.

prubin
  • 4,923
  • I think something is missing with the constraint. For a frame of $4$ slots and $A=3$, we can have $y_1=1$ and $y_t=0$ for all $t\in{2,3,4}$. We have only one constraint: $y_4\geq y_3-1/3(y_1+y_2+y_3)$ which is equivalent to $0\geq 0-1/3(1+0+0)$. – zdm87 Jan 12 '18 at 15:58
  • No, the constraint applies for all $t>1$. For $t=2$ and $t=3$, the summation divided by $A=3$ must be less than 1, so the constraint effectively becomes $y_t\ge y_{t-2}$. For instance, with $y_1=1$, the first constraint is $y_2\ge y_1 - \frac{1}{3} y_1 = 1 - \frac{1}{3}$, forcing $y_2=1$. The second constraint is $y_3\ge y_2 - \frac{1}{3}(y_1 + y_2) = 1 - \frac{2}{3}$, forcing $y_3=1$. – prubin Jan 12 '18 at 19:33
  • Ok. So I don't really get your last sentence. Because I applied it for all $t>A$ since the starting index of the summation is $t-A$. Now, if I understand correctly, the starting index of the summation must be $s=\max(1, t-A)$, right? – zdm87 Jan 12 '18 at 20:06
  • That is correct. – prubin Jan 13 '18 at 19:47