Syntax error for EMP equilibrium problem

Hi,

I am trying to write a gams model with emp input to solve a equilibrium problem. However, GAMS said I have a syntax error causing JAMS Pre processing failed that I don’t know how to deal with: ***** EMP syntax error: key expected: is I (item 13 on line 3) but instance not in variable rim**

Here is the original code:

  • set defined
    set agent /a1a2/,
    time /t0
    t2/,
    node /n0n12/,
    j /j1
    j3/,
    k /k1*k4/;

alias(n, node, parent, child);
alias(a, agent);

set sn(n) /n1n12/
leafn(n) /n4
n12/
parentn(n, node) /(n1n3).n0,
(n4
n6).n1,
(n7n9).n2,
(n10
n12).n3/;

Parameter
y(n) /(n1n3) 5,
(n4
n12) 20/
D(j,n) /j1.n1 150,
j2.n1 200,
j3.n1 210,
j1.n2 105,
j2.n2 125,
j3.n2 225,
j1.n3 210,
j2.n3 210,
j3.n3 210,
j1.(n4,n7,n10) 75,
j2.(n4,n7,n10) 60,
j3.(n4,n7,n10) 90,
j1.(n5,n8,n11) 105,
j2.(n5,n8,n11) 115,
j3.(n5,n8,n11) 120,
j1.(n6,n9,n12) 180,
j2.(n6,n9,n12) 150,
j3.(n6,n9,n12) 135
/
Gamma(a,n)
/
a1.n0 125,
a2.n0 90,
a1.(n1n3) 30,
a2.(n1
n3) 20
/
c(a,j,n)
/
a1.j1.(n1n3) 10,
a2.j1.(n1
n3) 10,
a1.j2.(n1n3) 12,
a2.j2.(n1
n3) 12,
a1.j3.(n1n3) 15,
a2.j3.(n1
n3) 15,
a1.j1.(n4n12) 20,
a2.j1.(n4
n12) 20,
a1.j2.(n4n12) 25,
a2.j2.(n4
n12) 25,
a1.j3.(n4n12) 30,
a2.j3.(n4
n12) 30
/
;

set risk(a,n,k)
/a1.n0.(k1k4),
a2.n0.(k1
k3),
(a1a2).n1.(k1k3),
(a1a2).n2.(k1k3),
(a1a2).n3.(k1k3)
/
;

Parameter
c_prob(a,n,k) ‘risk averse conditional probability’
/a1.n1.k1 0.8,
a1.n2.k1 0.1,
a1.n3.k1 0.1,
a1.n1.k2 0.1,
a1.n2.k2 0.8,
a1.n3.k2 0.1,
a1.n1.k3 0.1,
a1.n2.k3 0.1,
a1.n3.k3 0.8,
a1.n1.k4 0.9,
a1.n2.k4 0.05,
a1.n3.k4 0.05,
a1.(n4,n7,n10).k1 0.8,
a1.(n5,n8,n11).k1 0.1,
a1.(n6,n9,n12).k1 0.1,
a1.(n4,n7,n10).k2 0.1,
a1.(n5,n8,n11).k2 0.8,
a1.(n6,n9,n12).k2 0.1,
a1.(n4,n7,n10).k3 0.1,
a1.(n5,n8,n11).k3 0.1,
a1.(n6,n9,n12).k3 0.8,
a2.n1.k1 0.8,
a2.n2.k1 0.1,
a2.n3.k1 0.1,
a2.n1.k2 0.1,
a2.n2.k2 0.8,
a2.n3.k2 0.1,
a2.n1.k3 0.1,
a2.n2.k3 0.1,
a2.n3.k3 0.8,
a2.(n4,n7,n10).k1 0.9,
a2.(n5,n8,n11).k1 0.05,
a2.(n6,n9,n12).k1 0.05,
a2.(n4,n7,n10).k2 0.05,
a2.(n5,n8,n11).k2 0.9,
a2.(n6,n9,n12).k2 0.05,
a2.(n4,n7,n10).k3 0.05,
a2.(n5,n8,n11).k3 0.05,
a2.(n6,n9,n12).k3 0.9
/
;

