Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Reading Excel data in multidimensional sets

20 views
Skip to first unread message

Lothar Löwer

unread,
Oct 22, 2024, 9:19:10 AM10/22/24
to AMPL Modeling Language

So far, I am reading grid data – here bus data – from an excel file using "amplxl.dll".


mpc_bus_id mpc_bus_vm mpc_bus_va
1 1,038397407 -15,39782653
2 1,024624806 -7,919400831


The data is defined as:

param ntmc    >  0 default 1; # number of time steps e.g. 3

set TMC       = {1..ntmc};

set MPC_BUS_ID;

param mpc_bus_vm {MPC_BUS_ID}  default  0;

var v_bus_vm {tc in TMC, b in MPC_BUS_ID} default mpc_bus_vm[b];

param filename_GRID symbolic = "./DATA/GridData.xlsx";

table mpc_bus IN "amplxl" (filename_GRID) "mpc_bus": MPC_BUS_ID <- [mpc_bus_id], mpc_bus_vm;

tread table mpc_bus;

This approach works fine, even without knowing the number of buses in advance.

Now, I want to read several grid layouts, e.g. dealing about three time steps including grid modifications, which results into a different number of buses depending on the time step. So, “time step 1” must store e.g. 200 buses, “time step 2” 205 buses and the third time step “time step 3” maybe only 190 buses.

How can such data be arranged and read from Excel? Also accessing other data via, an multi-dimensional approach like

display v_bus_vm {tc in TMC, b in MPC_BUS_ID[tc]};

If possible, there shall be simply different Excel tables dealing with the different time steps. The content of these tables shall be as now (key-word “mpc_bus_id” in cell A1).

I tried an approach using a two-dimensional set

set MPC_BUS_ID{TMC};

but already failed trying to access the data from Excel.

Best regards,

Lothar    

AMPL Google Group

unread,
Oct 23, 2024, 7:31:56 PM10/23/24
to AMPL Modeling Language
Your question has been moved to our new user forum at discuss.ampl.com, and a response has been posted there. To see the response, use this link:

https://discuss.ampl.com/t/ampl-25060-reading-excel-data-in-multidimensional-sets/1957

To reply, click the red "Reply" button that follows the response. (Do not send an email reply to this message.)


--
Nicolau Santos

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2741456568-129547#}
On Tue, Oct 22, 2024 at 1:19 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:

So far, I am reading grid data - here bus data - from an excel file using "amplxl.dll".

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/5323a21e-e3ab-4434-91dc-b281174e1647n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages