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≤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+…≤1
x=1, if a+b+c+d+e+f+g+h+…>1
Hi, I don’t know if I have the correct answer. I only try to help you based on what you comment. There is no single way to solve problems.
try adding these restrictions
* find binary variables y_i, x, such that
* x=0 if sum_y <= 1
* x=1 if sum_y > 1
set i / i1 * i8 /;
scalar M 'big-M of card(i) is enough' / [card(i)] /;
binary variable y(i);
binary variable x;
equation smallsum '(1-x) should be 1 if ysum is small-ish';
smallsum.. (1-x) * 2 + sum{i, y(i)} =G= 2;
equation bigsum 'x should be 1 if ysum is not small-ish';
bigsum.. sum{i, y(i)} =L= 1 + M * x;