emp31.gms : Test JAMS/EMP with no followers owning implicit variables

Description

Test the case where there are no followers owning implicit variables.

Contributors: Youngdae Kim & Steve Dirkse, Feb 2018


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emp31.gms

$title 'Test JAMS/EMP with no followers owning implicit variables' (EMP31,SEQ=745)

$onText
Test the case where there are no followers owning implicit variables.

Contributors: Youngdae Kim & Steve Dirkse, Feb 2018

$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 /
    K(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 /
    ;

variables obj(i), z;
positive variables q(i);

equations
    objdef(i)
    defz
    ;

objdef(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)*K(i)**(-1/beta(i))*q(i)**((beta(i)+1)/beta(i)));

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

model m / objdef, defz /;

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

* Test with substitution.

putclose opt
    'Dict         implDict.txt' /
    'FileName     impl.gms'     /
    'ImplVarModel substitution' ;

m.optfile = 1;

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

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$[ 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) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > impl_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 12:13:07
* 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 11/18/17 12:15:35

********************************************************************************
 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:max  obj('1') q('1') z objdef('1')
     4:max  obj('2') q('2') z objdef('2')
     5:max  obj('3') q('3') z objdef('3')
     6:max  obj('4') q('4') z objdef('4')
     7:max  obj('5') q('5') z objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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';

* Test with switching.

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

m.optfile = 1;

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

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$[ 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) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implSwitching_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 12:16:33
* 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
* written by GAMS/JAMS at 11/18/17 12:19:12

********************************************************************************
 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:max  obj('1') q('1') z objdef('1')
     4:max  obj('2') q('2') z objdef('2')
     5:max  obj('3') q('3') z objdef('3')
     6:max  obj('4') q('4') z objdef('4')
     7:max  obj('5') q('5') z objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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';

* Test with replication.

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

m.optfile = 1;

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

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$[ 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) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implRep_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 12:21:00
* 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/18/17 12:21:00

********************************************************************************
 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:max  obj('1') q('1') z objdef('1')
     4:max  obj('2') q('2') z objdef('2')
     5:max  obj('3') q('3') z objdef('3')
     6:max  obj('4') q('4') z objdef('4')
     7:max  obj('5') q('5') z objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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';

* Test competitive market. (no followers owning the implicit variable z.)

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

* Test with substitution.

putclose opt
    'Dict         implCompDict.txt' /
    'FileName     implComp.gms'     /
    'ImplVarModel substitution' ;

m.optfile = 1;

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

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$[ abs(obj.l('1') - 123.834) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2') - 195.314) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3') - 257.807) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4') - 302.863) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5') - 327.591) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')   -  44.262) > tol ] 'bad q.l("1")', q.l;
abort$[ abs(q.l('2')   -  50.295) > tol ] 'bad q.l("2")', q.l;
abort$[ abs(q.l('3')   -  50.774) > tol ] 'bad q.l("3")', q.l;
abort$[ abs(q.l('4')   -  47.342) > tol ] 'bad q.l("4")', q.l;
abort$[ abs(q.l('5')   -  41.657) > tol ] 'bad q.l("5")', q.l;
abort$[ abs(z.l        - 234.333) > tol ] 'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implComp_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 12:31:28
* 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) =G= 0;

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

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

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

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(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" implComp_gms > implComp.gms.want'
execute 'grep -v " written by GAMS" implComp.gms > implComp.gms.got'
execute '=diff -I reslim -bw implComp.gms.want implComp.gms.got'
abort$errorlevel 'Files implComp.gms.want and implComp.gms.got differ';

$onEcho > implComp_dict
* written by GAMS/JAMS at 11/18/17 12:31:28

********************************************************************************
 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:max obj('1') q('1') objdef('1')
     4:max obj('2') q('2') objdef('2')
     5:max obj('3') q('3') objdef('3')
     6:max obj('4') q('4') objdef('4')
     7:max obj('5') q('5') objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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" implComp_dict > implCompdict.txt.want'
execute 'grep -v " written by GAMS" implCompDict.txt > implCompdict.txt.got'
execute '=diff -bw implCompdict.txt.want implCompdict.txt.got'
abort$errorlevel 'Files implCompdict.txt.want and implCompdict.txt.got differ';

* Test with switching.

putclose opt
    'Dict         implCompSwitchingDict.txt' /
    'FileName     implCompSwitching.gms'     /
    'ImplVarModel switching' ;

m.optfile = 1;

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

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$[ abs(obj.l('1') - 123.834) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2') - 195.314) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3') - 257.807) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4') - 302.863) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5') - 327.591) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')   -  44.262) > tol ] 'bad q.l("1")', q.l;
abort$[ abs(q.l('2')   -  50.295) > tol ] 'bad q.l("2")', q.l;
abort$[ abs(q.l('3')   -  50.774) > tol ] 'bad q.l("3")', q.l;
abort$[ abs(q.l('4')   -  47.342) > tol ] 'bad q.l("4")', q.l;
abort$[ abs(q.l('5')   -  41.657) > tol ] 'bad q.l("5")', q.l;
abort$[ abs(z.l        - 234.333) > tol ] 'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implCompSwitching_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 12:35:41
* 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) =G= 0;

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

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

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

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(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" implCompSwitching_gms > implCompSwitching.gms.want'
execute 'grep -v " written by GAMS" implCompSwitching.gms > implCompSwitching.gms.got'
execute '=diff -I reslim -bw implCompSwitching.gms.want implCompSwitching.gms.got'
abort$errorlevel 'Files implCompSwitching.gms.want and implCompSwitching.gms.got differ';

$onEcho > implCompSwitching_dict
* written by GAMS/JAMS at 11/18/17 12:35:41

********************************************************************************
 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:max obj('1') q('1') objdef('1')
     4:max obj('2') q('2') objdef('2')
     5:max obj('3') q('3') objdef('3')
     6:max obj('4') q('4') objdef('4')
     7:max obj('5') q('5') objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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" implCompSwitching_dict > implCompSwitchingDict.txt.want'
execute 'grep -v " written by GAMS" implCompSwitchingDict.txt > implCompSwitchingDict.txt.got'
execute '=diff -bw implCompSwitchingDict.txt.want implCompSwitchingDict.txt.got'
abort$errorlevel 'Files implCompSwitchingDict.txt.want and implCompSwitchingDict.txt.got differ';

* Test with replication.

putclose opt
    'Dict         implCompRepDict.txt' /
    'FileName     implCompRep.gms'     /
    'ImplVarModel replication' ;

m.optfile = 1;

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

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$[ abs(obj.l('1') - 123.834) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2') - 195.314) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3') - 257.807) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4') - 302.863) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5') - 327.591) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')   -  44.262) > tol ] 'bad q.l("1")', q.l;
abort$[ abs(q.l('2')   -  50.295) > tol ] 'bad q.l("2")', q.l;
abort$[ abs(q.l('3')   -  50.774) > tol ] 'bad q.l("3")', q.l;
abort$[ abs(q.l('4')   -  47.342) > tol ] 'bad q.l("4")', q.l;
abort$[ abs(q.l('5')   -  41.657) > tol ] 'bad q.l("5")', q.l;
abort$[ abs(z.l        - 234.333) > tol ] 'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implCompRep_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 13:26:31
* 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) =G= 0;

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

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

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

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(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" implCompRep_gms > implCompRep.gms.want'
execute 'grep -v " written by GAMS" implCompRep.gms > implCompRep.gms.got'
execute '=diff -I reslim -bw implCompRep.gms.want implCompRep.gms.got'
abort$errorlevel 'Files implCompRep.gms.want and implCompRep.gms.got differ';

$onEcho > implCompRep_dict
* written by GAMS/JAMS at 11/18/17 13:26:31

********************************************************************************
 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:max obj('1') q('1') objdef('1')
     4:max obj('2') q('2') objdef('2')
     5:max obj('3') q('3') objdef('3')
     6:max obj('4') q('4') objdef('4')
     7:max obj('5') q('5') objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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" implCompRep_dict > implCompRepDict.txt.want'
execute 'grep -v " written by GAMS" implCompRepDict.txt > implCompRepDict.txt.got'
execute '=diff -bw implCompRepDict.txt.want implCompRepDict.txt.got'
abort$errorlevel 'Files implCompRepDict.txt.want and implCompRepDict.txt.got differ';

* Test mixed market.

set own(i) / 1, 3, 5 /;

put info 'equilibrium' /;
put 'implicit z defz' /;
loop(i,
    if (own(i),
        put 'max', obj(i), q(i), z, objdef(i) /;
    else
        put 'max', obj(i), q(i), objdef(i) /;
    );
);
putclose info;

* Test with substitution.

putclose opt
    'Dict         implMixedDict.txt' /
    'FileName     implMixed.gms'     /
    'ImplVarModel substitution' ;

m.optfile = 1;

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

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$[ abs(obj.l('1') - 148.784) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2') - 248.379) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3') - 289.150) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4') - 351.387) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5') - 361.421) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')   -  32.905) > tol ] 'bad q.l("1")', q.l;
abort$[ abs(q.l('2')   -  57.043) > tol ] 'bad q.l("2")', q.l;
abort$[ abs(q.l('3')   -  41.120) > tol ] 'bad q.l("3")', q.l;
abort$[ abs(q.l('4')   -  50.794) > tol ] 'bad q.l("4")', q.l;
abort$[ abs(q.l('5')   -  37.643) > tol ] 'bad q.l("5")', q.l;
abort$[ abs(z.l        - 219.509) > tol ] 'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implMixed_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 15:09:56
* 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) =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) =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" implMixed_gms > implMixed.gms.want'
execute 'grep -v " written by GAMS" implMixed.gms > implMixed.gms.got'
execute '=diff -I reslim -bw implMixed.gms.want implMixed.gms.got'
abort$errorlevel 'Files implMixed.gms.want and implMixed.gms.got differ';

