Dear friends,
I have a multidimensional parameter with 4 sets and 1 value into a gdx file.
I would like to know how many rows do I have per each set r1,p1,r2 or p2.
The problem is that the file is too large and I cannot open the gdxviewer, and I don't know the different elements that I have in each set.
So, I'm looking for this kind of information (in the image is the sample):
for r1: a1 2, a2 1
for p1: xa0 2, xa2 1
for r2: a2 2, a1 1
for p2: yt5 1, yt3 1, yt1 1.
Maybe you can help me.
Thank you and all the best,
COUNT THE ELEMENTS INSIDE A SET
Re: COUNT THE ELEMENTS INSIDE A SET
This is easily achieved by the projection operator accessible via the option statement. See https://www.gams.com/latest/docs/UG_Opt ... ggregation for details. Here is the code for your example:
which results in the following display:
-Michael
Code: Select all
set r1,p1,r2,p2;
parameter d(r1<,p1<,r2<,p2<) /
a1.xa0.a2.yt5 6
a1.xa0.a2.yt3 5
a2.xa2.a1.yt1 7
/;
parameter cnt_r1(r1), cnt_p1(p1), cnt_r2(r2), cnt_p2(p2);
option cnt_r1<d, cnt_p1<d, cnt_r2<d, cnt_p2<d;
display cnt_r1, cnt_p1, cnt_r2, cnt_p2;
Code: Select all
---- 12 PARAMETER cnt_r1
a1 2.000, a2 1.000
---- 12 PARAMETER cnt_p1
xa0 2.000, xa2 1.000
---- 12 PARAMETER cnt_r2
a1 1.000, a2 2.000
---- 12 PARAMETER cnt_p2
yt5 1.000, yt3 1.000, yt1 1.000