How to use binary variables to satisfy if/then linear constraints

883 Views Asked by At

I am trying to solve the constraint $c$ where: $$c=\begin{cases} 50\sigma & \text{if $\sigma < 0$},\\ 150\sigma & \text{if $\sigma \geq 0$}. \end{cases} $$

I know I need to use binary variables but do I need to use two -one for each case? If so, how can I turn each variable on/off if sigma is negative? I cannot seem to formulate a constraint that is not satisfied when the binary variable is positive and negative.

1

There are 1 best solutions below

2
On

Introduce one binary variable $x\in\{0,1\}$ and the following linear constraints: \begin{equation} -\sigma \le M_1 x\\ -M_2 (1-x) \le c-50 \sigma \le M_3 (1-x)\\ \sigma \le M_4 (1-x)\\ -M_5 x \le c-150 \sigma \le M_6 x \end{equation} The various $M_i$ are big-M constants.

The first constraint enforces $\sigma < 0 \implies x=1$. The second constraint enforces $x=1 \implies c=50\sigma$. The third constraint enforces $\sigma > 0 \implies x=0$. The fourth constraint enforces $x=0 \implies c=150\sigma$.

Update: With @prubin's suggestions, assuming $L \le \sigma \le U$ for some constants $L$ and $U$, the constraints become: \begin{equation} L x \le \sigma \le U (1-x)\\ 0 \le c-50 \sigma \le 100 U (1-x)\\ 0 \le c-150 \sigma \le -100 L x \end{equation}