Hello,
I have a text file (file.txt) in format:
M1 M2 M3
1 45.7256046374655 28.4062955882777 35.8474298744489
2 46.4275276498946 47.374679706601 32.9808478906229
3 46.1226020555142 22.4848278029251 43.1264515215413
4 45.1024313926292 34.8955821456699 40.7070988034582
5 44.6652808915011 31.1993941104196 41.4451205380671
6 45.514755530348 35.5824714998599 36.2780370857497
7 45.2545781813678 26.5073124093516 43.1065966659425
9 45.4537472012675 35.9457396335022 41.0270968689643
10 45.441471952754 21.0964683718102 40.2429333204404
...
There are 1000 rows and the first row with column names (these column names are elements of set S). I would like to read the data into a 1000x3 array in AMPL.
In my .dat file I have:
set S:= M1 M2 M3 ;
and in my .mod file:
param v {1..1000, S} >= 0;
read {i in 1..1000, j in S} v[i, j] <file.txt;
--------------------
I keep getting an error:
Error at _cmdno 1 executing "read" command
(file wdwr.mod, line 11, offset 201):
no data for set S
What is the proper syntax of the read command to read data from this file?
Best regards,
Artur