Search found 46 matches

by Clemens
7 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 3125

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
7 months ago
Forum: API
Topic: Python Embedded in Gams - Import Python Package
Replies: 13
Views: 3125

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
8 months ago
Forum: Tools
Topic: Select an element randomly from a multidimensional set
Replies: 3
Views: 385

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
9 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1606

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
9 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1606

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
9 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1606

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
by Clemens
9 months ago
Forum: API
Topic: GAMS API Python
Replies: 7
Views: 2211

Re: GAMS API Python

The content does not look like the content of the LST file (_gams_py_gjo0.lst). Please make sure that you are really looking at the LST file. I also saw some problems in your Python code. You call the GamsWorkspace constructor multiple times and make multiple assignments to ws . Please make sure tha...
by Clemens
10 months ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 1606

Re: GAMS PYTHON API - INTERFACE JUPYTER

Hi, When calling the GamsWorkspace constructor, the API tries to find a valid GAMS system directory. The exact mechanism for this is depending on the operating system. If you want to specify a system directory explicitly you can do this by providing the named argument system_directory : GamsWorkspac...
by Clemens
10 months ago
Forum: API
Topic: GAMS API Python
Replies: 7
Views: 2211

Re: GAMS API Python

Hello, The ws.gamslib call tries to find the model Artigo_LJ1 in the GAMS Model Library and can not find it. If you want to create a GamsJob from a specific file you need to use ws.add_job_from_file (https://www.gams.com/latest/docs/apis/python/classgams_1_1workspace_1_1GamsWorkspace.html#af1e83abb0...
by Clemens
10 months ago
Forum: Tools
Topic: MySQL, GAMS and Unix
Replies: 3
Views: 448

Re: MySQL, GAMS and Unix

Renger,

Neither the Object-Oriented Python API nor the Embedded Code facility is currently available for Python 3.7. At least the Object-Oriented API will (at some point of time) support Python 3.7. The Embedded Code facility might follow then.

Best,
Clemens