Search found 59 matches
- 5 years ago
- Forum: API
- Topic: Python API: Solving two models one after the other
- Replies: 1
- Views: 3477
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...
- 5 years ago
- Forum: API
- Topic: Python Embedded in Gams - Import Python Package
- Replies: 13
- Views: 15845
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...
- 5 years ago
- Forum: API
- Topic: Python Embedded in Gams - Import Python Package
- Replies: 13
- Views: 15845
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: 15845
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: 15845
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: 4201
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: 9344
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: 9344
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: 9344
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: 10097
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...