It's almost this question: Formulating the conditional constraint
But there they have non-strict inequality. I have $x_i$ a boolean decision var and $Q_i$ as a nonnegative integer decision variable such that
- if $x_i = 0$, then $Q_i = 0$
- if $x_i = 1$, then $Q_i \gt 0$ (note the strict inequality!).
Lets say I dont have upper bound on $Q_i$; is there a mathematical relation between $x_i$ and $Q_i$ you can write directly or is the following way to go?
dvar boolean x[I];
dvar int+ Q[I];
subject to
{
forall(i in I) {
(x[i]==0) => (Q[i] == 0);
(x[i]==1) => (Q[i] > 0);
}
I can formulate the constraint other way but does it help I'm not sure:
- if $Q_i = 0$, then $x_i = 0$
- if $Q_i \gt 0$, then $x_i = 1$.