Conditional binary formulation for variable greater than 0

Problems with syntax of GAMS
Post Reply
ggood
User
User
Posts: 3
Joined: 1 month ago

Conditional binary formulation for variable greater than 0

Post by ggood » 1 month ago

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 viewtopic.php?t=10286, 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

Manassaldi
User
User
Posts: 113
Joined: 5 years ago
Location: Rosario - Argentina

Re: Conditional binary formulation for variable greater than 0

Post by Manassaldi » 1 month ago

Hi, try this bigM reformulation

X =L= BbigM*B

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

best

ggood
User
User
Posts: 3
Joined: 1 month ago

Re: Conditional binary formulation for variable greater than 0

Post by ggood » 1 month ago

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!

ggood
User
User
Posts: 3
Joined: 1 month ago

Re: Conditional binary formulation for variable greater than 0

Post by ggood » 1 month ago

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!

Manassaldi
User
User
Posts: 113
Joined: 5 years ago
Location: Rosario - Argentina

Re: Conditional binary formulation for variable greater than 0

Post by Manassaldi » 1 month ago

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

X =L= Xup*B
X =g= 1e-6*B

Hope this can help you
Best

Post Reply