**Model
Positive variable
R(a,n)
q(a,j,n)
I(a,n)
Ka(a,n)
P(j,n)
;

variable
obj(a),
theta(a,n)
;

Equations
defobj(a)
transition(a,n)
costtogo(a,n,k)
costtogoleaf(a,n)
investment(a,n)
prodcapacity(a,n)
supplydemand(j,n)
;

defobj(a)…
obj(a) =e= theta(a,‘n0’) - Gamma(a,‘n0’)*I(a,‘n0’);

transition(a,n)$[sn(n)]…
R(a,n) =e= sum(parentn(n, parent), R(a,parent)) - y(n)*sum(j, q(a,j,n));

investment(a,n)$[sn(n)]…
Ka(a,n) =e= sum(parentn(n, parent), Ka(a,parent) + I(a,parent));

prodcapacity(a,n)$[sn(n)]…
y(n)*sum(j, q(a,j,n)) =l= Ka(a,n);

costtogo(a,n,k)$[not leafn(n) and risk(a,n,k)]…
theta(a,n) =g= sum(parentn(child, n), c_prob(a,child,k)*( sum(j, (c(a,j,child)

  • P(j,child))*q(a,j,child)) - Gamma(a,child)*I(a,child) + theta(a,child) ));

costtogoleaf(a,n)$[leafn(n)]…
theta(a,n) =e= 0;

supplydemand(j,n)$[sn(n)]…
sum(a, q(a,j,n)) - D(j,n) =g= 0;


model mp /defobj, transition, costtogo, costtogoleaf, investment, prodcapacity, supplydemand/;

file empinfo /‘%emp.info%’/;
put empinfo ‘equilibrium’/;
loop(a,

  • put variables
    put 'min ';
    put obj(a) theta(a,‘n0’) R(a,‘n0’) Ka(a,‘n0’);
    loop(n$[sn(n)],
    put Ka(a,n) theta(a,n) R(a,n) I(a,n);
    loop(j,
    put q(a,j,n);
    );
    );

  • put constraints
    put defobj(a);
    loop(n$[sn(n)],
    put transition(a,n) investment(a,n) prodcapacity(a,n);
    );
    loop(n$[not leafn(n)],
    loop(risk(a,n,k),
    put costtogo(a,n,k);
    );
    );
    loop(n$leafn(n),
    put costtogoleaf(a,n);
    );
    put /;
    );
    put 'vi '/;
    loop(n$sn(n),
    loop(j,
    put supplydemand(j,n) P(j,n);
    );
    );
    put /;
    putclose empinfo;

$echo SharedEqu > jams.opt
mp.optfile = 1;

R.fx(‘a1’,‘n0’) = 8000;
R.fx(‘a2’,‘n0’) = 8000;

Ka.fx(‘a1’,‘n0’) = 1500;
Ka.fx(‘a2’,‘n0’) = 1500;

option limrow = 1000;
option limcol = 1000;

solve mp using emp;
display obj.l, theta.l, R.l, q.l, I.l, Ka.l, P.l;

Thanks,

Look at the EMP info file you produce (e.g. do a gamskeep and look into the 225a directory at file empinfo.dat). Line 3 reads:

q('a1','j2','n2') q('a1','j3','n2') Ka('a1','n3') theta('a1','n3') R('a1','n3') I('a1','n3') q('a1','j1','n3') q('a1','j2','n3') q('a1','j3','n3') Ka('a1','n4') theta('a1','n4') R('a1','n4') I('a1','n4') q('a1','j1','n4') q('a1','j2','n4')

and contains the variable I(‘a1’,‘n4’) in the 13th position on this line but the model you generate does not contain this variable. You can find out about the rows and columns the solve statement generates, but looking at the equation and column listing in the listing file. You might have to increase limrow and limcol for this to see all variables and equations (by default GAMS only print the first three of each block). You have the following I variables in your model: I(a1,n0) I(a1,n1) I(a1,n2) I(a1,n3) I(a2,n0) I(a2,n1) I(a2,n2) I(a2,n3), but not I(a1,n4). So correct this in your EMP info file.

-Michael

Thanks! This solves my problem!