Using Embedded Python through API

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
Raghav
User
User
Posts: 2
Joined: 3 years ago

Using Embedded Python through API

Post by Raghav »

Hi,

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:

EndEmbeddedCode

Please help and suggest if this is valid.

Thanks,
Raghav
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Using Embedded Python through API

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

-Michael
Raghav
User
User
Posts: 2
Joined: 3 years ago

Re: Using Embedded Python through API

Post 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.
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Using Embedded Python through API

Post by bussieck »

That's not an example. And the statement that GamsModelInstances don't execute any GAMS code including embedded code still holds. -Michael
Post Reply