Gap AMPL API Python

I need to obtain the gap in AMPL API Python. I know that in AMPL the code is “display z.relmipgap” where z is the name of objective function.
the information capture is necesary because I export the results to excel.

I’m using gurobi and writed "ampl.option[“gurobi_options”] = “outlev=1 timelim=150 bestbound=1 return_mipgap=3"”

I defined “GAP = ampl.get_option(“relmipgap”)” but whitout success

1 Like

Hi @Oscar_Romero,

The value for relmipgap is not returned as an option but as a suffix for the objective. You can retrieve it with GAP = ampl.get_value("objective_name.relmipgap") (replacing “objective_name” by the name of your objective).

Thank you very much, everything worked ok

1 Like