AddRows: duplicate subscript, error in reading three dimensional table from excel

363 views
Skip to first unread message

Foroogh Abasian

unread,
Jul 23, 2015, 4:02:42 PM7/23/15
to AMPL Modeling Language
Hello,

I have a three dimensional table as follow:

ProcessOUT AllCapacity ENERGY_SW_MIX Chipped_Biomass Prepared_Biomass LM PAP HEAT EL CHR GAS BIOIL PLT ETNOL
SAW K1 0.15 0.15 0 0.7 0 0 0 0 0 0 0 0
TMP K2 0 0 0 0 0.9 0 0 0 0 0 0 0
ExPLT K3 0 0 0 0 0 0 0 0 0 0 0.9 0
PreProcess K4 0 0 0.85 0 0 0 0 0 0 0 0 0
CHP K6 0 0 0 0 0 0.217 0.145 0 0 0 0 0
CHP K7 0 0 0 0 0 0.202 0.162 0 0 0 0 0
CHP K8 0 0 0 0 0 0.141 0.169 0 0 0 0 0
CHP K9 0 0 0 0 0 0.129 0.183 0 0 0 0 0
BoilEL K6 0 0 0 0 0 0 0.187 0 0 0 0 0
BoilEL K7 0 0 0 0 0 0 0.187 0 0 0 0 0
BoilEL K8 0 0 0 0 0 0 0.187 0 0 0 0 0
BoilEL K9 0 0 0 0 0 0 0.187 0 0 0 0 0
BoilHT K7 0 0 0 0 0 0.713 0 0 0 0 0 0
ORC K6 0 0 0 0 0 0.485 0.111 0 0 0 0 0
ORC K7 0 0 0 0 0 0.521 0.12 0 0 0 0 0
ORC K8 0 0 0 0 0 0.541 0.115 0 0 0 0 0
ORC K9 0 0 0 0 0 0.555 0.118 0 0 0 0 0
ICE K6 0 0 0 0 0 0.103 0.126 0 0 0 0 0
ICE K7 0 0 0 0 0 0.09 0.192 0 0 0 0 0
ICE K8 0 0 0 0 0 0.09 0.187 0 0 0 0 0
ICE K9 0 0 0 0 0 0.87 0.212 0 0 0 0 0
PYR K10 0 0 0 0 0 0 0 0.1785 0.1785 0.643 0 0
PYR K11 0 0 0 0 0 0 0 0.1785 0.1785 0.643 0 0
PYR K12 0 0 0 0 0 0 0 0.1785 0.1785 0.643 0 0
PLLT K13 0 0 0 0 0 0 0 0 0 0 0.91 0
PLLT K14 0 0 0 0 0 0 0 0 0 0 0.91 0
PLLT K15 0 0 0 0 0 0 0 0 0 0 0.91 0
FER K16 0 0 0 0 0 0 0 0 0 0 0 0.28


Three sets are as Follow:
AllProcs={ "SAW", "TMP", 
"ExPLT", "PreProcess CHP", "BoilEL", 
"BoilHT", 
"ORC", 
"ICE", 
"PYR ", "PLLT", "FER"}

AllCapacity={
k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 k13 k14 k15 k16
};

PrmInt={
"ENERGY_SW_MIX", "Chipped_Biomass", "Prepared_Biomass", "LM", "PAP", "HEAT", "EL", "CHR", "GAS", "BIOIL", "PLT", "ETNOL"
}

i read the table as follow:

table ProcessOUT {i in AllProcs}
IN "ODBC" "C:\Users\foaba\Desktop\UL\ete2015\Project\NLtest.xlsx" :
         [j ~ AllCapacity],  {k in PIntEnd} <ProcessOUT[i,j,k] ~ (k)>;
read table ProcessOUT;


but i face with following error:

Error reading table ProcessOUT['SAW'] with table handler odbc:
AddRows: duplicate subscript ['K6']



please help me. what should i do?

victor.z...@gmail.com

unread,
Jul 24, 2015, 2:38:00 PM7/24/15
to am...@googlegroups.com
Keys must be unique, so you should probably specify both ProcessOUT and AllCapacity as key columns:

table ProcessOUT {i in AllProcs} ...:
         [j ~ ProcessOUT, k ~ AllCapacity], ...

HTH,
Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Foroogh Abasian

unread,
Jul 24, 2015, 3:09:59 PM7/24/15
to AMPL Modeling Language, victor.z...@gmail.com
Thanks, i did what you said as follow:

table ProcessOUT {k in PIntEnd} IN "ODBC" ".....NLtest.xlsx":
 [i ~ ProcessOUT, j ~ AllCapacity] <ProcessOUT[i,j,k]~(k)> ;
read table ProcessOUT;

 and i face with  new error:

Table ProcessOUT has no set_name and no pvnames.

Thank you so much for your help.

Foroogh Abasian

unread,
Jul 24, 2015, 5:04:00 PM7/24/15
to AMPL Modeling Language, fabas...@gmail.com
you are wite it solved, i wrote in this way:

table ProcessOUT IN "ODBC" ".....xlsx":
 [i ~ PrOUT, j ~ AllCapacity], {k in PIntEnd} <ProcessOUT[i,j,k]~ (k)> ;
read table ProcessOUT;


tank you so much for your help.
Reply all
Reply to author
Forward
0 new messages