why integer decision variables work much better than binaries?
AnsweredHello,
I am rather new in Gurobi but have spent a fairly big amount of time trying to set a model that optimally selects a group of objects among a large ensemble, according to certain restrictions. What I found is that, contrary to what I have thought, when some variables in the model that can only take 0 and 1 values are defined as integers, as follows
z ={i: cosp.addVar(vtype=GRB.INTEGER,lb=0,ub=1,\
name="z_{0}".format(i)) for i in set_I}
the results are far better that defining as
z ={i: cosp.addVar(vtype=GRB.BINARY, name="z_{0}".format(i)) \
for i in set_I}
There are also more variables like z_i that have to be defined as integers as well. Is this indicating any flaws in my model construction?
Thanks and regards,
Paco
-
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 Paco,
This sounds very strange. There should not be a difference between a 0-1 integer variable and a binary variable. You should write out the two formulations as LP files and then check for differences.
Cheers,
Matthias0 -
Hi Matthias,
Thanks for your help. In fact, there were differences between the two models. I copied the initial integer definition but made typo in one of the sets that should be the reason for the lack of performances in the binary case. I have corrected it and will try now.
Thanks again.
Paco
0
Post is closed for comments.
Comments
3 comments