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