Put file, sets, loops

Problems with syntax of GAMS
Post Reply
GAMSisGREAT
User
User
Posts: 11
Joined: 6 years ago

Put file, sets, loops

Post by GAMSisGREAT »

I am trying to combine the use of put files, sets and loops in a specific way. I have a set, dynamic subsets that make up the power set of the full set, I have loops in loops, and some parameter output. It looks roughly like this, I'll use a three member set as an example:
Sets
$onempty
i /A,B,C/
z(i) / /
;
Alias (i,ii);
Alias (z,zz);
Parameters
*this parameter takes a 1 or 0 for certain conditions
para(z,i)
;
My loops look roughly like this:
loop(i,
* picks up a member of set i
z(i)=yes;
loop(ii$(not z(ii)),
* loops over the other members of set i
para(z,i)= some output;
);
z(i)=no;
);
I now want the put file to give me (automatically) something that looks like what I note down below. The first column would be the power set with sets z(i) that is generated via the loops. The next columns are the elements of the large set i. And associated with each subset z(i) and each element of set i is the parameter para(z,i). Output in the matrix below is just an example.

Put file example:

Sets A B C
A 1 3 2
B 4 3 2
C 1 1 2
AB 0 9 12
BC 3 4 3
AC 4 4 4
ABC 3 4 3

I have been breaking my head over this and would appreciate any help, or pointers to similar exercises. Thanks so much!
Post Reply