Issue with binary variables
AnsweredHi,
I am using gurobi python on Pycharm.
In my model, I used some binary variables (vtype=GRB.BINARY). The issue is when I print the values of these variables after optimization, sometimes I get values like '9.9999902022874265e-01' instead of '1'.
I appreciate your helps!
Thanks
Mirna
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Mirna,
For numerical reasons, an integrality constraint on a variable is considered satisfied if the variable value is "close enough" to an integer. By default, this tolerance is 1e-5. You can try setting the IntFeasTol parameter to a smaller value (e.g., 1e-8) to tighten this tolerance. Note that in some cases, tightening this tolerance too much can have a significant impact on the solve time.
I hope this helps!
Eli
1
Post is closed for comments.
Comments
2 comments