Getting correct result only when setting InFeasTol parameter
AnsweredHi,
I have a concern regarding the parameters set for Gurobi in Python. I know the solution to my mathematical model that I formulated however I get an incorrect value from Gurobi and I believe the reason is that Gurobi gives me values that are not 0 or 1 for binary variables.
To clarify, x(i,j,k) is a binary variable but here is a small screenshot of result I get from gurobi:
As you can see the value of objective function is 28.2 obtained by gurobi. However the correct value of objective function (which is total distance that I'm minimizing) should be 33.4 miles. On the same model now, when I set a parameter for tolerance by the following line, I get the correct answer:
m.Params.IntFeasTol = 1e-09
But this makes the computational time increase significantly from 3 seconds to 8 minutes.
For my research, I have to compare two models that are different only in some constraints. So I need to get the same objective function value on both models which I do when I set this parameter to 1e-09 on the first model. But since I get the correct value on the second model whitout this parameter, it runs faster although it is a larger model (based on number of variables an constraints) and this makes my comparison meaningless because I need to run both models under the same condition.
Is there any reason why I'm getting the wrong result without the tolerance value?
-
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 Azi,
Is there any reason why I'm getting the wrong result without the tolerance value?
Every mathematical software has to work with tolerances due to floating point arithmetic (with very few exceptions). Thus, the solution you obtain is correct within tolerances. Decreasing these tolerances as you did with setting the IntFeasTol parameter is expected to deteriorate performance because more tedious computations have to be performed. You could try setting the IntegralityFocus parameter available in the latest version of Gurobi which will make Gurobi focus on true integer values, i.e., \(\{0,1\}\) in your case, only. Please note that using this parameter will very likely worsen the performance.
For more details of why tolerances are needed and may rise difficulties, please have a look at the the article by Ed Klotz on Ill-Conditioning and Numerical Instability in MIPs.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments