I tried a construct that looks like the following code:
Basically I take the intersection of the two sets and create a mapping between the two base sets. Unfortunately, the sets are big:
n_cell5m = card(cell5m);
n_cell5m_spam = card(cell5m_spam);
display n_cell5m, n_cell5m_spam;
---- 23 PARAMETER n_cell5m = 2294094.000
as a result expression (1) takes an extraordinary long time to execute:
|---- 26 Assignment cellmap 2436.954 2437.032 SECS 383 Mb 806839|
I believe the sameas function is just not properly implemented in GAMS. This performance is really not what one would expect.
Of course we can work around this:
intersect(u) = cell5m(u)*cell5m_spam(u);
cellmap(cell5m(intersect),cell5m_spam(intersect)) = yes;
This now executes in much less than a second:
|---- 27 Assignment intersect 0.187 0.203 SECS 333 Mb 806839 |
---- 33 Assignment cellmap 0.203 0.406 SECS 358 Mb 806839
Note that we had to change the declarations of the sets a little bit, in order to get this passed the domain checking of GAMS.