Hello,
I am reading excel data using “amplxl.dll” and want to use it to setup several piecewise linear functions in AMPL. Is there a common procedure (best practice) to do this?
My excel data contains data like:
|id|trf_id|tap|value|
|1|1|0|1.4|
|2|1|11|1.0|
|3|1|27|0.8|
|4|2|10|1.5|
|5|2|15|1.75|
|6|2|20|2.0|
|7|2|25|2.25|
|8|2|30|3.0|
|9|2|35|3,75|
Here, “id” is simply an index to be able to read the data. There are several sampling points of different size (number) for two transformer (tr_id): Three sampling points for the 1st and six for the 2nd transformer. How can the slopes be calculated in AMPL? Is there a “generic internal function” which can do the job? Maybe defining and using several sets or sub-sets due to the diffenrt number of sampling points as well as minimum and maximum values for the tap values?
So far, I am stating using this code (not finished):
reset;
load amplxl.dll;
set ID default {};
param trf_id {ID} default 0;
param tap {ID} default 0;
param value {ID} default 0;
table trf_data IN “amplxl” “Testdata.xlsx” “Table1”: ID ← [id], trf_id, tap, value;
read table trf_data;
param max_id = max{i in ID} trf_id[i];
set id_new = {1… max_id};
param number_of_sampling_points{j in id_new} = sum{i in ID: trf_id[i]==j} 1;
…
Best regards,
Lothar