Making a Variable Non-Zero

Problems with modeling
Post Reply
JCunningham8
User
User
Posts: 2
Joined: 1 year ago

Making a Variable Non-Zero

Post by JCunningham8 »

Hi all,

I am currently working on a MILP problem that requires two variables to be either negative or positive, but not zero. Below, f(aij,t) is a variable that can be either negative or positive, which is calculated elsewhere in the model, while qout(aij,t) and qin(aij,t) are variables that are both negative if f(aij,t) is negative, or both positive if f(aij,t) is positive, but both qout(aij,t) and qin(aij,t) must have non-zero value. I therefore cannot specifically define both qout(aij,t) and qin(aij,t) as positive or negative variables, and defining them as normal variables results in one (usually qin(aij,t)) being zero.

Code: Select all

variable f(aij,t), qout(aij,t), qin(aij,t);

equation averagef;
averagef(aij(ap,gn,gm),t) .. f(aij,t) =e= (qout(aij,t)+qin(aij,t))/2
Currently, the above code results in qin.L(aij,t) = 0 , and qout.L(aij,t) = 2*f(aij,t). Thus, is there a way to enforce both qout(aij,t) and qin(aij,t) to both have non-zero values?

Any help is greatly appreciated. Cheers!
User avatar
bussieck
Moderator
Moderator
Posts: 1037
Joined: 7 years ago

Re: Making a Variable Non-Zero

Post by bussieck »

Optimization happens over compact sets, so no >0 is allowed. You need to specific, like >= 1e-6. But even this one is so so, because every solver works with feasibility tolerances (usually around 1e-4 to 1e-6) and hence the variables can still be zero even if you require them to be >=1e-6 or <= -1e-6.

-Michael
Post Reply