Dear all,
I am trying to affect values of several continents to each country of that continent in a Gams program. Since I might not be clear I created a small example to illustrate my problem which you can copy below the Example section of this post.
I set up 90 countries and 3 continents (a,b,c). Let’s say I have growth rates forecasts over several continents and I want to affect this value to each country of that continent without having to do it manually. In the exampe below this operation is represented with parameter test2(ctry). My problem is that if some countries are missing (1130) I get a value of 1 for these countries where I would like a 0 value see (Display section). Do you have any idea of what is happening here? Maybe I used the wrong trick?
Thanks in advance for your help. It is deeply appreciated!
Jon
*=============================================================================
*EXAMPLE
*=============================================================================
sets
reg/a,b,c/
reg2(reg)/b,c/
ctry/1*90/
regtoctry(reg,ctry)
/
a.(110)
b.(3160)
c.(61*90)
/
;
display regtoctry;
parameter test(reg)
/ a 33
b 66
c 99
/;
parameter test0(ctry)
/ 130 1
3160 2
61*90 3
/;
display test0;
*!Sum of country values for each region
parameter test1(reg);
test1(reg)=sum(regtoctry(reg,ctry), test0(ctry));
display test1;
*!Apply regional values to each country of the region
parameter test2(ctry);
test2(ctry)=prod(regtoctry(reg,ctry),test(reg));
display test2;
$ontext
parameter test3 (reg2);
test3(reg2)=sum(regtoctry(reg2,ctry),test0(ctry));
*display test3;
parameter test4(reg);
test4(“a”)=sum(reg2, test(reg2));
*display test4;
set
notregtoctry(reg,ctry)
;
notregtoctry(reg,ctry)=not regtoctry(reg,ctry);
display notregtoctry;
$offtext
*============================ End Of File ======================================
*=============================================================================
*DISPLAY
*=============================================================================
$ontext
---- 59 PARAMETER test2
1 33.000, 2 33.000, 3 33.000, 4 33.000, 5 33.000, 6 33.000, 7 33.000, 8 33.000
9 33.000, 10 33.000, 11 1.000, 12 1.000, 13 1.000, 14 1.000, 15 1.000, 16 1.000
17 1.000, 18 1.000, 19 1.000, 20 1.000, 21 1.000, 22 1.000, 23 1.000, 24 1.000
25 1.000, 26 1.000, 27 1.000, 28 1.000, 29 1.000, 30 1.000, 31 66.000, 32 66.000
33 66.000, 34 66.000, 35 66.000, 36 66.000, 37 66.000, 38 66.000, 39 66.000, 40 66.000
41 66.000, 42 66.000, 43 66.000, 44 66.000, 45 66.000, 46 66.000, 47 66.000, 48 66.000
49 66.000, 50 66.000, 51 66.000, 52 66.000, 53 66.000, 54 66.000, 55 66.000, 56 66.000
57 66.000, 58 66.000, 59 66.000, 60 66.000, 61 99.000, 62 99.000, 63 99.000, 64 99.000
65 99.000, 66 99.000, 67 99.000, 68 99.000, 69 99.000, 70 99.000, 71 99.000, 72 99.000
73 99.000, 74 99.000, 75 99.000, 76 99.000, 77 99.000, 78 99.000, 79 99.000, 80 99.000
81 99.000, 82 99.000, 83 99.000, 84 99.000, 85 99.000, 86 99.000, 87 99.000, 88 99.000
89 99.000, 90 99.000
$offtext
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.