Why binary variables range from (0,1)
AnsweredHi,
I set the variables as binary. But while adding lazy constraints, some values of variables range from (0,1). Please suggest.
var = m.addVars(dist.keys(), vtype=GRB.BINARY, name='e')
0
-
Some pictures are missing.
0 -
Hi Chenshi,
I assume you might be referring to some of these 0.9999999 numbers. Indeed there are some "rounding errors" that may cause this behaviour (usually quite small, less than 1e-5).
When checking whether a binary value is 0 or 1, you should consider a possible error, doing something like:
if binary_value > 0.5:
#assume binary is 1
else:
#assume binary is 01 -
Thank you!
0 -
Note we have a parameter, IntegralityFocus, that can help with this but it incurs a (typically small) cost in performance.
0
Please sign in to leave a comment.
Comments
4 comments