Description
Test the case where there are no explicit objective equations. Contributor: Youngdae Kim (08.15.2017)
Small Model of Type : GAMS
Category : GAMS Test library
Main file : selkie11.gms
$title 'SELKIE test suite' (SELKIE11,SEQ=767)
$ontext
Test the case where there are no explicit objective equations.
Contributor: Youngdae Kim (08.15.2017)
$offtext
$if not set TESTTOL $set TESTTOL 1e-4
scalar tol / %TESTTOL% /;
file opt / 'selkie.opt' /;
file info / '%emp.info%' /;
set i / 1*2 /;
variable obj(i);
equation cons(i);
cons(i)..
sqr(obj(i)-2) =l= 1;
model m / cons /;
put info 'equilibrium';
loop(i,
put / 'min', obj(i), cons(i);
);
putclose;
option emp = selkie;
putclose opt 'use_mcpopt yes';
m.optfile = 1;
* Test if we generate a correct MCP model for each agent.
solve m using emp;
abort$[ smax{i, abs(obj.l(i) - 1)} > tol ] 'bad obj.l(i)', obj.l;
abort$[ smax{i, abs(cons.l(i) - 1)} > tol ] 'bad cons.l(i)', cons.l;
abort$[ smax{i, abs(cons.m(i) + 0.5)} > tol ] 'bad cons.m(i)', cons.m;
$onecho > agent1_gms
Variables x1,u1;
Negative Variables u1;
Equations e1,dL_dx1;
e1.. sqr((-2) + x1) =L= 1;
dL_dx1.. 1 - (2*(-2 + x1))*u1 =E= 0;
Model m / e1.u1,dL_dx1.x1 /;
Solve m using mcp;
$offecho
execute 'cat agent1_gms > agent1.gms.want';
execute 'cat "%gams.scrdir%agent1.gms" > agent1.gms.got';
execute '=diff -bw agent1.gms.want agent1.gms.got';
abort$errorlevel 'Files agent1.gms.want and agent1.gms.got differ';
$onecho > agent2_gms
Variables x2,u2;
Negative Variables u2;
Equations e2,dL_dx2;
e2.. sqr((-2) + x2) =L= 1;
dL_dx2.. 1 - (2*(-2 + x2))*u2 =E= 0;
Model m / e2.u2,dL_dx2.x2 /;
Solve m using mcp;
$offecho
execute 'cat agent2_gms > agent2.gms.want';
execute 'cat "%gams.scrdir%agent2.gms" > agent2.gms.got';
execute '=diff -bw agent2.gms.want agent2.gms.got';
abort$errorlevel 'Files agent2.gms.want and agent2.gms.got differ';
* Test if we generate a correct MCP model when we group them.
obj.l(i) = 0;
cons.l(i) = 0;
cons.m(i) = 0;
option emp = selkie;
putclose opt 'agent_group {{1,2}}';
m.optfile = 1;
solve m using emp;
abort$[ smax{i, abs(obj.l(i) - 1)} > tol ] 'bad obj.l(i)', obj.l;
abort$[ smax{i, abs(cons.l(i) - 1)} > tol ] 'bad cons.l(i)', cons.l;
abort$[ smax{i, abs(cons.m(i) + 0.5)} > tol ] 'bad cons.m(i)', cons.m;
$onecho > agent3_gms
Variables x1,x2,u1,u2;
Negative Variables u1,u2;
Equations e1,e2,dL_dx1,dL_dx2;
e1.. sqr((-2) + x1) =L= 1;
e2.. sqr((-2) + x2) =L= 1;
dL_dx1.. 1 - (2*(-2 + x1))*u1 =E= 0;
dL_dx2.. 1 - (2*(-2 + x2))*u2 =E= 0;
Model m / e1.u1,e2.u2,dL_dx1.x1,dL_dx2.x2 /;
Solve m using mcp;
$offecho
execute 'cat agent3_gms > agent3.gms.want';
execute 'cat "%gams.scrdir%agent3.gms" > agent3.gms.got';
execute '=diff -bw agent3.gms.want agent3.gms.got';
abort$errorlevel 'Files agent3.gms.want and agent3.gms.got differ';