Search found 34 matches

by Clemens
1 week ago
Forum: Tools
Topic: Select an element randomly from a multidimensional set
Replies: 3
Views: 67

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
1 month ago
Forum: API
Topic: GAMS PYTHON API - INTERFACE JUPYTER
Replies: 7
Views: 892

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

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

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
2 months ago
Forum: API
Topic: GAMS API Python
Replies: 7
Views: 1351

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

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
2 months ago
Forum: API
Topic: GAMS API Python
Replies: 7
Views: 1351

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
2 months ago
Forum: Tools
Topic: MySQL, GAMS and Unix
Replies: 3
Views: 179

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
by Clemens
2 months ago
Forum: Tools
Topic: MySQL, GAMS and Unix
Replies: 3
Views: 179

Re: MySQL, GAMS and Unix

Renger, Using Embedded Code is in my opinion a good idea. You save the extra Python file and you could do it without writing the CSV file. Something like this: parameter p(*,*); $onEmbeddedCode Python: import pandas as pd data = [('a', 'a', 2), ('a','b', 4), ('b', 'a', 1), ('b','b', 3)] df = pd.Data...
by Clemens
5 months ago
Forum: API
Topic: Embedded Python code - Import parameter with gams.get
Replies: 2
Views: 893

Re: Embedded Python code - Import parameter with gams.get

Luis, First of all, note that the assignment ParA = 5; happens during GAMS execution time and the $onEmbeddedCode/$offEmbeddedCode section is performaned during GAMS compilation time. That means that in the embedded code section, no value will be assigned to ParA . For more information about GAMS ex...