4
$\begingroup$

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..

enter image description here

$\endgroup$
5
  • $\begingroup$ Would you see .lst file in the GAMS directory? $\endgroup$
    – A.Omidi
    Dec 15, 2020 at 7:16
  • $\begingroup$ yes i see the solution report in the .lst there but i need to automate the whole thing $\endgroup$
    – Eddiee
    Dec 15, 2020 at 7:22
  • $\begingroup$ What you mean by automating the whole thing? When the problem is solved this file is generated automatically with the full reports. $\endgroup$
    – A.Omidi
    Dec 15, 2020 at 8:15
  • $\begingroup$ I am solving multiple problems in a loop.. it's a bit tedious to get the data I want from the report $\endgroup$
    – Eddiee
    Dec 15, 2020 at 10:59
  • $\begingroup$ 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 $\endgroup$
    – Eddiee
    Dec 15, 2020 at 13:57

1 Answer 1

5
$\begingroup$

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);
);
$\endgroup$
3
  • $\begingroup$ will this parameter be in the .lst file? $\endgroup$
    – Eddiee
    Dec 16, 2020 at 11:03
  • $\begingroup$ Otherwise i can't access it via the python api i think. Parameters which arent part of the actual model arent in the .lst? $\endgroup$
    – Eddiee
    Dec 16, 2020 at 11:12
  • $\begingroup$ 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. $\endgroup$ Dec 16, 2020 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.