I have a set:
Code: Select all
Set i /1*3/;
set j /1*3/;
Set a(i,j) /1.2 2.3 1.3/;
I wanted to use
Code: Select all
ord(a)
Code: Select all
Set i /1*3/;
set j /1*3/;
Set a(i,j) /1.2 2.3 1.3/;
Code: Select all
ord(a)
Code: Select all
Set i /1*3/;
set j /1*3/;
Set a(i,j) /1.2,2.3,1.3/;
set b(i,j);
b(i,j)$(ord(i) = 3 and ord(j) = 1) = yes;
That's a good idea.Freddy wrote: ↑4 years ago How about this?Code: Select all
Set i /1*3/; set j /1*3/; Set a(i,j) /1.2,2.3,1.3/; set b(i,j); b(i,j)$(ord(i) = 3 and ord(j) = 1) = yes;
Code: Select all
Set i /1*3/;
set j /1*3/;
Set a(i,j) /1.2,2.3,1.3/;
set b(i,j);
set c/1*3/;
loop (c,
b(i,j) $ (ord(a(i,j))=c) = yes ;
);
Code: Select all
Set i /1*3/;
set j /1*3/;
Set a(i,j) /1.2, 2.3, 1.3/;
parameter ordOfA(i,j);
scalar cnt / 0 /;
loop{a(i,j),
cnt = cnt + 1;
ordOfA(i,j) = cnt;
};
display a, ordOfA;
Thank you. It works.dirkse wrote: ↑4 years ago You can compute your ord value yourself with a loop:
Be careful how you use this, though. If you want to do something for the tuples in a(i,j), then it is best to do that directly, not by a loop over something else (say, a loop from 1 to card(a)) and some code to do something for the (i,j) tuples corresponding to the loop variable. The latter approach may work, but it will not be efficient as the data gets large.Code: Select all
Set i /1*3/; set j /1*3/; Set a(i,j) /1.2, 2.3, 1.3/; parameter ordOfA(i,j); scalar cnt / 0 /; loop{a(i,j), cnt = cnt + 1; ordOfA(i,j) = cnt; }; display a, ordOfA;
-Steve