I have 8 binary variables :
Code: Select all
a,b,c,d,e,f,g,h
Code: Select all
x=0, if a+b+c+d+e+f+g+h≤1
x=1, if a+b+c+d+e+f+g+h>1
Code: Select all
x=0, if a+b+c+d+e+f+g+h+…≤1
x=1, if a+b+c+d+e+f+g+h+…>1
Code: Select all
a,b,c,d,e,f,g,h
Code: Select all
x=0, if a+b+c+d+e+f+g+h≤1
x=1, if a+b+c+d+e+f+g+h>1
Code: Select all
x=0, if a+b+c+d+e+f+g+h+…≤1
x=1, if a+b+c+d+e+f+g+h+…>1
Code: Select all
* 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;