Search found 52 matches

by Clemens
1 month ago
Forum: API
Topic: Python API error message
Replies: 2
Views: 367

Re: Python API error message

Pei Huang, The PKG installer on macOS allows to add the GAMS system directory to the PATH variable when a Terminal is opened. You might want to double-check its content using echo $PATH , but since you are able to call gams and gamslib, I guess that this is set up correctly. If you run the python in...
by Clemens
3 months ago
Forum: API
Topic: unhashable type: 'GamsSetRecord'
Replies: 2
Views: 321

Re: unhashable type: 'GamsSetRecord'

Looks like you are trying to use your dictionary qta with GamsSetRecords instead of keys. So you most likely want to do qta[(j.key(0),k.key(0))] instead of qta[(j,k)]

Best,
Clemens
by Clemens
1 year ago
Forum: API
Topic: Matrix to GDX from Python
Replies: 3
Views: 1174

Re: Matrix to GDX from Python

I can not say anything about csr_matrix in particular, but if possible, you can skip the zeros of any sparse matrix representation when writing to an instance of GamsParameter. Filling data using the Object-oriented Python API always works record based by calling my_symbol.add_record([key1, key2,......
by Clemens
1 year ago
Forum: API
Topic: Matrix to GDX from Python
Replies: 3
Views: 1174

Re: Matrix to GDX from Python

Hi, You can represent the matrix as a 2-dimensional GAMS parameter using the following code: from gams import * A=[[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.], [0., 0., 0., 1., 0.], [0., 0., 0., 0., 1.]] ws = GamsWorkspace(".") db = ws.add_database('data') mat = db.add_parameter...
by Clemens
1 year ago
Forum: API
Topic: Python 3.7
Replies: 1
Views: 1435

Re: Python 3.7

Renger, First of all we need to distinguish between the use of the GAMS Python API and the GAMS Embedded Code Facility . While the GAMS Python API is provided for different version of Python, the Embedded Code Facility requires a Python 3.6 right now. The error message comes from the setup.py script...
by Clemens
1 year ago
Forum: API
Topic: GMSPython 3.7 and tkinter
Replies: 2
Views: 2237

Re: GMSPython 3.7 and tkinter

Hello, There is currently no time schedule for updates of the Python version that is shipped with GAMS. It is primarily meant to be used as a minimal Python interpreter for certain GAMS features, especially the Embedded Code Python Facility. If there is a need for specific Python configurations, a s...
by Clemens
1 year ago
Forum: API
Topic: Python API Exception Handling
Replies: 5
Views: 2269

Re: Python API Exception Handling

This is not possible right now. In order to get detailed information about an error it is required to have a look into the listing file or to examine the log output.

Best,
Clemens
by Clemens
1 year ago
Forum: API
Topic: Python API Exception Handling
Replies: 5
Views: 2269

Re: Python API Exception Handling

The log output can be captured by specifying the output argument in GamsJob.run() . The following code snipped shows how to get the log output redirected to stdout: from gams import * import sys if __name__ == "__main__": if len(sys.argv) > 1: ws = GamsWorkspace(system_directory = sys.argv[1]) else:...
by Clemens
1 year ago
Forum: API
Topic: Python API Exception Handling
Replies: 5
Views: 2269

Re: Python API Exception Handling

Hello, The GamsException itself as well as the GamsExceptionExecution do not give you detailed information about the cause of an error. You can use the GamsException.get_rc() call in order to get the return code of GAMS which tells you what kind of problem occurred. See the documentation for possibl...
by Clemens
2 years ago
Forum: API
Topic: Reusing a model instance in different function calls
Replies: 6
Views: 2753

Re: Reusing a model instance in different function calls

Bruno, Sorry for the delay. It seems to me that you did solve your original problem where you did the mi.instantiate call multiple times. So from a GAMS/Python perspective the code looks actually correct to me. The new problem that arises now is that you also want to do some calculations in MatLab "...