# GAMS: Is there a way to retrieve the gap from the final solve statement

Good evening, I am looking for a way to retrieve information from the final solve statement. Lower bound and Gap would be nice. I am working with the python api but i can only get the final obj. value and all parameters etc.. Is there a way to store the information I need in a parameter and what would be the command?

I want to access and store the underlined values in the picture..

• Would you see .lst file in the GAMS directory? – A.Omidi Dec 15 '20 at 7:16
• yes i see the solution report in the .lst there but i need to automate the whole thing – DerEddie Dec 15 '20 at 7:22
• What you mean by automating the whole thing? When the problem is solved this file is generated automatically with the full reports. – A.Omidi Dec 15 '20 at 8:15
• I am solving multiple problems in a loop.. it's a bit tedious to get the data I want from the report – DerEddie Dec 15 '20 at 10:59
• UPDATE: my current workaround: use put Model.objest (this is what i found out how to get the lower bound) into a temporary.txt and access that via python kinda cumbersome but at least it works – DerEddie Dec 15 '20 at 13:57

Collecting things in a parameter is actually very simple.

set run /.../;

parameter objresult(run,*);

loop(run,
solve m ....
objresult(run,"obj") = m.objval;
objresult(run,"bestbound") = m.objest;
objresult(run,"absgap") = abs(m.objval-m.objest);
);

• will this parameter be in the .lst file? – DerEddie Dec 16 '20 at 11:03
• Otherwise i can't access it via the python api i think. Parameters which arent part of the actual model arent in the .lst? – DerEddie Dec 16 '20 at 11:12
• Sorry, I have no clue what you are saying here. The listing file is well just a listing file. I fail to see the connection with the Python API. This makes no sense. – Erwin Kalvelagen Dec 16 '20 at 11:45