# Representing "and"/"or" relationships into constraints

How do I represent the following constraints in terms of equations?

For each i, either (1) holds or (2) holds-

$$x_{1}^i \geq x_{2}^i \quad and \quad x_{3}^i \geq x_{4}^i \quad {(1)}$$

$$x_{1}^i \leq x_{2}^i \quad and \quad x_{3}^i \leq x_{4}^i \quad {(2)}$$

• What type of variables are these? Commented Mar 25, 2023 at 0:42
• continuous (real-valued) Commented Mar 25, 2023 at 0:52

Introduce binary decision variable $$z^i$$. You can model your logical conditions via indicator constraints \begin{align} z^i=0 &\implies x_1^i \ge x_2^i \\ z^i=0 &\implies x_3^i \ge x_4^i \\ z^i=1 &\implies x_1^i \le x_2^i \\ z^i=1 &\implies x_3^i \le x_4^i \end{align} These indicator constraints can alternatively be enforced via linear big-M constraints \begin{align} x_2^i - x_1^i &\le M_1 z^i\\ x_4^i - x_3^i &\le M_2 z^i\\ x_1^i - x_2^i &\le M_3 (1-z^i) \\ x_3^i - x_4^i &\le M_4 (1-z^i) \end{align}
$$x_1^{i}-x_2^{i} \le \epsilon + Mz_1^i$$
$$x_2^{i}-x_1^{i}\le \epsilon + M(1-z_1^i)$$ $$x_3^{i}- x_4^{i} \le \epsilon + Mz_2^i$$
$$x_4^{i}- x_3^{i} \le \epsilon + M(1-z_2^i)$$
$$z_1^i+z_2^i \le 1+\delta_1$$
$$\delta_1 \le z_1^i$$
$$\delta_1 \le z_2^i$$
$$1\le \delta_1+\delta_2$$
$$1-z_1^i-z_2^i \le \delta_2$$
where $$z$$ are binary, M is upper bound of your $$x$$ and $$0\le \epsilon$$ is a very small number.