Binary variable having floats as results
AnsweredHi,
In the past few days, when I ran my model, I observed that some of the binary variables, which I expected to take either 0 or 1, ended up sometimes taking some floats, which is shown below:
((‘T9', 'M1'), 'ST, 24) 0.9999959899878522
(('T9', M1'), 'ST', 22) 3.4349085137562096e-06
(('T9', 'M1'), 'ST, 25) 5.644126990605905e-07
(('T9', 'M1'), 'ST, 30) 1
I always want to ensure optimal solution; hence, I set my gap to zero.
model.setParam(GRB.Param.MIPGap, 0)
Note that sometimes, when I rerun the model, I obtain another solution where all binary variables take 0 or 1.
Note that sometimes, when I rerun the model, I obtain another solution where all binary variables take 0 or 1.
Can someone please help me figure out how to fix this to ensure that I always obtain 0 or 1?
0
-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
This is discussed in the Knowledge Base article Why does Gurobi sometimes return non-integral values for integer variables?
0
Post is closed for comments.
Comments
2 comments