emp22.gms : Test JAMS/EMP on implicit variable handling

Description

Test JAMS behavior on a small equilibrium model with implicit variables.

Contributors: Youngdae Kim & Steve Dirkse, Dec 2016


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emp22.gms

$TITLE 'Test JAMS/EMP on implicit variable handling' (EMP22,SEQ=704)

$ontext
Test JAMS behavior on a small equilibrium model with implicit variables.

Contributors: Youngdae Kim & Steve Dirkse, Dec 2016
$offtext
$if not set TESTTOL $set TESTTOL 1e-3
scalars tol / %TESTTOL% /;
file opt  / 'jams.opt' /;
file info / '%emp.info%' /;

sets i agents   / 1*5 /;
alias(i,j);

parameters
    c(i)    / 1  10, 2   8, 3   6, 4   4, 5   2 /
    L(i)    / 1   5, 2   5, 3   5, 4   5, 5   5 /
    beta(i) / 1 1.2, 2 1.1, 3 1.0, 4 0.9, 5 0.8 /
    ;

* The scalar files generated depend on the variable declaration order,
* so do not change the declarations lightly

variable
    obj(i)     objective variable of each cost minimizing agent
    zExp(i)    explicit replica of variable z
    z          implicit variable
    ;

positive variables q(i);

equations
    defobjExp(i)   definition of the objective variable i with zExp
    defobj(i)      definition of the objective variable i with z
    defzExp(i)     definition of the explicit replica of variable z
    defz           definition of the implicit variable z
    ;


defobjExp(i)..
    obj(i) =E= q(i)*5000**(1.0/1.1)*zExp(i)**(-1.0/1.1) - (c(i)*q(i) + beta(i)/(beta(i)+1)*L(i)**(-1/beta(i))*q(i)**((beta(i)+1)/beta(i)));

defzExp(i)..
    zExp(i) =E= sum(j, q(j));

q.l(i) = 10;
zExp.l(i) = sum(j, q.l(j));

model me 'explicit formulation' / defobjExp, defzExp /;
put info 'equilibrium';
loop(i,
    put / 'min', obj(i), q(i), zExp(i);
    put / defobjExp(i), defzExp(i);
);
putclose;

putclose opt
  'Dict     explDict.txt' /
  'FileName expl.gms' ;

me.optfile = 1;
solve me using emp;

abort$[me.solvestat <> %solvestat.NormalCompletion%]
   'wrong me.solvestat', me.solvestat;
abort$[me.modelstat  > %modelstat.LocallyOptimal%]
   'wrong me.modelstat', me.modelstat;
abort$[ abs(obj.l('1')-199.934) > tol ]        'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')-279.716) > tol ]        'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')-346.590) > tol ]        'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')-391.279) > tol ]        'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')-410.357) > tol ]        'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')-36.933) > tol ]           'bad q.l("1")', q.l;
abort$[ abs(q.l('2')-41.818) > tol ]           'bad q.l("2")', q.l;
abort$[ abs(q.l('3')-43.707) > tol ]           'bad q.l("3")', q.l;
abort$[ abs(q.l('4')-42.659) > tol ]           'bad q.l("4")', q.l;
abort$[ abs(q.l('5')-39.179) > tol ]           'bad q.l("5")', q.l;
abort$[smax{i, abs(zExp.l(i)-204.295)} > tol ] 'bad zExp.l(i)', zExp.l;

obj.l(i) = 0;
q.l(i) = 10;
z.l = sum(i, q.l(i));

$onecho > expl_gms
***********************************************
* written by GAMS/JAMS at 12/04/16 11:07:17
* for more information use JAMS option "Dict"
***********************************************

Variables  x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,u6,u7,u8,u9,u10;

Positive Variables  x11,x12,x13,x14,x15;

Equations  e6,e7,e8,e9,e10,dL_dx6,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11,dL_dx12
          ,dL_dx13,dL_dx14,dL_dx15;


e6..    x6 - x11 - x12 - x13 - x14 - x15 =E= 0;

