I have tried following problem, but I could not solve it. Can you please help me in this?
I have 8 binary variables : a,b,c,d,e,f,g,h
I want to define a variable (x) with the help of linear equations with following conditions:
- $x=0$, if $a+b+c+d+e+f+g+h\leq 1$
- $x=1$, if $a+b+c+d+e+f+g+h>1$
Further, in my problem, these variables can be more or less than 8. Thus, can you help me in finding a general set of linear equations with $n$ binary variables satisfying the following:
- $x=0$, if $a+b+c+d+e+f+g+h+\ldots\leq1$
- $x=1$, if $a+b+c+d+e+f+g+h+\ldots >1$
Thank you.
You can enforce the logical implication $x = 1 \implies \sum_{j=1}^n y_j \ge 2$ by imposing linear constraint $\sum_{j=1}^n y_j \ge 2x$.
You can enforce the logical implication $x = 0 \implies \sum_{j=1}^n y_j \le 1$ by imposing linear constraint $\sum_{j=1}^n y_j - 1 \le (n-1)x$.
As a check, there are two cases: