From multi-dimensional set table to simple set table

Problems with syntax of GAMS
Post Reply
lpedauga
User
User
Posts: 1
Joined: 2 years ago

From multi-dimensional set table to simple set table

Post by lpedauga »

Hi,

I want to create a simple set table, from a multi-dimensional set table.
I am trying to get it by mapping, but I only get some values.
What I am doing wrong?
Thanks.
Below my code:
*****************************************************************************************
Set
i Table ixj /i1*i6 /
ctry Country Codes (ISO 3166 alpha-2) /ctry1*ctry2/
CpaxNace /cpa1*cpa3, nace1*nace3/
Cpa(CpaxNace) /cpa1*cpa3/
Nace(CpaxNace) /nace1*nace3/

map(ctry,CPAxNACE,i) / (ctry1.cpa1,ctry1.nace1).i1
(ctry1.cpa2,ctry1.nace2).i2
(ctry1.cpa3,ctry1.nace3).i3
(ctry2.cpa1,ctry1.nace1).i4
(ctry2.cpa2,ctry1.nace2).i5
(ctry2.cpa3,ctry1.nace3).i6 /

Alias(i,j);

Table SAM(ctry,cpa,ctry,nace) "Social Accounting Matrix"
ctry1.nace1 ctry1.nace2 ctry1.nace3 ctry2.nace1 ctry2.nace2 ctry2.nace3
ctry1.cpa1 1 2 3 4 5 6
ctry1.cpa2 7 8 9 10 11 12
ctry1.cpa3 13 14 15 16 17 18
ctry2.cpa1 19 20 21 22 23 24
ctry2.cpa2 25 26 27 28 29 30
ctry2.cpa3 31 32 33 34 35 36

;
display SAM;

Parameter Tij(i,j)
;

Tij(i,j) = sum((ctry,cpa,nace)$((map(ctry,cpa,i) and map(ctry,nace,j))),SAM(ctry,cpa,ctry,nace) ) ;
display Tij;

The result that I get:
*****************************************************************************************
---- 33 PARAMETER Tij

i1 i2 i3 i4 i5 i6

i1 1.000 2.000 3.000
i2 7.000 8.000 9.000
i3 13.000 14.000 15.000
i4 22.000 23.000 24.000
i5 28.000 29.000 30.000
i6 34.000 35.000 36.000
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: From multi-dimensional set table to simple set table

Post by GFA »

Hi lpedauga,

Didn't test it but looking at your code there seems to be an error in you mapping. In the SAM you refer to "ctry2.nace1" "ctry2.nace2" and "ctry2.nace3" however there is no mapping in "map", I guess the numbers in red (see below) have to be a 2?

Regards
GFA


map(ctry,CPAxNACE,i) / (ctry1.cpa1,ctry1.nace1).i1
(ctry1.cpa2,ctry1.nace2).i2
(ctry1.cpa3,ctry1.nace3).i3
(ctry2.cpa1,ctry1.nace1).i4
(ctry2.cpa2,ctry1.nace2).i5
(ctry2.cpa3,ctry1.nace3).i6 /
Post Reply