e7..    x7 - x11 - x12 - x13 - x14 - x15 =E= 0;

e8..    x8 - x11 - x12 - x13 - x14 - x15 =E= 0;

e9..    x9 - x11 - x12 - x13 - x14 - x15 =E= 0;

e10..    x10 - x11 - x12 - x13 - x14 - x15 =E= 0;

dL_dx6.. (2095.59483215011*x6**(-1.90909090909091)*x11)/(-1) - u6 =E= 0;

dL_dx7.. (2095.59483215011*x7**(-1.90909090909091)*x12)/(-1) - u7 =E= 0;

dL_dx8.. (2095.59483215011*x8**(-1.90909090909091)*x13)/(-1) - u8 =E= 0;

dL_dx9.. (2095.59483215011*x9**(-1.90909090909091)*x14)/(-1) - u9 =E= 0;

dL_dx10.. (2095.59483215011*x10**(-1.90909090909091)*x15)/(-1) - u10 =E= 0;

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (10 + 
          0.261532097202366*x11**0.833333333333333)))/(-1) + u6 =G= 0;

dL_dx12.. (-(2305.15431536512*x7**(-0.909090909090909) - (8 + 0.231511582354131
          *x12**0.909090909090909)))/(-1) + u7 =G= 0;

dL_dx13.. (-(2305.15431536512*x8**(-0.909090909090909) - (6 + 0.2*x13**1))
          )/(-1) + u8 =G= 0;

dL_dx14.. (-(2305.15431536512*x9**(-0.909090909090909) - (4 + 0.167250206190075
          *x14**1.11111111111111)))/(-1) + u9 =G= 0;

dL_dx15.. (-(2305.15431536512*x10**(-0.909090909090909) - (2 + 
          0.133748060995284*x15**1.25)))/(-1) + u10 =G= 0;

* set non-default levels
x6.l = 50;
x7.l = 50;
x8.l = 50;
x9.l = 50;
x10.l = 50;
x11.l = 10;
x12.l = 10;
x13.l = 10;
x14.l = 10;
x15.l = 10;

Model m / e6.u6,e7.u7,e8.u8,e9.u9,e10.u10,dL_dx6.x6,dL_dx7.x7,dL_dx8.x8
         ,dL_dx9.x9,dL_dx10.x10,dL_dx11.x11,dL_dx12.x12,dL_dx13.x13
         ,dL_dx14.x14,dL_dx15.x15 /;

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

Solve m using MCP;
$offecho

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

$onecho > expl_dict
* written by GAMS/JAMS at 12/04/16 11:07:17

********************************************************************************
 Contents
 1 Content of EMP Information File
 2 Processed EMP Information
 3 Dictionary
  3.1 Constraints
  3.2 Variables
********************************************************************************


 1 Content of EMP Information File
 ---------------------------------

     1:equilibrium
     2:min obj('1') q('1') zExp('1')
     3:defobjExp('1') defzExp('1')
     4:min obj('2') q('2') zExp('2')
     5:defobjExp('2') defzExp('2')
     6:min obj('3') q('3') zExp('3')
     7:defobjExp('3') defzExp('3')
     8:min obj('4') q('4') zExp('4')
     9:defobjExp('4') defzExp('4')
    10:min obj('5') q('5') zExp('5')
    11:defobjExp('5') defzExp('5')


 2 Processed EMP Information
 ---------------------------


 3 Dictionary
 ------------
  3.1 Constraints
  ---------------

      {reformulated}  defobjExp(1)
      {reformulated}  defobjExp(2)
      {reformulated}  defobjExp(3)
      {reformulated}  defobjExp(4)
      {reformulated}  defobjExp(5)
                  e6  defzExp(1)
                  e7  defzExp(2)
                  e8  defzExp(3)
                  e9  defzExp(4)
                 e10  defzExp(5)
              dL_dx6  {new}
              dL_dx7  {new}
              dL_dx8  {new}
              dL_dx9  {new}
             dL_dx10  {new}
             dL_dx11  {new}
             dL_dx12  {new}
             dL_dx13  {new}
             dL_dx14  {new}
             dL_dx15  {new}


  3.2 Variables
 --------------

      {reformulated}  obj(1)
      {reformulated}  obj(2)
      {reformulated}  obj(3)
      {reformulated}  obj(4)
      {reformulated}  obj(5)
                  x6  zExp(1)
                  x7  zExp(2)
                  x8  zExp(3)
                  x9  zExp(4)
                 x10  zExp(5)
                 x11  q(1)
                 x12  q(2)
                 x13  q(3)
                 x14  q(4)
                 x15  q(5)
                  u6  {new}
                  u7  {new}
                  u8  {new}
                  u9  {new}
                 u10  {new}
