Binary Varibales get negative -0.0 values
回答済みHello,
How is it possible to get -0.0 when they are binary variables?
Thanks.
-
正式なコメント
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. -
Have you had a chance to look at our Knowledge Base article Why does Gurobi sometimes return non-integral values for integer variables?
0 -
Yeah,
I set IntFeasTol to 1e-9 and IntegralityFocus to 1, but it didn't changed the outcome.
Thanks for the fast reply.
0 -
Yes, things like this still can happen due to limited precision arithmetics.
We usually do a very rough test for binary variables in a solution: if x > 0.5 then x=1 else x=0.0 -
for j in range(n):
for i in range(m):
model.addConstr(y_2022[j,i] >= 0.5 + eps - M*(1-B))
model.addConstr(y_2022[j,i] <= 0.5 + M*(B))
model.addConstr((B==1) >> (y_2022[j,i] == 1))
model.addConstr((B==0) >> (y_2022[j,i] == 0))
I added something like this, but this time i didn't have any outcome, are there
something wrong with this?
Thanks0 -
I probably was not clear with my last comment. The idea is not to add further constraints to ensure that binary variables get exactly value 0 or 1. This is simply not possible on all our machines with limited precision arithmetics.
The test I proposed is meant for analyzing the solution after the optimization process has already finished. If the value for a binary variable is larger than 0.5, then it is actually 1 (or True) in the solution, 0 otherwise.
0 -
Oh OK, i thought adding such constraint would delete the - sign on the 0.0's but it's the same thing.
Thanks for your support.
0
投稿コメントは受け付けていません。
コメント
7件のコメント