## Multidimensional set in MPSGE

Problems with syntax of GAMS
akingCCC
User
Posts: 2
Joined: 1 year ago

### Multidimensional set in MPSGE

I've got a lot of situations where I have

rto_nt("rmk1",r) = rto("rmk",r);
rto_nt("b_s1",r) = rto("b_s",r);
...

so I need a 1-to-1 mapping between rmk and rmk1, b_s and b_s1, etc (a lot like "Indice from Indice" posted by Manu123 a couple of months ago). In my general code, I can get

rto_nt(agr_nt,r) = sum(agr\$agr_map(agr,agr_nt),rto(agr,r));

to work, where I have defined the sets

agr(g) "Agricultural sectors" /oap, rmk, b_s, hor, frs/
agr_nt(g) "Agricultural new technology sectors" /rmk1, b_s1/
agr_map(agr, agr_nt) "Agricultural matched new technology sectors" /rmk.rmk1, b_s.b_s1/

But I can't get anything equivalent to work in my MPSGE code. I'm trying:

\$prod:land_nt(g,r)\$(agr_nt(g) and active(g,r,"0"))
o:ps(f,g,r)\$(sameas(f,"lnd")) q:vffm(f,g,r)
i:ps(f,agr,r)\$(agr_map(agr,agr_nt(g)) and sameas(f,"lnd")) q:vffm(f,g,r)

and I've also tried:

\$prod:land_nt(g,r)\$(agr_nt(g) and active(g,r,"0"))
o:ps(f,g,r)\$(sameas(f,"lnd")) q:vffm(f,g,r)
i:(sum((agr\$(agr_map(agr,g))),ps("lnd",agr,r))) q:vffm("lnd",g,r)

to replace two blocks that look like:

\$prod:land_nt(g,r)\$(sameas(g,"b_s1") and active(g,r,"0"))
o:ps(f,g,r)\$(sameas(f,"lnd") and sameas(g,"b_s1")) q:vffm(f,g,r)
i:ps(f,"b_s",r)\$(sameas(f,"lnd")) q:vffm(f,g,r)
akingCCC
User
Posts: 2
Joined: 1 year ago

### Re: Multidimensional set in MPSGE

I've figured it out:

\$prod:land_nt(agr_nt,r)\$active(agr_nt,r,"0")
o:pfs(f,agr_nt,r)\$(sameas(f,"lnd")) q:vffm(f,agr_nt,r)
i:pfs(f,agr,r)\$(agr_map(agr,agr_nt) and sameas(f,"lnd")) q:vffm(f,agr_nt,r)

The trick was to replace the general set g with the set agr_nt, instead of doing it in the conditional statement. Note that my declaration of land_nt couldn't change though:
\$sectors:
land_nt(g,r)\$(agr_nt(g) and active(g,r,"0"))