$offecho

execute 'grep -v " written by GAMS" expl_dict > expldict.txt.want'
execute 'grep -v " written by GAMS" explDict.txt > expldict.txt.got'
execute '=diff -bw expldict.txt.want expldict.txt.got'
abort$errorlevel 'Files expldict.txt.want and expldict.txt.got differ';

defobj(i)..
    obj(i) =E= q(i)*5000**(1.0/1.1)*z**(-1.0/1.1) - (c(i)*q(i) + beta(i)/(beta(i)+1)*L(i)**(-1/beta(i))*q(i)**((beta(i)+1)/beta(i)));

defz..
    z =E= sum(i, q(i));

model mi 'implicit formulation' / defobj, defz /;

put info 'equilibrium';
put / 'implicit z defz';
loop(i,
    put / 'min', obj(i), q(i), z, defobj(i);
);
putclose;

* testing with implicit
putclose opt
  'Dict         implDict.txt' /
  'FileName     impl.gms'     /
  'ImplVarModel substitution' ;

mi.optfile = 1;
solve mi using emp;
abort$[mi.solvestat <> %solvestat.NormalCompletion%]
   'wrong mi.solvestat', mi.solvestat;
abort$[mi.modelstat  > %modelstat.LocallyOptimal%]
   'wrong mi.modelstat', mi.modelstat;
abort$[ abs(obj.l('1')-199.934) > tol ]        'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')-279.716) > tol ]        'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')-346.590) > tol ]        'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')-391.279) > tol ]        'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')-410.357) > tol ]        'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')-36.933) > tol ]           'bad q.l("1")', q.l;
abort$[ abs(q.l('2')-41.818) > tol ]           'bad q.l("2")', q.l;
abort$[ abs(q.l('3')-43.707) > tol ]           'bad q.l("3")', q.l;
abort$[ abs(q.l('4')-42.659) > tol ]           'bad q.l("4")', q.l;
abort$[ abs(q.l('5')-39.179) > tol ]           'bad q.l("5")', q.l;
abort$[ abs(z.l-204.295) > tol ]               'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 10;
z.l = sum(i, q.l(i));
defobj.m(i) = 0;
defz.m = 0;

$onechoV > impl_gms
***********************************************
* written by GAMS/JAMS at 12/04/16 11:11:39
* for more information use JAMS option "Dict"
***********************************************

Variables  x6,x7,x8,x9,x10,x11;

Positive Variables  x7,x8,x9,x10,x11;

Equations  e6,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11;


e6..    x6 - x7 - x8 - x9 - x10 - x11 =E= 0;

dL_dx7.. (-(2305.15431536512*x6**(-0.909090909090909) - (10 + 0.261532097202366
         *x7**0.833333333333333)))/(-1) + ((2095.59483215011*x6**(-
         1.90909090909091)*x7)/(-1))*(1) =G= 0;

dL_dx8.. (-(2305.15431536512*x6**(-0.909090909090909) - (8 + 0.231511582354131*
         x8**0.909090909090909)))/(-1) + ((2095.59483215011*x6**(-
         1.90909090909091)*x8)/(-1))*(1) =G= 0;

dL_dx9.. (-(2305.15431536512*x6**(-0.909090909090909) - (6 + 0.2*x9**1)))/(-1)
          + ((2095.59483215011*x6**(-1.90909090909091)*x9)/(-1))*(1) =G= 0;

