Originally posted by: SystemAdmin
[rocarvaj said:]
As far as I know, you have to compute it by yourself. I don't know if this works on 9.0 (I use 11.0) but it can help you:
int rval = 0;
double best_bound, IP_obj, mip_gap;
rval = CPXgetbestobjval(env, lp, &best_bound);
rval = CPXgetobjval(env, lp, &IP_obj);
if(rval)
/** In this case, CPLEX didn't find any feasible solution */
fprintf(stderr, "No feasible solution. Best bound: %f\n", best_bound);
else
{
/** Assuming you're maximizing */
mip_gap = (best_bound - IP_obj)/(IP_obj + 0.001)*100;
fprintf(stderr, "MIP gap: %f\n", mip_gap);
}
That should be it. If there's any errors or a better way to do it, tell me.
Greetings from Chile!
#CPLEXOptimizers#DecisionOptimization