Conditional binary formulation for variable greater than 0

Hi everyone,

I am working on an MIP optimization problem where X is a positive variable with a lower bound of zero and no upper bound and B is a binary variable.

X{0,inf} and B{0,1}

I’m trying to formulate equations such that if X =E= 0 then B =E= 0, else B=E=1. I’ve bound B with the following constraint:

X =L= bigM * B /bigM is a value much larger than any expected value the model can choose based on other constraints/

such that when X is greater than 0, B must equal 1. However, I’m completely lost as to how to formulate the second conditional equation so that when X equals 0, B must equal zero.
I’ve reviewed https://newforum.gams.com/t/logical-equations-binary-variables/2108/1 but the equations don’t force the binary variable to equal 0 when the lower bound is also equal to 0.
Any advice about how I can code this logical condition into my model would be greatly appreciate. Thank you for your help.

Greg

Hi, try this bigM reformulation

X =L= BbigM*B

if you propose a lower and upper bound you can use the following:
X =L= XupB
X =g= Xlo
B

best

Hi,

Thank you for your response. What I’m confused about in your proposed formulation is how it ensures that when X=0 that B is all =0. Isn’t it the case that when X=0 that B can equal either 0 or 1? Thanks again for your help!

Hi,

Thank you for your response. What I’m confused about in your proposed formulation is how it ensures that when X=0 that B is all =0. Isn’t it the case that when X=0 that B can equal either 0 or 1? Thanks again for your help!

It’s hard with a continuous variable. You can try putting a small lower bound
For example:

X =L= XupB
X =g= 1e-6
B

Hope this can help you
Best