I have two tasks $i$ and $k$ with durations $d_i$ and $d_k$, where $d_i$ and $d_k$ are nonnegative variables.
I would like to model that $i$ may precede $k$ or $k$ may precede $i$ and that they may not overlap.
So, with $t_i$ and $t_k$ denoting the start times of $i$ and $k$, I have to model:
either $t_i + d_i \le t_k$ OR $t_k + d_k \le t_i$
Introducing a binary variable $y$, I can achieve the result with the following two big M constraints:
$t_i + d_i - t_k \le M y $
$t_k + d_k - t_i \le M (1-y)$
If it is required that $t_i + d_i \le H $ and $t_k + d_k \le H $ then I can set $M$ to be $M=H$.
My question is, is what I have done so far correct (what worries me is the variable duration) and can anyone think about a better formulation?