dL_dx10.. (-(2305.15431536512*x6**(-0.909090909090909) - (4 + 0.167250206190075
          *x10**1.11111111111111)))/(-1) + ((2095.59483215011*x6**(-
          1.90909090909091)*x10)/(-1))*(1) =G= 0;

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(-1) + ((2095.59483215011*x6**(-1.90909090909091)*x11
          )/(-1))*(1) =G= 0;

* set non-default levels
x6.l = 50;
x7.l = 10;
x8.l = 10;
x9.l = 10;
x10.l = 10;
x11.l = 10;

Model m / e6.x6,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10,dL_dx11.x11 /;

File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;

$onPutV
x6
$offPut

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

Solve m using MCP;
$offecho

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

$onecho > impl_dict
* written by GAMS/JAMS at 12/04/16 11:11:39

********************************************************************************
 Contents
 1 Content of EMP Information File
 2 Processed EMP Information
 3 Dictionary
  3.1 Constraints
  3.2 Variables
********************************************************************************


 1 Content of EMP Information File
 ---------------------------------

     1:equilibrium
     2:implicit z defz
     3:min obj('1') q('1') z defobj('1')
     4:min obj('2') q('2') z defobj('2')
     5:min obj('3') q('3') z defobj('3')
     6:min obj('4') q('4') z defobj('4')
     7:min obj('5') q('5') z defobj('5')


 2 Processed EMP Information
 ---------------------------


 3 Dictionary
 ------------
  3.1 Constraints
  ---------------

      {reformulated}  defobj(1)
      {reformulated}  defobj(2)
      {reformulated}  defobj(3)
      {reformulated}  defobj(4)
      {reformulated}  defobj(5)
                  e6  defz
              dL_dx7  {new}
              dL_dx8  {new}
              dL_dx9  {new}
             dL_dx10  {new}
             dL_dx11  {new}


  3.2 Variables
 --------------

      {reformulated}  obj(1)
      {reformulated}  obj(2)
      {reformulated}  obj(3)
      {reformulated}  obj(4)
      {reformulated}  obj(5)
                  x6  z
                  x7  q(1)
                  x8  q(2)
                  x9  q(3)
                 x10  q(4)
                 x11  q(5)
$offecho

execute 'grep -v " written by GAMS" impl_dict > impldict.txt.want'
execute 'grep -v " written by GAMS" implDict.txt > impldict.txt.got'
execute '=diff -bw impldict.txt.want impldict.txt.got'
abort$errorlevel 'Files impldict.txt.want and impldict.txt.got differ';

* testing with adjoint

putclose opt
  'Dict         implSwitchingDict.txt' /
  'FileName     implSwitching.gms'     /
  'ImplVarModel switching'           ;

solve mi using emp;
abort$[mi.solvestat <> %solvestat.NormalCompletion%]
   'wrong mi.solvestat', mi.solvestat;
abort$[mi.modelstat  > %modelstat.LocallyOptimal%]
   'wrong mi.modelstat', mi.modelstat;
abort$[ abs(obj.l('1')-199.934) > tol ]        'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')-279.716) > tol ]        'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')-346.590) > tol ]        'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')-391.279) > tol ]        'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')-410.357) > tol ]        'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')-36.933) > tol ]           'bad q.l("1")', q.l;
abort$[ abs(q.l('2')-41.818) > tol ]           'bad q.l("2")', q.l;
abort$[ abs(q.l('3')-43.707) > tol ]           'bad q.l("3")', q.l;
abort$[ abs(q.l('4')-42.659) > tol ]           'bad q.l("4")', q.l;
abort$[ abs(q.l('5')-39.179) > tol ]           'bad q.l("5")', q.l;
abort$[ abs(z.l-204.295) > tol ]               'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 10;
z.l = sum(i, q.l(i));
defobj.m(i) = 0;
defz.m = 0;

