Error reading table precio with table handler amplxl:

Hello. Hope you all doing well.

Im using Excel to read data in AMPL and Im trying to read this next table that I called “precio” but im not being able to put the correct comands to make this possible.

That table depends of g and t01 …t024 (T) and those parameters are used in other different tables

however, g and T in other tables have unique data that is not the same from the table “precio”.

but all of the information has some correlation

hope someone can help :slight_smile: thx

Hi @Laura_Rodriguez

I didn’t fully understand the issue with g and T.
If possible, I’ll ask you to post a minimal working example of the issues you are facing.
Otherwise please post the contents of one of the other tables that is also indexed by g and T, the AMPL declarations of those sets and the corresponding interpretation of those sets in your model, as you might not be using the g and T sets but only some subsets of them.

Hi,
table 1

The first table depends on the parameters T and D, where T stands for time and D stands for demand. The second table also includes the parameter G, which stands for generator.

For example:

  • At time t01, producing from generator g1 costs 13.32. (from first table i ever shared)
  • The same generator, g1, has a certain power capacity (as shown in Table 2).
  • At the same time t01, demand D1 requires 67.48173 units (as shown in Table 1).

but im not being able to read the first table i ever shared

so far im using this writing to read table 1 and table 2:

.run:

table Tiempo IN “amplxl” “DTU-Perfiles1.xlsx” “periods”:

T ← [T];

read table Tiempo;

#------------------------------------------------------------------------------

table Generacion IN “amplxl” “dtu.xlsx” “gen”:

[G] IN, pmax,pmin;

table Demandas IN “amplxl” “dtu.xlsx” “dem”:

[D] IN, dem;

table Perfil_Demandas IN “amplxl” “DTU-Perfiles1.xlsx” “dem” “2D”:

[D, T], prfl_dem;

table GeneracionCX IN “amplxl” “dtu.xlsx” “gen”:

Gn ← [G, B];

table DemandaCX IN “amplxl” “dtu.xlsx” “dem”:

Dn ← [D, B];

.mod:

set T ordered ; # periodos

set B default {} ; # barras

set G ; # generadores
set D ; # demandas

set Gn within {G, B} ; # conexion de generadores
set Dn within {D, B} ; # conexion de demandas

set L dimen 2;
set FROM = setof {(i,j) in L} j;
set TO = setof {(i,j) in L} i;

----------------------------------------------------

param po {G, T} >= 0 ; # precio de oferta
param pmin {G} >= 0 ; # potencia minima de generacion de cada G
param pmax {G} >= 0 ; # capacidad ofertada
param fmax {L} >= 0 ; # capacidad por linea
param xlin {L} >= 0 ; # reactancia de la linea

param dem {D} >= 0 ; # potencia consumida
param prfl_dem {D, T} >= 0 ; # perfil de demanda / dem

table 2

Hi @Laura_Rodriguez

Thank you for the provided information!

To load data from a table with one indexing set you just need the table declaration and the read command.
However, when you load data from a table with more than one indexing set, the data from the indexing sets must be loaded before.

In the case of table precio you have two indexing sets, G and T, so you first need to load the data for G and T and only than you can read table precio

table Tiempo IN "amplxl" "dtu.xlsx" "periods":
	T <- [T];

table Generacion IN "amplxl" "dtu.xlsx" "gen":
	G <- [G], pmax, pmin;

table precio IN "amplxl" "dtu.xlsx" "2D":
	[G, T], po;

read table Tiempo;
read table Generacion;
read table precio;

As precio is a 2D table you need to put the name G on top of the column. From the table declaration amplxl will deduce that the header of the table has elements of T and that the parameter that you are reading is po.

A quick read to this post might help understanding how amplxl and 2D tables work. amplxl documentation is available here.

Sample files attached example.zip (9.4 KB) with minor changes but also loading the prfl data.