Home > database >  Get If (condition), then (assign value), else (assign other value) statement in Linear Programming
Get If (condition), then (assign value), else (assign other value) statement in Linear Programming

Time:12-15

I'm looking for a linear programming equation that satisfied the conditions;

Given that all variables here are binary variables

if A B = 2; then C = 1; else C = 0

Also,

if A B D = 3; then E = 1; else E = 0

How would one phrase this and satisfy these conditions as well as linearity conditions?

I've tried

A B - 2 <= M(1-y) and 1 - C <= My

for the first constraint but it doesn't seem to work

CodePudding user response:

For the first equation, you can use:

C   1 >= A   B
2C <= A   B

If there is a natural sense (max/min) for C in the problem, one of those is sufficient.

Similarly for the second:

E   2 >= A   B   D
3E <= A   B   D
  • Related