$onechoV > implSwitching_gms
***********************************************
* written by GAMS/JAMS at 11/12/17 17:33:21
* for more information use JAMS option "Dict"
***********************************************

Variables  x6,x7,x8,x9,x10,x11,u6_4,u6_5,u6_6,u6_7,u6_8;

Positive Variables  x7,x8,x9,x10,x11;

Equations  e6,dL_dx6_4,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11,dL_dx6_5,dL_dx6_6
          ,dL_dx6_7,dL_dx6_8;


e6..    x6 - x7 - x8 - x9 - x10 - x11 =E= 0;

dL_dx6_4.. (2095.59483215011*x6**(-1.90909090909091)*x7)/(-1) - u6_4 =E= 0;

dL_dx7.. (-(2305.15431536512*x6**(-0.909090909090909) - (10 + 0.261532097202366
         *x7**0.833333333333333)))/(-1) + u6_4 =G= 0;

dL_dx8.. (-(2305.15431536512*x6**(-0.909090909090909) - (8 + 0.231511582354131*
         x8**0.909090909090909)))/(-1) + u6_5 =G= 0;

dL_dx9.. (-(2305.15431536512*x6**(-0.909090909090909) - (6 + 0.2*x9**1)))/(-1)
          + u6_6 =G= 0;

dL_dx10.. (-(2305.15431536512*x6**(-0.909090909090909) - (4 + 0.167250206190075
          *x10**1.11111111111111)))/(-1) + u6_7 =G= 0;

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(-1) + u6_8 =G= 0;

dL_dx6_5.. (2095.59483215011*x6**(-1.90909090909091)*x8)/(-1) - u6_5 =E= 0;

dL_dx6_6.. (2095.59483215011*x6**(-1.90909090909091)*x9)/(-1) - u6_6 =E= 0;

dL_dx6_7.. (2095.59483215011*x6**(-1.90909090909091)*x10)/(-1) - u6_7 =E= 0;

dL_dx6_8.. (2095.59483215011*x6**(-1.90909090909091)*x11)/(-1) - u6_8 =E= 0;

* set non-default levels
x6.l = 50;
x7.l = 10;
x8.l = 10;
x9.l = 10;
x10.l = 10;
x11.l = 10;

Model m / e6.x6,dL_dx6_4.u6_4,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10
         ,dL_dx11.x11,dL_dx6_5.u6_5,dL_dx6_6.u6_6,dL_dx6_7.u6_7
         ,dL_dx6_8.u6_8 /;

File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;

$onPutV
x6
u6_4
u6_5
u6_6
u6_7
u6_8
$offPut

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

Solve m using MCP;
$offecho

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

$onecho > implSwitching_dict

********************************************************************************
 Contents
 1 Content of EMP Information File
 2 Processed EMP Information
 3 Dictionary
  3.1 Constraints
  3.2 Variables
********************************************************************************


 1 Content of EMP Information File
 ---------------------------------

     1:equilibrium
     2:implicit z defz
     3:min obj('1') q('1') z defobj('1')
     4:min obj('2') q('2') z defobj('2')
     5:min obj('3') q('3') z defobj('3')
     6:min obj('4') q('4') z defobj('4')
     7:min obj('5') q('5') z defobj('5')


 2 Processed EMP Information
 ---------------------------


 3 Dictionary
 ------------
  3.1 Constraints
  ---------------

      {reformulated}  defobj(1)
      {reformulated}  defobj(2)
      {reformulated}  defobj(3)
      {reformulated}  defobj(4)
      {reformulated}  defobj(5)
                  e6  defz
            dL_dx6_4  {new}
              dL_dx7  {new}
              dL_dx8  {new}
              dL_dx9  {new}
             dL_dx10  {new}
             dL_dx11  {new}
            dL_dx6_5  {new}
            dL_dx6_6  {new}
            dL_dx6_7  {new}
            dL_dx6_8  {new}


  3.2 Variables
 --------------

      {reformulated}  obj(1)
      {reformulated}  obj(2)
      {reformulated}  obj(3)
      {reformulated}  obj(4)
      {reformulated}  obj(5)
                  x6  z
                  x7  q(1)
                  x8  q(2)
                  x9  q(3)
                 x10  q(4)
                 x11  q(5)
                u6_4  {new}
                u6_5  {new}
                u6_6  {new}
                u6_7  {new}
                u6_8  {new}
