Aggregate Parameter Indices
Posted: Tue Jun 26, 2018 10:15 pm
Hi all,
I have to use one parameter to store the following information: n variables, each variable can take Sn values. I have a toy example, 3 variables and each of them can take 1 or 2. The desired outcome should be like this:
It can be easily achieved in the following way:
Note that here I used three indices s1 s2 s3 to express. Then I wonder if there is a way to only use one index, say s /1*8/, to achieve this. Then the desired outcome would be like the following (here I express it like a table for convenience, but I actually want a parameter)
It is a toy example though but I can use the idea to express more complicated instance like 21 variables and each of them can have 10 or more possible values. Anyone can give a comment on this is highly appreciated!
Best,
Gabriel
I have to use one parameter to store the following information: n variables, each variable can take Sn values. I have a toy example, 3 variables and each of them can take 1 or 2. The desired outcome should be like this:
Code: Select all
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2
Code: Select all
Set
s /1*8/
s1 /1*2/
s2 /1*2/
s3 /1*2/
j /1*3/
Parameter a(j,s1,s2,s3)
loop(s1,
a('1',s1,s2,s3) = ord(s1);
);
loop(s2,
a('2',s1,s2,s3) = ord(s2);
);
loop(s3,
a('3',s1,s2,s3) = ord(s3);
);
display a;
Code: Select all
Parameter a(j, s)
j1 j2 j3
s1 1 1 1
s2 1 1 2
s3 1 2 1
s4 1 2 2
s5 2 1 1
s6 2 1 2
s7 2 2 1
s8 2 2 2
Best,
Gabriel