Search found 67 matches
- 5 years ago
- Forum: API
- Topic: Python Embedded in Gams - Import Python Package
- Replies: 13
- Views: 17519
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...
- 5 years ago
- Forum: API
- Topic: Python Embedded in Gams - Import Python Package
- Replies: 13
- Views: 17519
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 ...
- 5 years ago
- Forum: API
- Topic: Python Embedded in Gams - Import Python Package
- Replies: 13
- Views: 17519
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...
- 5 years ago
- Forum: Tools
- Topic: Select an element randomly from a multidimensional set
- Replies: 3
- Views: 4731
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...
- 5 years ago
- Forum: API
- Topic: GAMS PYTHON API - INTERFACE JUPYTER
- Replies: 7
- Views: 10816
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...
- 5 years ago
- Forum: API
- Topic: GAMS PYTHON API - INTERFACE JUPYTER
- Replies: 7
- Views: 10816
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) + "," ...
- 5 years ago
- Forum: API
- Topic: GAMS PYTHON API - INTERFACE JUPYTER
- Replies: 7
- Views: 10816
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
Best,
Clemens
- 5 years ago
- Forum: API
- Topic: GAMS API Python
- Replies: 7
- Views: 11332
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...
- 5 years ago
- Forum: API
- Topic: GAMS PYTHON API - INTERFACE JUPYTER
- Replies: 7
- Views: 10816
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...
- 5 years ago
- Forum: API
- Topic: GAMS API Python
- Replies: 7
- Views: 11332
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...