$offecho

execute 'grep -v " written by GAMS" implSwitching_dict > implSwitchingDict.txt.want'
execute 'grep -v " written by GAMS" implSwitchingDict.txt > implSwitchingDict.txt.got'
execute '=diff -bw implSwitchingDict.txt.want implSwitchingDict.txt.got'
abort$errorlevel 'Files implSwitchingDict.txt.want and implSwitchingDict.txt.got differ';

* testing with replication
putclose opt
  'Dict         implRepDict.txt' /
  'FileName     implRep.gms'     /
  'ImplVarModel replication'     ;

solve mi using emp;
abort$[mi.solvestat <> %solvestat.NormalCompletion%]
   'wrong mi.solvestat', mi.solvestat;
abort$[mi.modelstat  > %modelstat.LocallyOptimal%]
   'wrong mi.modelstat', mi.modelstat;
abort$[ abs(obj.l('1')-199.934) > tol ]        'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')-279.716) > tol ]        'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')-346.590) > tol ]        'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')-391.279) > tol ]        'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')-410.357) > tol ]        'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')-36.933) > tol ]           'bad q.l("1")', q.l;
abort$[ abs(q.l('2')-41.818) > tol ]           'bad q.l("2")', q.l;
abort$[ abs(q.l('3')-43.707) > tol ]           'bad q.l("3")', q.l;
abort$[ abs(q.l('4')-42.659) > tol ]           'bad q.l("4")', q.l;
abort$[ abs(q.l('5')-39.179) > tol ]           'bad q.l("5")', q.l;
abort$[ abs(z.l-204.295) > tol ]               'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 10;
z.l = sum(i, q.l(i));
defobj.m(i) = 0;
defz.m = 0;

$onechoV > implRep_gms
***********************************************
* written by GAMS/JAMS at 11/17/17 15:30:43
* for more information use JAMS option "Dict"
***********************************************

Variables  x6_4,x7,x8,x9,x10,x11,x6_5,x6_6,x6_7,x6_8,u6_4,u6_5,u6_6,u6_7,u6_8;

Positive Variables  x7,x8,x9,x10,x11;

Equations  e6_4,e6_5,e6_6,e6_7,e6_8,dL_dx6_4,dL_dx7,dL_dx8,dL_dx9,dL_dx10
          ,dL_dx11,dL_dx6_5,dL_dx6_6,dL_dx6_7,dL_dx6_8;


e6_4..    x6_4 - x7 - x8 - x9 - x10 - x11 =E= 0;

e6_5..    x6_5 - x7 - x8 - x9 - x10 - x11 =E= 0;

e6_6..    x6_6 - x7 - x8 - x9 - x10 - x11 =E= 0;

e6_7..    x6_7 - x7 - x8 - x9 - x10 - x11 =E= 0;

e6_8..    x6_8 - x7 - x8 - x9 - x10 - x11 =E= 0;

dL_dx6_4.. (2095.59483215011*x6_4**(-1.90909090909091)*x7)/(-1) - u6_4 =E= 0;

dL_dx7.. (-(2305.15431536512*x6_4**(-0.909090909090909) - (10 + 
         0.261532097202366*x7**0.833333333333333)))/(-1) + u6_4 =G= 0;

dL_dx8.. (-(2305.15431536512*x6_5**(-0.909090909090909) - (8 + 
         0.231511582354131*x8**0.909090909090909)))/(-1) + u6_5 =G= 0;

dL_dx9.. (-(2305.15431536512*x6_6**(-0.909090909090909) - (6 + 0.2*x9**1))
         )/(-1) + u6_6 =G= 0;

dL_dx10.. (-(2305.15431536512*x6_7**(-0.909090909090909) - (4 + 
          0.167250206190075*x10**1.11111111111111)))/(-1) + u6_7 =G= 0;

