Difference in relative gap calculation
AnsweredHi everyone, I've been seeing some confusing results in my models that I am hoping someone can help me understand.
When I run one instance of my model, which is a minimization problem, both my objective value and lower bound are positive, and the relative gap is calculated as |ObjVal-LB|/|ObjVal| in both the log file and the final solution (see screenshot below)
However, when I run another instance where the objective value and lower bound are negative, the relative gap in the log file is calculated using |ObjVal-LB|/|ObjVal|, but the relative gap given in the final solution is calculated using |ObjVal-LB|/|LB| (see below)
Has anyone seen this before, and has an understanding as to why Gurobi is inconsistent in relative gap calculation for models with negative objective values and bounds?
-
The output "MIP Solution", "Final Solve", etc. comes from GAMS, not Gurobi. Gurobi and GAMS use different formulas to calculate the relative MIP gap.
Gurobi calculates the relative MIP gap as
$$\begin{align}\textrm{gap} = \frac{|z_P - z_D|}{|z_P|},\end{align}$$
where \(z_P\) is the primal objective bound and \(z_D\) is the dual objective bound. In contrast, GAMS calculates the relative MIP gap as
$$\begin{align}\textrm{gap} = \frac{|z_P - z_D|}{\max\{|z_P|, |z_D|\}}.\end{align}$$
1 -
Oh, that makes sense. Thank you so much!
0
Please sign in to leave a comment.
Comments
2 comments