Let $0\le X\le\bar X$ and $0\le Y\le\bar Y$ be nonnegative continuous variables. Let $\epsilon$ be a small positive number. How can the constraint $X\ge\epsilon\implies X\ge Y$ be modeled?
2 Answers
Introduce binary variable $Z$ and linear constraints \begin{align} X - \epsilon &\le (\bar{X} - \epsilon) Z \tag1 \\ Y - X &\le (\bar{Y} - 0) (1-Z) \tag2 \\ \end{align} Constraint $(1)$ enforces $X > \epsilon \implies Z = 1$. Constraint $(2)$ enforces $Z = 1 \implies X \ge Y$.
With CPLEX you can use logical constraints. In OPL for instance you can write
float epsilon=0.01;
dvar float X;
dvar float Y;
subject to
{
(X>=epsilon) => (X>=Y);
}
And if you wonder , logical constraints are available in OPL but also in all APIs.
float epsilon=0.01;
dvar float X; dvar float Y;
subject to { (X>=epsilon) => (X>=Y); }
main { thisOplModel.generate(); cplex.exportModel("exp.lp"); }
gives exp.lp
Minimize
obj1: 0 x1 + 0 X + 0 x3 + 0 Y
Subject To
i1: x1 = 1 <-> X => 0.01
i2: x3 = 1 <-> X - Y => 0
i3: x1 = 1 -> x3 = 1
Bounds
0 <= x1 <= 1
X Free
0 <= x3 <= 1
Y Free
Binaries
x1 x3
End
-
$\begingroup$ But this requires using OPL. Is there a way to see how CPLEX translates the statement to a set of constraints? I suppose the solution is then the same as stated by Rob Pratt? $\endgroup$– ClementSep 15, 2021 at 15:26