Syntax error for EMP equilibrium problem

Problems with syntax of GAMS
Post Reply
jshengdb
User
User
Posts: 3
Joined: 1 year ago

Syntax error for EMP equilibrium problem

Post by jshengdb » 1 week ago

<r>Hi,<br/>
<br/>
I have a emp syntax error for a equilibrium problem. GAMS said <B><s></s>"JAMS Pre processing failed"<e></e></B> caused by <B><s></s>"EMP syntax error: key expected: is I (item 13 on line 3) but instance not in variable rim"<e></e></B>. <br/>
<br/>
My code is following:<br/>
<br/>
* set defined<br/>
set agent /a1*a2/,<br/>
time /t0*t2/,<br/>
node /n0*n12/,<br/>
j /j1*j3/,<br/>
k /k1*k4/;<br/>
<br/>
alias(n, node, parent, child);<br/>
alias(a, agent);<br/>
<br/>
set sn(n) /n1*n12/<br/>
leafn(n) /n4*n12/<br/>
parentn(n, node) /(n1*n3).n0,<br/>
(n4*n6).n1,<br/>
(n7*n9).n2,<br/>
(n10*n12).n3/;<br/>
<br/>
Parameter<br/>
y(n) /(n1*n3) 5,<br/>
(n4*n12) 20/<br/>
D(j,n) /j1.n1 150,<br/>
j2.n1 200,<br/>
j3.n1 210,<br/>
j1.n2 105,<br/>
j2.n2 125,<br/>
j3.n2 225,<br/>
j1.n3 210,<br/>
j2.n3 210,<br/>
j3.n3 210,<br/>
j1.(n4,n7,n10) 75,<br/>
j2.(n4,n7,n10) 60,<br/>
j3.(n4,n7,n10) 90,<br/>
j1.(n5,n8,n11) 105,<br/>
j2.(n5,n8,n11) 115,<br/>
j3.(n5,n8,n11) 120,<br/>
j1.(n6,n9,n12) 180,<br/>
j2.(n6,n9,n12) 150,<br/>
j3.(n6,n9,n12) 135<br/>
/<br/>
Gamma(a,n) <br/>
/<br/>
a1.n0 125,<br/>
a2.n0 90,<br/>
a1.(n1*n3) 30,<br/>
a2.(n1*n3) 20<br/>
/<br/>
c(a,j,n)<br/>
/<br/>
a1.j1.(n1*n3) 10,<br/>
a2.j1.(n1*n3) 10,<br/>
a1.j2.(n1*n3) 12,<br/>
a2.j2.(n1*n3) 12,<br/>
a1.j3.(n1*n3) 15,<br/>
a2.j3.(n1*n3) 15,<br/>
a1.j1.(n4*n12) 20,<br/>
a2.j1.(n4*n12) 20,<br/>
a1.j2.(n4*n12) 25,<br/>
a2.j2.(n4*n12) 25,<br/>
a1.j3.(n4*n12) 30,<br/>
a2.j3.(n4*n12) 30<br/>
/<br/>
;<br/>
<br/>
set risk(a,n,k)<br/>
/a1.n0.(k1*k4),<br/>
a2.n0.(k1*k3),<br/>
(a1*a2).n1.(k1*k3),<br/>
(a1*a2).n2.(k1*k3),<br/>
(a1*a2).n3.(k1*k3)<br/>
/<br/>
;<br/>
<br/>
Parameter<br/>
c_prob(a,n,k) 'risk averse conditional probability'<br/>
/a1.n1.k1 0.8,<br/>
a1.n2.k1 0.1,<br/>
a1.n3.k1 0.1,<br/>
a1.n1.k2 0.1,<br/>
a1.n2.k2 0.8,<br/>
a1.n3.k2 0.1,<br/>
a1.n1.k3 0.1,<br/>
a1.n2.k3 0.1,<br/>
a1.n3.k3 0.8,<br/>
a1.n1.k4 0.9,<br/>
a1.n2.k4 0.05,<br/>
a1.n3.k4 0.05,<br/>
a1.(n4,n7,n10).k1 0.8,<br/>
a1.(n5,n8,n11).k1 0.1,<br/>
a1.(n6,n9,n12).k1 0.1,<br/>
a1.(n4,n7,n10).k2 0.1,<br/>
a1.(n5,n8,n11).k2 0.8,<br/>
a1.(n6,n9,n12).k2 0.1,<br/>
a1.(n4,n7,n10).k3 0.1,<br/>
a1.(n5,n8,n11).k3 0.1,<br/>
a1.(n6,n9,n12).k3 0.8,<br/>
a2.n1.k1 0.8,<br/>
a2.n2.k1 0.1,<br/>
a2.n3.k1 0.1,<br/>
a2.n1.k2 0.1,<br/>
a2.n2.k2 0.8,<br/>
a2.n3.k2 0.1,<br/>
a2.n1.k3 0.1,<br/>
a2.n2.k3 0.1,<br/>
a2.n3.k3 0.8,<br/>
a2.(n4,n7,n10).k1 0.9,<br/>
a2.(n5,n8,n11).k1 0.05,<br/>
a2.(n6,n9,n12).k1 0.05,<br/>
a2.(n4,n7,n10).k2 0.05,<br/>
a2.(n5,n8,n11).k2 0.9,<br/>
a2.(n6,n9,n12).k2 0.05,<br/>
a2.(n4,n7,n10).k3 0.05,<br/>
a2.(n5,n8,n11).k3 0.05,<br/>
a2.(n6,n9,n12).k3 0.9 <br/>
/<br/>
;<br/>
<br/>
**Model<br/>
Positive variable<br/>
R(a,n)<br/>
q(a,j,n)<br/>
I(a,n)<br/>
Ka(a,n)<br/>
P(j,n)<br/>
;<br/>
<br/>
variable<br/>
obj(a),<br/>
theta(a,n)<br/>
;<br/>
<br/>
Equations<br/>
defobj(a)<br/>
transition(a,n)<br/>
costtogo(a,n,k)<br/>
costtogoleaf(a,n)<br/>
investment(a,n)<br/>
prodcapacity(a,n)<br/>
supplydemand(j,n)<br/>
;<br/>
<br/>
defobj(a)..<br/>
obj(a) =e= theta(a,'n0') - Gamma(a,'n0')*I(a,'n0');<br/>
<br/>
transition(a,n)$[sn(n)]..<br/>
R(a,n) =e= sum(parentn(n, parent), R(a,parent)) - y(n)*sum(j, q(a,j,n));<br/>
<br/>
investment(a,n)$[sn(n)]..<br/>
Ka(a,n) =e= sum(parentn(n, parent), Ka(a,parent) + I(a,parent));<br/>
<br/>
prodcapacity(a,n)$[sn(n)]..<br/>
y(n)*sum(j, q(a,j,n)) =l= Ka(a,n);<br/>
<br/>
costtogo(a,n,k)$[not leafn(n) and risk(a,n,k)]..<br/>
theta(a,n) =g= sum(parentn(child, n), c_prob(a,child,k)*( sum(j, (c(a,j,child)<br/>
- P(j,child))*q(a,j,child)) - Gamma(a,child)*I(a,child) + theta(a,child) ));<br/>
<br/>
costtogoleaf(a,n)$[leafn(n)]..<br/>
theta(a,n) =e= 0; <br/>
<br/>
supplydemand(j,n)$[sn(n)]..<br/>
sum(a, q(a,j,n)) - D(j,n) =g= 0;<br/>
<br/>
<br/>
model mp /defobj, transition, costtogo, costtogoleaf, investment, prodcapacity, supplydemand/;<br/>
<br/>
file empinfo /'%emp.info%'/; <br/>
put empinfo 'equilibrium'/;<br/>
loop(a,<br/>
* put variables<br/>
put 'min ';<br/>
put obj(a) theta(a,'n0') R(a,'n0') Ka(a,'n0');<br/>
loop(n$[sn(n)],<br/>
put Ka(a,n) theta(a,n) R(a,n) I(a,n);<br/>
loop(j,<br/>
put q(a,j,n);<br/>
);<br/>
);<br/>
<br/>
* put constraints<br/>
put defobj(a);<br/>
loop(n$[sn(n)],<br/>
put transition(a,n) investment(a,n) prodcapacity(a,n);<br/>
);<br/>
loop(n$[not leafn(n)],<br/>
loop(risk(a,n,k),<br/>
put costtogo(a,n,k);<br/>
);<br/>
);<br/>
loop(n$leafn(n),<br/>
put costtogoleaf(a,n);<br/>
);<br/>
put /;<br/>
);<br/>
put 'vi '/;<br/>
loop(n$sn(n),<br/>
loop(j,<br/>
put supplydemand(j,n) P(j,n);<br/>
);<br/>
);<br/>
put /;<br/>
putclose empinfo;<br/>
<br/>
$echo SharedEqu > jams.opt<br/>
mp.optfile = 1;<br/>
<br/>
R.fx('a1','n0') = 8000;<br/>
R.fx('a2','n0') = 8000;<br/>
<br/>
Ka.fx('a1','n0') = 1500;<br/>
Ka.fx('a2','n0') = 1500;<br/>
<br/>
option limrow = 1000;<br/>
option limcol = 1000;<br/>
<br/>
solve mp using emp;<br/>
display obj.l, theta.l, R.l, q.l, I.l, Ka.l, P.l;</r>

Thanks

Post Reply