Bilkent Ogrencisi
Bilkent Ogrencisi

Reputation: 133

How to convert if else statement into Linear Programming constraints?

How to write the following if-else condition in Linear Programming?

If YR1 == 1 , then 20 <= XR1 <= 80, else XR1 = 0

YR1 is a binary variable, XR1 is a continuous variable.

I tried

20 - XR1 <= 1000 * (1 - YR1)
80 - XR1 <= 1000 * (1 - YR1)

XR1 - 20 <= 1000 * YR1

Is it correct? If not, how can I convert the statement to linear programming conditions?

Upvotes: 0

Views: 978

Answers (1)

Erwin Kalvelagen
Erwin Kalvelagen

Reputation: 16724

XR1 is called a semi-continuous variable. It can be modeled as:

 20*YR1 <= XR1 <= 80*YR1
 YR1 ∈ {0,1}
 

You need to split this into two inequalities.

Upvotes: 3

Related Questions