Given the following two expressions:
- $ x - \frac{1}{T}\sum_{i} y_{i}$
- $ x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i}$
where $x \in \mathbb{Z}_{+}$, $y \in \mathbb{R}_{+}$, and $T$, $Q$ and $\beta_{i}$ are given constants.
I need to find the following:
a) The min between these two expressions $F = \min (x - \frac{1}{T}\sum_{i} y_{i}, x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i})$
b) if $F > 0 $ I want to enforce on variable $w \in \mathbb{Z}_{+}$ the floor of the min, $i.e.$ $w \leq \lfloor{F}\rfloor$
c) if $F < 0 $ I want to enforce on another variable $v \in \mathbb{Z}_{+}$ the ceil of the absolute value of $F$ (since the minimum could be negative) $i.e. v \geq \lceil {|F|}\rceil$.
What I have done so far is the following:
- To find the min function, I did the same as in here How to linearize min function as a constraint?. I define two aux variables equals each expression.
$r^{1} = x - \frac{1}{T}\sum_{i} y_{i}$
$r^{2} = x - \frac{1}{Q}\sum_{i} \beta_{i} y_{i}$
a binary variable $z$ and the following constraints are introduced to find the min:
$r^{2} - r^{1} \leq Mz$
$r^{1} - r^{2} \leq M(1-z)$
$F \leq r^{2}$
$F \leq r^{1}$
$F \geq r^{1} - M(1 - z)$
$F \geq r^{2} - M(z)$
- To find the absolute value $abs = |F|$. As proposed by here https://groups.google.com/g/gurobi/c/YUWqUfk3PSc I introduce two continuous variables $p$ and $n$ and a binary variable $\delta$ used as an indicator and the following constraints:
$F = p -n $
$p \leq M \delta$
$n \leq M (1 - \delta)$
$abs = p + n $
Now my question is I have difficulties to formulate the third constraints. I introduced a binary variable $\delta^{'}$ that equals 1 when $F > 0 $ and 0 otherwise. Then this can be formulate as following:
$F \leq M\delta^{'}$
$F \geq M(1 - \delta^{'})$
Now I want to say:
if $\delta^{'} = 1$ then $w \leq \lfloor{F}\rfloor$ ($v$ is already enforced to be 0 so we don't have to worry about it in this case)
if $\delta^{'} = 0$ then $v \geq \lceil{abs}\rceil$ (similarly $w$ is already enforced to be 0)