MIPGap and Runtime query before optimization stops

Answered

Comments

8 comments

  • Eli Towle

    Hi Wu,

    You're right that you cannot directly obtain the MIPGap from a callback. However, you can easily calculate the gap yourself using the incumbent objective value (\(\textrm{ObjVal}\)) and the best bound (\(\textrm{ObjBound}\)), both of which can be retrieved in a callback. The formula is:

    $$\begin{align*}\textrm{Gap} = \frac{|\textrm{ObjBound} - \textrm{ObjVal}|}{|\textrm{ObjVal}|}.\end{align*}$$

    Thanks,

    Eli

    0
    Comment actions Permalink
  • Pritom Kumar Mondal

    Hello Eli,

    I also have a similar question. I solve large MILP models by using Gurobi solver through AMPL environment. I tried to use the high processing computer center of my university but they have the rule to stop job every 48 hours.

    So my question is I get to know about the incumbent objective value when I am stopping a problem but what is the command to know about the best bound?

    Thanks,

    Pritom

    0
    Comment actions Permalink
  • Robert Fourer

    In AMPL, add bestbound=1 to your gurobi_options string -- or if you are not setting a gurobi_options string yet, give this command before solving:

    option gurobi_options 'bestbound=1';

    Then the best bound will be returned in the suffix ".bestbound" on the objective. For example, if your objective function is "minimize TotalCost" then the best bound will be given by "TotalCost.bestbound".

    0
    Comment actions Permalink
  • Pritom Kumar Mondal

    Hello,

    Thank you so much for your response. I was testing this command on some examples. 

    If we get the optimum solution or interrupt AMPL before getting a feasible solution, will it show the following?

    suffix bestbound OUT;

    Will I get a bestbound only if I interrupt the problem with a feasible non-optimum solution?

    Thanks,

    Pritom

    0
    Comment actions Permalink
  • Robert Fourer

    The message "suffix bestbound OUT" says that the suffix .bestbound was created by Gurobi for output to AMPL. It's only an informational message; it appears the first time that Gurobi runs with bestbound=1 in an AMPL session, and does not convey any information about whether Gurobi has found a feasible or optimal solution.

    You will always get a bestbound value when bestbound=1 is set. If the root relaxation problem has a feasible solution, then bestbound will be a meaningful finite value. If the root relaxation is infeasible, then bestbound will be 1e+100 (when minimizing) or -1e+100 (when maximizing), which is technically a finite value but should be interpreted as standing for "infinity".

    0
    Comment actions Permalink
  • Pritom Kumar Mondal

    Hello

    Thank you so much for your response. I understand what you mentioned here. I posted a similar question on another thread. I am using the command you gave me but I couldn't find the bestbound. Please see the following commands.

    I am using the following commands on AMPL.

    model 2Modefile.mod;
    data 2dataset.dat;
    option gurobi_options 'bestbound=1';
    option solver gurobi;

    solve;

    The output is the following.

    Gurobi 9.1.1: bestbound=1
    Gurobi 9.1.1: optimal solution; objective 13150
    4 simplex iterations

    suffix bestbound OUT;

    With your answer, it is clear to me now what it is meant by bestbound out. But my question is what command should I use to see the bestbound?

    Thanks,

    Pritom

     

    0
    Comment actions Permalink
  • Robert Fourer

    As mentioned previously, the best bound is returned in the suffix ".bestbound" on the objective. For example, if your objective function is "minimize TotalCost" then the best bound is given by "TotalCost.bestbound", which you can use wherever a number would make sense. In particular, if you want to see the best bound, you can give the AMPL command

    display TotalCost.bestbound;

    (though with the name of your objective function in place of "TotalCost").

    0
    Comment actions Permalink
  • Pritom Kumar Mondal

    Thank you, Robert! I appreciate your help.

    Thanks,

    Pritom

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk