selkie12.gms : SELKIE test suite: sub-diagonalization

Description

Test sub-diagonalization.

Contributor: Youngdae Kim (08.15.2017)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : selkie12.gms

$title 'SELKIE test suite: sub-diagonalization'  (SELKIE12,SEQ=768)

$ontext

Test sub-diagonalization.

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*3 /;

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 / 'agent_group {{1,2}:jacobi,{3}}';
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;

Equations  e1;

e1.. sqr((-2) + x1) =L= 1;



Model m / e1 /;

Solve m using nlp minimizing x1;

$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;

Equations  e2;

e2.. sqr((-2) + x2) =L= 1;



Model m / e2 /;

Solve m using nlp minimizing x2;

$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';

$onecho > agent3_gms

Variables  x3;

Equations  e3;

e3.. sqr((-2) + x3) =L= 1;



Model m / e3 /;

Solve m using nlp minimizing x3;

$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';

* Test with parallel version of the Jacobi method.
option emp = selkie;
put opt 'parallel_jacobi yes';
putclose / 'agent_group {{1,2}:jacobi,{3}}';
m.optfile = 1;

obj.l(i) = 0; obj.m(i) = 0;

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;