dL_dx11.. (-(2305.15431536512*x6_8**(-0.909090909090909) - (2 + 
          0.133748060995284*x11**1.25)))/(-1) + u6_8 =G= 0;

dL_dx6_5.. (2095.59483215011*x6_5**(-1.90909090909091)*x8)/(-1) - u6_5 =E= 0;

dL_dx6_6.. (2095.59483215011*x6_6**(-1.90909090909091)*x9)/(-1) - u6_6 =E= 0;

dL_dx6_7.. (2095.59483215011*x6_7**(-1.90909090909091)*x10)/(-1) - u6_7 =E= 0;

dL_dx6_8.. (2095.59483215011*x6_8**(-1.90909090909091)*x11)/(-1) - u6_8 =E= 0;

* set non-default levels
x6_4.l = 50;
x6_5.l = 50;
x6_6.l = 50;
x6_7.l = 50;
x6_8.l = 50;
x7.l = 10;
x8.l = 10;
x9.l = 10;
x10.l = 10;
x11.l = 10;

Model m / e6_4.u6_4,e6_5.u6_5,e6_6.u6_6,e6_7.u6_7,e6_8.u6_8,dL_dx6_4.x6_4
         ,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10,dL_dx11.x11
         ,dL_dx6_5.x6_5,dL_dx6_6.x6_6,dL_dx6_7.x6_7,dL_dx6_8.x6_8 /;

File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;

$onPutV
x6_4
x6_5
x6_6
x6_7
x6_8
u6_4
u6_5
u6_6
u6_7
u6_8
$offPut

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

Solve m using MCP;
$offecho

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

$onecho > implRep_dict
* written by GAMS/JAMS at 11/17/17 15:31:17

********************************************************************************
 Contents
 1 Content of EMP Information File
 2 Processed EMP Information
 3 Dictionary
  3.1 Constraints
  3.2 Variables
********************************************************************************


 1 Content of EMP Information File
 ---------------------------------

     1:equilibrium
     2:implicit z defz
     3:min obj('1') q('1') z defobj('1')
     4:min obj('2') q('2') z defobj('2')
     5:min obj('3') q('3') z defobj('3')
     6:min obj('4') q('4') z defobj('4')
     7:min obj('5') q('5') z defobj('5')


 2 Processed EMP Information
 ---------------------------


 3 Dictionary
 ------------
  3.1 Constraints
  ---------------

      {reformulated}  defobj(1)
      {reformulated}  defobj(2)
      {reformulated}  defobj(3)
      {reformulated}  defobj(4)
      {reformulated}  defobj(5)
                e6_4  defz
                e6_5  defz
                e6_6  defz
                e6_7  defz
                e6_8  defz
            dL_dx6_4  {new}
              dL_dx7  {new}
              dL_dx8  {new}
              dL_dx9  {new}
             dL_dx10  {new}
             dL_dx11  {new}
            dL_dx6_5  {new}
            dL_dx6_6  {new}
            dL_dx6_7  {new}
            dL_dx6_8  {new}


  3.2 Variables
 --------------

      {reformulated}  obj(1)
      {reformulated}  obj(2)
      {reformulated}  obj(3)
      {reformulated}  obj(4)
      {reformulated}  obj(5)
                x6_4  z
                  x7  q(1)
                  x8  q(2)
                  x9  q(3)
                 x10  q(4)
                 x11  q(5)
                u6_4  {new}
                u6_5  {new}
                u6_6  {new}
                u6_7  {new}
                u6_8  {new}
                x6_5  z
                x6_6  z
                x6_7  z
                x6_8  z
$offecho

execute 'grep -v " written by GAMS" implRep_dict > implRepDict.txt.want'
execute 'grep -v " written by GAMS" implRepDict.txt > implRepDict.txt.got'
execute '=diff -bw implRepDict.txt.want implRepDict.txt.got'
abort$errorlevel 'Files implRepDict.txt.want and implRepDict.txt.got differ';