reading 4 dimensional data

32 views
Skip to first unread message

ezzati...@gmail.com

unread,
Aug 14, 2017, 8:27:18 AM8/14/17
to AMPL Modeling Language
Hi,

I want to read an array with a 4 dimensional, i can read it into AMPL but seems to be something is wrong (only 2 of 24 rows are displayed), I would appreciate somebody can give me notes.

I attach the table as well.


table volume IN 'tableproxy' 'odbc' "C:\Users\ampl02\Test_AMPL2017\BELT\TstDat.xlsx" 'volume': 
[i~harNode, j ~t_A,h ~resTyp], {s in species}<volume[i,j,h,s]~(s)>;
read table volume;
display volume;

volume :=
1 1 fuel aspen   25
1 1 fuel maple   12
;


Thanks
TstDat .xlsx

Robert Fourer

unread,
Aug 14, 2017, 3:36:30 PM8/14/17
to am...@googlegroups.com
When reading table "volume" we see the message

Error reading table volume2 with table handler odbc:
AddRows: duplicate subscript [1,1,'fuel']

This error occurs when reading the second line of the table in the Excel file:

harNode t_A resTyp aspen maple
1 1 fuel 25 12
1 1 fuel 1 2

The second line contains values for volume[1,1,'fuel','aspen'] and volume[1,1,'fuel','maple'], but these values were already read from the first line. In general, each triple of values in the first 3 columns must be unique within the table.

Bob Fourer
am...@googlegroups.com

=======

ezzati...@gmail.com

unread,
Aug 15, 2017, 10:44:21 AM8/15/17
to AMPL Modeling Language, 4...@ampl.com
Hi Bob,

You are very right: but each one of this identical triple has value which is different. Could you please modify my example (i.e., excel data) to be recognized by the AMPL as different triple?


I would appreciate for your time and quick response.

Sattar

Robert Fourer

unread,
Aug 16, 2017, 11:34:41 AM8/16/17
to am...@googlegroups.com
It's clear the problem is that volume[1,1,'fuel','aspen'] can't have the value 25 and also the value 1. However the solution depends on knowing what you are actually trying to say in your model, so I can't give you the solution.

I can say however that it is likely you will need to adjust the model as well as the spreadsheet table. Since it appears that you have exactly two values for every combination of subscripts (like [1,1,'fuel','aspen']), perhaps what you need are two different params defined in your model. Then you would need to split your spreadsheet table into two tables, one with all the odd-numbered lines and one with all the even-numbered lines.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages