I have a multiple if-then logic, like this:

if a=1 b=0;

if a=2 b=1;

if a=3 b=0;

if a=4 b=1;

the variable ‘a’ is an integer which can be valued from 1-4. the variable ‘b’ is a binary which can be valued from 0-1.

I know the big-M method, which can solve the situation when ‘a’ and ‘b’ are both binary. However, when ‘a’ is an integer, I feel hard to make it be accepted by CVX.

You can express any integer in its binary form. like, the third constraint, let a=a1a2a3, then it will be b<=a1+(1-a2)+(1-a3), since a’=011=3 in this cons. It generalizes the same when b is integer.

1 Like

Thanks for your reply. This constraint form is great.