Getting arc data into Excel table format

43 views
Skip to first unread message

Blair Lane

unread,
Sep 22, 2021, 7:54:34 PM9/22/21
to am...@googlegroups.com, sup...@ampl.com
Hello,

I have been trying to get the following x and Limit parameter data (the last chunk of data in the screenshot) in a readable Excel table format, but I am running into errors (the screenshot of the AMPLIDE console attached). The issue at hand seems to be that the x and Limit parameters are parameters of the arc variables made by linking variables in the bus_node set, and I am unsure how to input for example, “b1 b2” x and limit data into an Excel table and have AMPL (amplxl.dll) read it the same way it is read when hardcoded like it is in the OPF3bus3L.dat file (the screenshot attached). I tried making two columns called “bus_node” in the Excel but it wouldn’t run because there would be two columns of the same name….

For reference I’ve attached the .mod, .dat, and .xlsx files I am trying to work with. There are two .dat files: the OPF3bus3L.dat file is the hardcoded/AMPL-only version, and the 3BusExcelFull.dat file reads the 3_Bus_Data.xlsx tables that have the same data as the OPF3bus3L.dat file, which is returning errors because it cannot read the table with the x and Limit params/
3_Bus_Data.xlsx
3BusExcelFull.dat
OPF3bus3L.dat
OPF3bus3.mod
Screen Shot 2021-09-22 at 4.38.03 PM.png
Screen Shot 2021-09-22 at 4.31.59 PM.png

AMPL Google Group

unread,
Sep 23, 2021, 1:04:55 PM9/23/21
to AMPL Modeling Language, sup...@ampl.com
Set up the "Connection" range in your spreadsheet like this:

18da6280ad63584da7e7d8dc26ee8b84.png

Then write your table statement as follows:

table xTab IN "amplxl" "3_Bus_Data.xlsx" "Connection":
       [BB_FROM, BB_TO], x, Limit;

The column headings "BB_FROM" and "BB_TO" do not need to be the names of sets in the AMPL model. You can give them any names you want, as long as the same names appear as shown in the corresponding table statement.

Currently you use an AMPL "set BBCONNECT := . . ." statement to specify the members of the set BBCONNECT. But if you prefer, you can instead read the members of set BBCONNECT from the same spreadsheet range that you are using for x and LImit, by writing your table statement like this:

table xTab IN "amplxl" "3_Bus_Data.xlsx" "Connection":
       BBCONNECT <- [BB_FROM, BB_TO], x, Limit;

In the AMPL book, search on "multidimensional" in Chapter 10 for more information about reading 2-dimensional parameters (like x and Limit) using table statements.


--
Robert Fourer
am...@googlegroups.com
{#HS:1639101703-106389#}
Thanks in advance for the help,
Christian

Reply all
Reply to author
Forward
0 new messages