Search code examples
matlabbinarylinear-algebralinear-programminggams-math

Need to write a set of linear equations for following condition:


I have three variables : A, B, C.

I want to write a set of linear equations such that

X = 1 if atleast 2 of A,B,C are ones.

X= 0 if only one of A,B,C is one.

X = 0 if all of them are zero.

A,B and C are binary (0,1).

Kindly suggest a linear equation for this.

Thank you.


Solution

  • X >= A + B - 1
    X >= B + C - 1
    X >= A + C - 1
    
    X <= A + B
    X <= B + C
    X <= A + C
    

    as mentioned in comment, you didn't define outcome for A=B=C=0, but in that case X -> 0 by inspection.