Gurobi Free Variable
OngoingHi,
In Gurobi, how can a free variable be defined if it takes all the values negative or positive except zero?

Could you describe a bit more how you want to use that variable  is it continuous or integer and how do you want to use the variable? The challenge is that computers have limited precision so the question becomes "how close to zero is considered zero". See also this article for more detail.
0 
A continuous variable.
I want to use a free variable (e.g. x) in a constraint that ensures that "x" should not equal zero and takes any value other than zero that is feasible.
0 
As you can see in the article, the problem with your constraint is that it's not properly defined when something is "close enough to zero". If 0.0 is not allowed, would 0.001 be allowed, or 0.0001 ?
If you have a properly defined threshold, you may look at indicator constraints.
 Give your variable lowerbound GRB.INFINITY and upperbound +GRB.INFINITY
 Define a binary variable that is 1 when your continuous variable is positive , 0 when negative
 Add two indicator constraints linking both variables: When the binary is 1, your continuous variable must be at least equal to the threshold. When it's 0, the continuous variable must not be greater than threshold.
Hope this helps!
Kind regards,
Ronald0
Please sign in to leave a comment.
Comments
3 comments