emppy1.gms : Test an equilibrium model using emp python

Description

Test an equilibrium model using emp python.

Contributor: Youngdae Kim (10.26.2018)


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emppy1.gms

$title 'Test an equilibrium model using emp python' (EMPPY1,SEQ=789)

$onText
Test an equilibrium model 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);
positive variables x(i);

equations defobj(i);

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

model m / defobj /;

$onEcho > empinfo.txt
equilibrium
max obj(i) s.t. x(i), defobj(i)
$offEcho

$libInclude empmodel empinfo.txt

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.062)} > tol ] 'bad obj.l', obj.l;
abort$[ smax{i, abs(x.l(i) - 0.25)} > tol ] 'bad x.l', x.l;

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

Variables  x4,x5,x6;

Positive Variables  x4,x5,x6;

Equations  dL_dx4,dL_dx5,dL_dx6;


dL_dx4.. (-(1 - x4 - x5 - x6 - x4))/(1) =N= 0;

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

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

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

Model m / dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;

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