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
-
This is discussed in the Knowledge Base article Why does Gurobi sometimes return non-integral values for integer variables?
0
Please sign in to leave a comment.
Comments
1 comment