User Tools

Site Tools


gams:linearization_of_multi_dimensional_parameter

Linearization of multi dimensional parameter

I met one index-operation problem. I would like to map B(m)= A(i,j,k) + C(i,j,k) where m = i+4*(j-1)+ 8*(k-1) gives a unique mapping for (i,j,k) to m.

If i,j,k, and m are ordered sets such that the ord() operator works, one possibility of the 'linearization' of your matrices A and C could be formulated with a SUM to control the sets i,j,k. Note that the SUM consists of one addend only. The following program gives the details:

sets  i /1*5/
      j /1*4/
      k /1*8/
      m /1*160/;

parameter
      A(i,j,k)
      B(m)
      C(i,j,k);

A(i,j,k) = ord(i) + 10 * ord(j) + 100 * ord(k);
C(i,j,k) = 1000*ord(i) + 10000 * ord(j) + 100000 * ord(k);

B(m) = sum((i,j,k)$(ord(m)=(ord(i)+4*(ord(j)-1)+8*(ord(k)-1))),
          A(i,j,k) + C(i,j,k));

display A,C,B; 
gams/linearization_of_multi_dimensional_parameter.txt · Last modified: 2009/04/13 12:52 by support