The "read" statement syntax doesn't work to read members into a set. What you can do instead is to read them into parameters and then create the set. For example,
param ns = 8;
param nb integer >= 1;
param b1 {1..nb} in 1..ns;
param b2 {1..nb} in 1..ns;
read nb, {j in 1..nb} (b1[j],b2[j]) <test.txt;
set b = setof {j in 1..nb} (b1[j],b2[j]);
Note that you need to put one more number into your input, giving the number of members of b to be read from test.txt -- unless this number is always equal to ns, in which case you can just use ns instead of nb.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Zheng
Sent: Sunday, May 15, 2011 10:43 PM
To: am...@googlegroups.com
Subject: [AMPL 4634] Read Sets from txt file