Issue on assignment data in GAMS

Problems with syntax of GAMS
Post Reply
Rodrigue
User
User
Posts: 36
Joined: 6 years ago

Issue on assignment data in GAMS

Post by Rodrigue »

Hello everyone,

I wrote a CGE code in which I imported the SAM data from Excel spreadsheet. Look at the code below:

Code: Select all

Set
   u        'SAM entry' / agri, extra,  alim    ,indu,  utilities ,cons   ,trade,
   trans, serv,public,TAXDOM, TAXIMP, TAXEXP, trav_q, trav_nq,cap ,terre, r_nat,
   HH ,GOV, FNF, Bcen, Bcom, rdm, HH2 ,GOV2, FNF2, Bcen2,  Bcom2,rdm2, Mfi,
   Dep, CDom ,Cext, Res,  Ref, AV, Resext, AExt, VK/
   i(u)     'goods'     / agri, extra, alim,indu, utilities, cons, trade, trans, serv, public /
   h(u)     'factor'          / trav_q,trav_nq,cap, terre, r_nat /
   h_mob(h) 'mobile factor'   /    trav_q,trav_nq /
   h_imm(h) 'immobile factor' / cap, terre, r_nat /

    af(u)   'actifs financiers'    / Mfi,Dep,CDom ,Cext,Res,Ref,AV,Resext,AExt,VK /
    Agr(u)  'agents courants'     /HH   ,GOV,   FNF,    Bcen,   Bcom,   rdm /
    Ag(u)  'agents capital'     /HH2   ,GOV2,   FNF2,    Bcen,   Bcom2,   rdm2 /

    afd(af)     'actifs domestiques' /Mfi,  Dep, CDom ,  Res,    Ref,    AV,   VK/
    afe(af)     'actifs etrangers' / Cext, Resext, AExt/
    t        'time'            / 2015    /;

Alias (u,v), (i,j), (h,k), (af,afc),(ag,agc);

*for SAM data
    Parameter
    SAM(u,v)         'social accounting matrix'
    SAMGAP(u)        'gaps between row sums and column sums';


*data importation

$call gdxxrw.exe i=mat2.xlsx o=tran.gdx par=sam rng=CMR!b3:ap43 rdim=1 cdim=1

$gdxin tran.gdx
$load  sam
$gdxin


SAMGAP(u) = sum(v, SAM(u,v) - SAM(v,u));

display sam, SAMGAP;


*Now, I declared the following parameter 

parameter
Daf00(af, ag) ;

    Daf00(af, ag)   =  SAM(af, ag);
    
    Display Daf00;
    
*Actually, the set "af" has 10 elements and "ag" has 5 elements and all the entries (af, ag) are displayed in the SAM.

However, by displaying Daf00, I just count 7 components of "Af" and 5 components of "ag", which doesn't make any sense. I though the problem would rely on the set declaration but it doesn't seem the best way. Please look at the attachments for the entire code and help me to overcome this.

Best regards,

Rodrigue[attachment=1]BEAC 2.gms[/attachment]
    
Mat2.xlsx
(115.26 KiB) Downloaded 155 times
Attachments
BEAC 2.gms
(45.38 KiB) Downloaded 144 times
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: Issue on assignment data in GAMS

Post by GFA »

Dear Rodrigue,

That is because not all "af"-"Ag" combinations have data. For example: "AV" and "Resext" (elements of "af") only have data with the element "Bcen2" in SAM-parameter, but "Bcen2" is not in "Ag" subset so it is not included in Daf00-parameter (GAMS does not store zero values in parameters).

Hope this helps.

GFA
Rodrigue
User
User
Posts: 36
Joined: 6 years ago

Re: Issue on assignment data in GAMS

Post by Rodrigue »

Hi BFA,

Thank you very much for your reply. You are right. The problem were on "Bcen2" as element of the subset "af". I've missed the digit "2" while typing. It's okay now.

Cheers,
Rodrigue
Post Reply