Is it possible to create a set from a parameter?

I am reading parameter from an excel-file using amplxl.dll. Partly, the parameter data (columns in excel) contain empty data.

set MPC_BRA_ID default {};
param bra_type{MPC_BRA_ID} symbolic default ‘’;
param bra_tap_pos{MPC_BRA_ID}; # no default here so far
table tmp_table IN “amplxl” (filename_GRID) “mpc_bra”: MPC_BRA_ID ← [mpc_bra_id], bra_type, bra_tap_pos;
read table tmp_table;

As a result, let’s assume five branches, MPC_BRA_ID is a set containing five values. Also bra_type contains five values since every branch has a type information like “line” or “transformer”. Having a look at bra_tap_position, some indices are missing because a value is only defined for a few transformer within the excel file. A lot of cells are simply empty.

e.g.
display bra_tap_pos;
bra_tap_pos [*] =
3 0
5 2
;

I want to create a new set dealing with the branches, which have a tap-position information.

The result shall be: new_set = {3, 5};

Unfortunatelly, “0” is a valid information too. Thus, replacing the empty cell by “0” would mean that the transformer has tap position data.
Evaluating the command

set new_set = {i in MPC_BRA_ID: bra_tap_pos[i]};

contains only the indices which are not “0”.

Is there any possibility to create such a set, without using a default value outside a realistic range (param bra_tap_pos{MPC_BRA_ID} default -9999)?

Best regards,
Lothar

There’s no easy way to define the set of “all bra_tap_pos[i] that have received a value so far.” Using default -9999 is a clean approach, however.

test.txt (446 Bytes)
test.xlsx (8.3 KB)

Hi @Lothar_Lower ,

Just a remark, it could be more convenient to use amplpy to interact with tables or spreadsheets in python rather than read/update them in ampl. Data manipulation is usually easier in python

Hi Robert & Marcos,
Thank’s for the reply. So I will read the data using a default value of -9999 and create the set based on another set excluding all members which have a bra_tap_pos of this value.
Best regards,
Lothar