Search found 40 matches

by Clemens
2 weeks ago
Forum: API
Topic: gams_job.interrupt() does not work in Python 3.6
Replies: 3
Views: 252

Re: gams_job.interrupt() does not work in Python 3.6

Serdar,

This is actually a bug in the GAMS Python API. We have already fixed the bug and will publish it in the next GAMS release. Thank you very much for reporting this problem.

Best,
Clemens
by Clemens
2 months ago
Forum: API
Topic: Python API: Solving two models one after the other
Replies: 1
Views: 217

Re: Python API: Solving two models one after the other

Giorgis, It would be good if you can provide some code that demonstrates the problem. I assume that you are using GamsWorkspace.add_job_from_string() to create a GamsJob instance. This one can be executed using the run() method and should per default compile and execute all your GAMS code. Best, Cle...
by Clemens
3 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 2699

Re: Python Embedded in Gams - Import Python Package

Renger, The mechanism on finding the Python interpreter is different on Linux. The shared object that is responsible for loading the Python interpreter uses @rpath to resolve its dependency to the Python shared object. Therefore it will be very hard to convince Embedded Code to use a different Pytho...
by Clemens
3 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 2699

Re: Python Embedded in Gams - Import Python Package

Good to hear that the plotting is working. Perhaps one could start from a setup where no Python is found at all. This means that the python36.dll in the GAMS system directory is renamed. Furthermore the PYTHONPATH and also the PATH should be empty or at least should not contain any PYTHON or GAMS sp...
by Clemens
3 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 2699

Re: Python Embedded in Gams - Import Python Package

Renger, Regrading wxPython: I have attached the file meanvarPlot.gms which shows how to use Embedded Code and matplotlib/wxPython for generating a plot which shows up in a new window. Your Python interpreter needs to have both matplotlib and also wxPython installed. Regarding PySetup=0: There seems ...
by Clemens
3 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 2699

Re: Python Embedded in Gams - Import Python Package

Renger, You are right. Tkinter is not part of GMSPython. If you only want to get matplotlib running, there is a workaround for this. You can use wxPython . Install it using: pip install wxPython and then in embeddedCode you can do the following: import matplotlib matplotlib.use('WXAgg') import matpl...
by Clemens
4 months ago
Forum: Tools
Topic: Select an element randomly from a multidimensional set
Replies: 3
Views: 254

Re: Select an element randomly from a multidimensional set

I see two possibilities to do this: 1) Splitting up the ord() into three individual parts: scalar rI, rJ, rK; rI=uniformint(1,card(i)); rJ=uniformint(1,card(j)); rK=uniformint(1,card(k)); sRand(i,j,k)$(ord(i)=rI and ord(j)=rJ and ord(k)=rK) = yes; 2) Using an Embedded Code section (Python): embedded...
by Clemens
5 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1335

Re: GAMS PYTHON API - INTERFACE JUPYTER

There is no fundamental difference when accessing records of GAMS Symbols with a dimension greater than zero. You can iterate through the records as you already did and for each record you can access the available information. This is .key(x) where x needs to be between 0 and dimension-1. You get th...
by Clemens
6 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1335

Re: GAMS PYTHON API - INTERFACE JUPYTER

From your code it seems that the variable COST is zero dimensional, but you try to access key(0) and key(1) which would only be possible for GAMS symbols with at least two dimensions. Instead of doing this: for rec in t1.out_db["cost"]: print("cost(" + rec.key(0) + "," + rec.key(1) + "): level=" + s...
by Clemens
6 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1335

Re: GAMS PYTHON API - INTERFACE JUPYTER

You can not use ws.gamslib() for you custom models. You need to use ws.add_job_from_file in order to load a model from a specific file that you have created.

Best,
Clemens