# If then else constraints

 0 I need to formulate the following as linear constraints using binary variables. Can someone help me out? If A <= 3, then B >= 6, else B <= 4 (Assume A & B are integers) asked 17 Sep '15, 15:10 Shyam 1●1 accept rate: 0%

 4 You want to model $(\underline{A} \le A \le 3 \text{ and } 6 \le B \le \overline{B}) \text{ xor } (4 \le A \le \overline{A} \text{ and } \underline{B} \le B \le 4)$ Let $$x=0$$ correspond to the left half of the exclusive disjunction and $$x=1$$ correspond to the right half. Here's a way to organize the needed constraints so that it is easy to visually check their correctness: \begin{align} 4x + \underline{A} (1-x) \le &A \le \overline{A} x + 3 (1-x) \\ \underline{B}x + 6 (1-x) \le &B \le 4x + \overline{B}(1-x) \end{align} answered 17 Sep '15, 17:58 Rob Pratt 1.2k●2●6 accept rate: 28%
 0 \begin{gather*} A \le 3 + \text{UB}(A) * x\\ B \ge 6 - \text{LB}(B) * x\\ B \le 4 + \text{UB}(B) * (1 - x)\\ x ~\textrm{binary} \end{gather*} answered 17 Sep '15, 15:39 fbahr ♦ 4.6k●7●16 accept rate: 13% Paul Rubin ♦♦ 14.6k●5●13 1 I think you also need $$A \ge 4 - LB(A)*(1 - x)$$. Otherwise $$A \le 3$$ and $$B \le 4$$ (with $$x = 1$$) satisfies the constraints. (17 Sep '15, 18:12) Paul Rubin ♦♦
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: