1

I want to calculate relative optimality Gap of a MIP Problem also i want to abort runs at a certain run time. this method:

F(1)    
abs(mymodel.objest - mymodel.objval)/max(abs(mymodel.objest),abs(mymodel.objval)) 

is not consistent with gap which GAMS calculate in log. GAMS uses "Best Integer" to find gap not current objective value. which one is correct? and How can i save current "Best Integer" into a parameter ( like .objval).

and finally calculating relative optimality Gap in a benders algorithm is right this way?

rgap = (upperBound - lowerBound)/(1 + abs(upperBound));

What GAMS Calculate using "MIP Solution"

MIP Solution:   3334501534.000555    (1625 iterations, 0 nodes)
Final Solve:      56330158.829040    (2561 iterations)

Best possible:    48915652.476336
Absolute gap:   3285585881.524219
Relative gap:            0.985330

F(1) calculated gap using mymodel.objval (mymodel.objval return "Final Solve") so calculated gap is %13 and mymodel.objval value is 5.633016E+7 (GAMS calculated gap is %98). so i need to save "MIP Solution" to a parameter to export it to a excel file.

1 Answers1

1

There are different formulas to calculate the relative optimality gap. It depends on the solver you use, which one is applied. Some info about this can be found in the description of the GAMS option optCR . The solver manual of the solver you use could have more details about the formula actually applied.

EDIT after question was updated:

As you wrote mymodel.objval returns the Final Solve value. If you want to see the MIP Solution value instead (as the Cplex link does it internally), you could deactivate the final solve. However, if Final Solve and MIP Solution are so much different as in your example this is often an indication for some problem (usually, they are (nearly) identical). Often, this indicates a poorly scaled model. Maybe you could improve the situation by tightening the Cplex tolerances (see Cplex options epopt, eprhs, epint) and activating aggressive scaling (Cplex option scaind 2). Activating mipkappastats (https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXmipkappastats) and quality (https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXquality) could give you more information. DataCheck=2 (https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXdatacheck) might show some problems.

Lutz
  • 2,197
  • 1
  • 10
  • 12
  • Hi, thanks for your respond, the problem is mymodel.objval doesn't return "best known integer solution" value. i need last "best known integer" value to calculate rgap. please see this: https://support.gams.com/solver:what_is_optca_optcr – mohammad reza sourati Aug 17 '20 at 07:49
  • So, what does mymodel.objval return to you? What solver are you using? Can you share, what you tried? – Lutz Aug 17 '20 at 08:23
  • I've used Cplex 12.5.1.0, I've add it to main question. – mohammad reza sourati Aug 17 '20 at 10:03
  • Thanks, The problem is so big in number of constraints and variables and i abort it very shortly, the gap between final solve and MIP Solution reduce by passing time. deactivating the final solve is a good idea but what is it's consequences except "no proper marginal values", has it impact on solve time or anything else? – mohammad reza sourati Aug 19 '20 at 14:14
  • It influences the total solve time such, that you save the time to do the final solve. So, you save some time and the "price you pay" is that you do not get the marginals back. – Lutz Aug 19 '20 at 14:32