GAMS Engine with GAMSModelInstance

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
nechiforv
User
User
Posts: 8
Joined: 4 years ago

GAMS Engine with GAMSModelInstance

Post by nechiforv »

Dear GAMS community,

I have a question that is rather broad but hoping to get some clarifications.

I would want to quantify the benefit with GAMS Engine of being able to run multiple model solves in parallel. This could potentially allow many more parallel runs than the number of cores one would have when using the GAMS multi-threading facility or the parallel submissions using Python-based (for example) GAMSModelInstance.

My question is to what extent does GAMS Engine allow for wrapping/altering a pre-existing Python code/classes which uses GAMSModelInstance to run a GAMS model. This Python code besides running a sequence of solves also has an internal logic of how the GAMS model parameters are changing across runs (through the Modifiers) and also considers relationships between model solutions across time (for instance, it runs sequences of 5-year simulations where the solution of one year influences the model setup for the next year).
Would I be able to use GAMS Engine to build on this existing Python code? Ideally the Engine would be able to use the classes that I already have, but maybe everything would need to be re-developed and GAMSModelInstance would need to be entirely replaced?

Many thanks in advance for any tip/hint.

Kind regards,
Victor
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: GAMS Engine with GAMSModelInstance

Post by bussieck »

Viktor,

GAMS Engine is designed to run GAMS jobs not Python jobs. Nevertheless, you can "trick" the system because GAMS that is installed on Engine workers comes with a Python 3.8 installation (GMSPython) so GAMS code can execute e.g. embedded Python code in GAMS. This Python installation comes with a number of packages (e.g. pandas) and has all the GAMS APIs installed, so it works e.g. with the Python OO GAMS API including GAMSModelinstance. If your code/classes can be run with GMSPython then you can execute your code via a "dummy" GAMS program that just runs your Python script:

Code: Select all

$call %gams.sysDir%GMSPython/python myscript.py
You instruct Engine to just bring everything along you need for the job to run, including the dummy GAMS script and your myscript.py. Also for the output, you tell Engine what you want back. Who (GAMS or Python) creates the files that you want back is to no concern of Engine.

If GMSPython is not sufficient because you need other Python packages to run your job then the worker needs to be modified. In this case you need to get support from the GAMS folks (support@gams.com) to get you a different GAMS worker.

-Michael
nechiforv
User
User
Posts: 8
Joined: 4 years ago

Re: GAMS Engine with GAMSModelInstance

Post by nechiforv »

Dear Michael,

Thank you for your detailed reply. Very useful, as always.

Victor
Post Reply