$onEcho > implMixed_dict
* written by GAMS/JAMS at 11/18/17 15:09:56

********************************************************************************
 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:max obj('1') q('1') z objdef('1')
     4:max obj('2') q('2') objdef('2')
     5:max obj('3') q('3') z objdef('3')
     6:max obj('4') q('4') objdef('4')
     7:max obj('5') q('5') z objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(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" implMixed_dict > implMixedDict.txt.want'
execute 'grep -v " written by GAMS" implMixedDict.txt > implMixedDict.txt.got'
execute '=diff -bw implMixedDict.txt.want implMixedDict.txt.got'
abort$errorlevel 'Files implMixedDict.txt.want and implMixedDict.txt.got differ';

* Test with switching.

putclose opt
    'Dict         implMixedSwitchingDict.txt' /
    'FileName     implMixedSwitching.gms'     /
    'ImplVarModel switching' ;

m.optfile = 1;

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

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$[ abs(obj.l('1') - 148.784) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2') - 248.379) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3') - 289.150) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4') - 351.387) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5') - 361.421) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(q.l('1')   -  32.905) > tol ] 'bad q.l("1")', q.l;
abort$[ abs(q.l('2')   -  57.043) > tol ] 'bad q.l("2")', q.l;
abort$[ abs(q.l('3')   -  41.120) > tol ] 'bad q.l("3")', q.l;
abort$[ abs(q.l('4')   -  50.794) > tol ] 'bad q.l("4")', q.l;
abort$[ abs(q.l('5')   -  37.643) > tol ] 'bad q.l("5")', q.l;
abort$[ abs(z.l        - 219.509) > tol ] 'bad z.l', z.l;

obj.l(i) = 0;
q.l(i) = 0;
z.l = 0;
objdef.m(i) = 0;
defz.m = 0;

$onEchoV > implMixedSwitching_gms
***********************************************
* written by GAMS/JAMS at 11/18/17 15:12:21
* for more information use JAMS option "Dict"
***********************************************

Variables  x6,x7,x8,x9,x10,x11,u6_4,u6_6,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_6,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) =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) =G= 0;

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

dL_dx6_6.. (2095.59483215011*x6**(-1.90909090909091)*x9)/(1) - u6_6 =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_6.u6_6,dL_dx6_8.u6_8 /;

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

$onPutV
x6
u6_4
u6_6
u6_8
$offPut

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

Solve m using MCP;
$offEcho

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

$onEcho > implMixedSwitching_dict
* written by GAMS/JAMS at 11/18/17 15:12:21

********************************************************************************
 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:max obj('1') q('1') z objdef('1')
     4:max obj('2') q('2') objdef('2')
     5:max obj('3') q('3') z objdef('3')
     6:max obj('4') q('4') objdef('4')
     7:max obj('5') q('5') z objdef('5')


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


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

      {reformulated}  objdef(1)
      {reformulated}  objdef(2)
      {reformulated}  objdef(3)
      {reformulated}  objdef(4)
      {reformulated}  objdef(5)
                  e6  defz
            dL_dx6_4  {new}
              dL_dx7  {new}
              dL_dx8  {new}
              dL_dx9  {new}
             dL_dx10  {new}
             dL_dx11  {new}
            dL_dx6_6  {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_6  {new}
                u6_8  {new}
$offEcho

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