Page 1 of 1

Bad dimension error when using gdxxrw

Posted: Mon May 13, 2019 10:54 pm
by Sarah_Chamberland
Hi everyone,

I am having a "Symbol: ZIMSAM2 Bad dimension: 1" error when importing a parameter into GAMS from Excel. See the code below:

Code: Select all

$call gdxxrw input="C:\Users\zimb_pan.xlsx" output="C:\Users\zimb_pan_sam.gdx" par=ZIMSAM2 rng=Sheet1!A1:AI35 rdim=1 cdim=1;
AC refers to every single variable in the model and ACP is an Alias for AC.
I understand that the error comes from cDim = 1 because when I increase cdim to a value x, the error message changes to Bad dimension:x.
Yet I know that labels are defined at column 1... So I am confused.

I joined the Excel file as an attachment.

Any help is appreciated!


Re: Bad dimension error when using gdxxrw

Posted: Tue May 14, 2019 8:15 am
by Renger
Hi Sarah
It looks like you haven't defined AC yet. If I define the parameter PARAMETER ZIMSAM2(*, *) instead of PARAMETER ZIMSAM2(AC,ACP), the import runs fine.
Did you define/import AC before you want to import ZIMSAM2?
Hope this helps

Re: Bad dimension error when using gdxxrw

Posted: Tue May 14, 2019 3:51 pm
by Sarah_Chamberland
Hi Renger,
Thank you for this prompt reply. I did define AC previously, as well as ACP as an alias for AC. Furthermore, I can import all my data correctly if I enter it manually in the following way:

Code: Select all


              AAGEX       AAGFO       AAGOT       AMINE       ANAFO       ANAOI

CAGEX                                                       341.998    1135.653
CAGFO                                                       243.014
CAGOT         6.304                 244.130                 827.023     142.909
CMINE                                            91.141      39.080    1268.605
This is a subsection of the data, but it would be too long to enter all of it manually, hence my interest in uploading the data from Excel.

So my question is the following: I can write ZIMSAM2(AC, ACP) in a table and GAMS will recognize the parameter ZIMSAM2, as well as AC and ACP, but I don't understand why GAMS won't do the same if I import the data from Excel?

Thanks again!


Re: Bad dimension error when using gdxxrw

Posted: Tue Jun 04, 2019 6:13 pm
by GFA
Hi Sarah,

You don't need semicolons after "$"-statements.
Here GAMS gives the error: "ZIMSAM2 Bad dimension: 1;"
Drop the semicolon in "cdim=1;" and it should work fine.