emppy3.gms : Test a combination of optimization and vi agents using emp python

Description

Test a combination of optimization and vi agents using emp python.

Contributor: Youngdae Kim (10.26.2018)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emppy3.gms

$title 'Test a combination of optimization and vi agents using emp python' (EMPPY3,SEQ=791)

$onText
Test a combination of optimization and vi agents using emp python.

Contributor: Youngdae Kim (10.26.2018)
$offText


$log --- Using Python library %sysEnv.GMSPYTHONLIB%

$if not set TESTTOL $set TESTTOL 1e-3
scalar tol / %TESTTOL% /;
file opt   / 'jams.opt' /;

set i / 1*3 /;
alias(i,j);

variables obj(i), y;
positive variables x(i);

equations defobj(i), defext;

defobj(i)..
    obj(i) =E= x(i)*(1 - sum(j, x(j))) + y;

defext..
    1 - sum(j, x(j)) - y =E= 0;

$onEcho > empfile.txt
equilibrium
max obj(i) s.t. x(i), defobj(i)
vi defext, y
$offEcho

$libInclude empmodel empfile.txt

model m / defobj, defext /;

putclose opt 'FileName m.gms';
m.optfile = 1;

x.up(i) = 1;
solve m using emp;

abort$[m.solvestat <> %solveStat.normalCompletion%]
     'wrong m.solvestat', m.solvestat;
abort$[m.modelstat <> %modelStat.locallyOptimal%]
     'wrong m.modelstat', m.modelstat;
abort$[ smax{i, abs(obj.l(i) - 0.312)} > tol ] 'bad obj.l', obj.l;
abort$[ smax{i, abs(x.l(i) - 0.25)} > tol ] 'bad x.l', x.l;
abort$[ abs(y.l - 0.25) > tol ] 'bad y.l', y.l;

$onEcho > m_gms
***********************************************
* written by GAMS/JAMS at 10/27/18 00:02:22
* for more information use JAMS option "Dict"
***********************************************

Variables  x4,x5,x6,x7;

Positive Variables  x5,x6,x7;

Equations  e4,dL_dx5,dL_dx6,dL_dx7;


e4..  - x4 - x5 - x6 - x7 =E= -1;

dL_dx5.. (-(1 - x5 - x6 - x7 - x5))/(1) =N= 0;

dL_dx6.. (-(1 - x5 - x6 - x7 - x6))/(1) =N= 0;

dL_dx7.. (-(1 - x5 - x6 - x7 - x7))/(1) =N= 0;

* set non-default bounds
x5.up = 1;
x6.up = 1;
x7.up = 1;

Model m / e4.x4,dL_dx5.x5,dL_dx6.x6,dL_dx7.x7 /;

m.limrow=0; m.limcol=0;

Solve m using MCP;
$offEcho

execute 'grep -v " written by GAMS" m_gms > m.gms.want'
execute 'grep -v " written by GAMS" m.gms > m.gms.got'
execute '=diff -I reslim -bw m.gms.want m.gms.got'
abort$errorlevel 'Files m.gms.want and m.gms.got differ';