1

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

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Ire Dami
  • 23
  • 3

1 Answers1

1

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
AirSquid
  • 10,214
  • 2
  • 7
  • 31
  • Thanks, this worked. Did you derive this from a formula? If yes, could you show me? Thanks. – Ire Dami Dec 15 '22 at 01:54
  • For binary variables, one way to systematically translate is to translate the statements into a propositional CNF and then to translate the clauses into inequalities. Works well for the given examples. – Tim Dec 15 '22 at 21:31
  • These type of things are relatively common and you might want to pick up a textbook on Linear Programming that covers Integer Programming, or something that covers IP/MIP fundamentals... When in doubt, set up a small truth table and check 'em. – AirSquid Dec 16 '22 at 03:07