Page 1 of 1

Using Embedded Python through API

Posted: Wed Jul 08, 2020 7:11 am
by Raghav

I have an embedded python code in GAMS model that assigns value to table Y based on the input parameter X.

When I try to run the gams model as a job through python API and use Modifier for X, I am unable to get any update on the table Y.

Will embedded python code work if the model job is run through Python API with a modifier (that is input to the embedded code in the GAMS code).

The code is inside

EmbeddedCode Python:


Please help and suggest if this is valid.


Re: Using Embedded Python through API

Posted: Thu Jul 09, 2020 6:51 am
by bussieck
I don't understand what you are asking. A modifier is only known in the context of a GamsModelInstance which does not execute any GAMS code it works off a generated model. Perhaps posting a small reproducible example is the way to go.


Re: Using Embedded Python through API

Posted: Thu Jul 09, 2020 3:48 pm
by Raghav
GAMS Code:

Parameter X

Table Delta

Embedded Code Python:

Y = list(gams.get('X'))

-----------------> Python Code to prepare data1 based on Y values <----------------

gams.set('Delta', data1)
EndEmbedded Code Delta

Model Test

The above model is called from Python API and with a modifier to change the values of X which in turn set the values for Table Delta. But the model instances are unable to modify Table Delta as the code to do the transformation from X to Delta is not endogenous to GAMS code.

That is what I am able to understand.

Re: Using Embedded Python through API

Posted: Fri Jul 10, 2020 6:05 am
by bussieck
That's not an example. And the statement that GamsModelInstances don't execute any GAMS code including embedded code still holds. -Michael