Python API: view solver output

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
davidwogan
User
User
Posts: 7
Joined: 3 years ago
Location: Tokyo, Japan
Contact:

Python API: view solver output

Post by davidwogan » 1 year ago

Hi everyone,

I have a workflow running GAMS models using the Python 3.6 API. I am looking for a way to inspect the solver progress, the same way you would when running a GAMS job in the IDE. Is there a class or method in the Python API to enable this type of output? This will assist in debugging the model, etc.

This topic may be related to this previous topic viewtopic.php?f=10&t=9903&p=22605&hilit ... put#p22605. I also searched the Python API documentation https://www.gams.com/latest/docs/API_PY_TUTORIAL.html. Perhaps I missed the class reference. Thanks!

David
David
Asia Pacific Energy Research Centre (APERC)

User avatar
bussieck
Moderator
Moderator
Posts: 615
Joined: 4 years ago

Re: Python API: view solver output

Post by bussieck » 1 year ago

David,

The GAMSJob.run method has an (optional) argument output. You pass in a stream, e.g. sys.stdout, and viola the GAMS log including the solver log appears on stdout. You can use other streams , including files to capture the log more permanently. This has been asked often enough that in the new GAMS 31 (currently in beta) we added a section to mention this explicitly: https://www.gams.com/beta/docs/API_PY_T ... PTION_FILE

-Michael

davidwogan
User
User
Posts: 7
Joined: 3 years ago
Location: Tokyo, Japan
Contact:

Re: Python API: view solver output

Post by davidwogan » 1 year ago

Michael,

Thank you for the pointer -- the output argument worked and is very convenient!

Many thanks,

David
David
Asia Pacific Energy Research Centre (APERC)

Post Reply