GAMS MIRO setup

Questions on GAMS MIRO
Post Reply
Danrome
User
User
Posts: 5
Joined: 5 years ago

GAMS MIRO setup

Post by Danrome »

Dear all,
I'm trying to learn MIRO environment. I have a question on how to proper import parameters on the application.
I'm taking the Cameroon CGE (camcge.gms) model from GAMS library as an example.
I have first parameter declaration where first i wrote the command "$onExternalInput":

$offIDCProtect
$onExternalInput
Parameter
delta(i) 'Armington function share parameter (unity)'
ac(i) 'Armington function shift parameter (unity)'
rhoc(i) 'Armington function exponent (unity)'
rhot(i) 'cet function exponent (unity)'
at(i) 'cet function shift parameter (unity)'
gamma(i) 'cet function share parameter (unity)'
eta(i) 'export demand elasticity (unity)'
ad(i) 'production function shift parameter (unity)'
cles(i) 'private consumption shares (unity)'
gles(i) 'government consumption shares (unity)'
depr(i) 'depreciation rates (unity)'
dstr(i) 'ratio of inventory investment to gross output (unity)'
kio(i) 'shares of investment by sector of destination (unity)'
tm0(i) 'tariff rates (unity)'
te(i) 'export duty rates (unity)'
itax(i) 'indirect tax rates (unity)'
alphl(lc,i) 'labor share parameter in production function (unity)'
........
........

(I'm not writing all the parameters, scalars and tables to not writing too long.)
Then i have parameter initialization where at the end i wrote the command "$offExternalInput" :

depr(i) = zz("depr",i);
rhoc(i) = (1/zz("rhoc",i)) - 1;
rhot(i) = (1/zz("rhot",i)) + 1;
eta(i) = zz("eta",i);
tm0(i) = zz("tm0",i);
te(i) = 0;
*te(i) = zz("te",i);
itax(i) = zz("itax",i);
cles(i) = zz("cles",i);
gles(i) = zz("gles",i);
kio(i) = zz("kio",i);
dstr(i) = zz("dstr",i);
xllb(i,lc) = xle(i,lc) + (1 - sign(xle(i,lc)));
m0(i) = zz("m0",i);
it(i) = yes$m0(i);
in(i) = not it(i);
e0(i) = zz("e0",i);
xd0(i) = zz("xd0",i);
k0(i) = zz("k",i);
pd0(i) = zz("pd0",i);
pm0(i) = pd0(i);
pe0(i) = pd0(i);
pwm0(i) = pm0(i)/((1 + tm0(i))*er);
pwe0(i) = pe0(i)/((1 + te(i))*er);
pva0(i) = pd0(i) - sum(j, io(j,i)*pd0(j)) - itax(i);
xxd0(i) = xd0(i) - e0(i);
dst0(i) = zz("dst",i);
id0(i) = zz("id",i);
ls0(lc) = sum(i, xle(i,lc));
.......
......
.......
$offExternalInput

Now when i run the MIRO base mode i get the error:
"External input symbol(s) without data initialization:"
****
delta
ac
rhoc
rhot
at
gamma
eta
ad
cles
gles
depr
dstr
kio
tm0
te
itax
........
.......
I think the problem is that some parameters are first declared and then initialized but probably all the parameters need to be declared and then initialized at the same time for MIRO.....
Is there any way to overcome this problem or should i modify the code in a proper way?
thank you very much for your help
Freddy
User
User
Posts: 16
Joined: 5 years ago

Re: GAMS MIRO setup

Post by Freddy »

Danrome,

between $onExternalInput and $offExternalInput you declare GAMS symbols to be read by MIRO. The symbols you declared in the camcge.gms model are parameters that are calculated by other parameters. This means that the values read by MIRO would be overwritten. So it makes no sense to declare them as external input symbols, and GAMS warns you about this with an error message.
You can declare them as $onExternalOutput instead, if you want to see their values in MIRO after your model was solved. As input, you should declare symbols that hold raw data such as er, io(i,j) etc. as external input symbols.

Hope this helps.

Best regards,
Freddy
Danrome
User
User
Posts: 5
Joined: 5 years ago

Re: GAMS MIRO setup

Post by Danrome »

Dear Freddy,

Many thanks for your answer, yes this was helpful to proper use of MIRO, but my problem still. Let me give an example:

Suppose i have 20 regions (reg1*reg20), set to "r" and 10 commodities (j1*j10), set to "j". Now i want to calibrate the price P0(r,j) for each commodity for each region at 1
normally i write:

Parameter
P0(r,j)
;

P0(r,j) = 1;

But this doesn't work for MIRO and i get the error.
What would be then a proper parameter initialization in this case? should i initialize each single parameter at the same time like the following code?:
Parameter
P0(r,j)
/(reg1,j1) 1
(reg1,j2) 1
....
... and so on. In this case there is a huge amount of coding!! Hope there is a solution to let MIRO work with the first code.
Thank you very much for your help.
Freddy
User
User
Posts: 16
Joined: 5 years ago

Re: GAMS MIRO setup

Post by Freddy »

Danrome,

what you can do if you want to create a default scenario with the parameter being initialized to 1, but allow the users to change these values via MIRO is to check whether you r model runs under MIRO or not when assigning to your parameter. You can do so by checking whether the GAMS option IDCGDXInput is set or not:

Code: Select all

set
  r /r1*r10/
  j /j1*j10/;
$onExternalInput
Parameter
  P0(r,j) //;
$offExternalInput

$if not "x%gams.IDCGDXInput%"=="x" $set mode MIRO

$iftheni not %mode%==MIRO
$offIDCProtect
P0(r,j) = 1;
$onIDCProtect
$endif

$onExternalOutput
Parameter
  Pp(r,j);
$offExternalOutput

Pp(r,j) = P0(r,j);

Hope this helps,

Freddy
Danrome
User
User
Posts: 5
Joined: 5 years ago

Re: GAMS MIRO setup

Post by Danrome »

Yes it helped,

Thank you very much
Post Reply