GAMS [ Home | Downloads | Documentation | Solvers | APIs | Tools | Model Libraries | Resources | Sales | Support | Contact Us | Search ]

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

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;

$onecho > 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 /;

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 -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     implAdjointDict.txt' /
  'FileName implAdjoint.gms' /
  'Adjoint' / ;

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;

$onecho > implAdjoint_gms
***********************************************
* written by GAMS/JAMS at 12/05/16 14:35:06
* for more information use JAMS option "Dict"
***********************************************

Variables  x6,x7,x8,x9,x10,x11,IMPL1_a4_x1,IMPL1_a5_x1,IMPL1_a6_x1,IMPL1_a7_x1
          ,IMPL1_a8_x1;

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

Equations  e6,IMPL1_a4_e1,IMPL1_a5_e1,IMPL1_a6_e1,IMPL1_a7_e1,IMPL1_a8_e1
          ,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11;


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

IMPL1_a4_e1.. (1)*(IMPL1_a4_x1) + (2095.59483215011*x6**(-1.90909090909091)*x7
              )/(-1) =E= 0;

IMPL1_a5_e1.. (1)*(IMPL1_a5_x1) + (2095.59483215011*x6**(-1.90909090909091)*x8
              )/(-1) =E= 0;

IMPL1_a6_e1.. (1)*(IMPL1_a6_x1) + (2095.59483215011*x6**(-1.90909090909091)*x9
              )/(-1) =E= 0;

IMPL1_a7_e1.. (1)*(IMPL1_a7_x1) + (2095.59483215011*x6**(-1.90909090909091)*x10
              )/(-1) =E= 0;

IMPL1_a8_e1.. (1)*(IMPL1_a8_x1) + (2095.59483215011*x6**(-1.90909090909091)*x11
              )/(-1) =E= 0;

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

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

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

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

dL_dx11.. (-(2305.15431536512*x6**(-0.909090909090909) - (2 + 0.133748060995284
          *x11**1.25)))/(-1) + (-1)*(IMPL1_a8_x1) =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,IMPL1_a4_e1.IMPL1_a4_x1,IMPL1_a5_e1.IMPL1_a5_x1
         ,IMPL1_a6_e1.IMPL1_a6_x1,IMPL1_a7_e1.IMPL1_a7_x1
         ,IMPL1_a8_e1.IMPL1_a8_x1,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10
         ,dL_dx11.x11 /;

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

Solve m using MCP;
$offecho

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

$onecho > implAdjoint_dict
* written by GAMS/JAMS at 12/05/16 14:35:06

********************************************************************************
 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
         IMPL1_a4_e1  {new}
         IMPL1_a5_e1  {new}
         IMPL1_a6_e1  {new}
         IMPL1_a7_e1  {new}
         IMPL1_a8_e1  {new}
              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)
         IMPL1_a4_x1  {new}
         IMPL1_a5_x1  {new}
         IMPL1_a6_x1  {new}
         IMPL1_a7_x1  {new}
         IMPL1_a8_x1  {new}
$offecho

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

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

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 12/05/16 14:35:44
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x2,x3,x4,x5,x6_4,x7,x8,x9,x10,x11,x6_5,x6_6,x6_7,x6_8;

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

Equations  e1,e2,e3,e4,e5,e6_4,e6_5,e6_6,e6_7,e6_8;


e1.. -(2305.15431536512*x6_4**(-0.909090909090909)*x7 - (0.142653871201291*x7**
     1.83333333333333 + 10*x7)) + x1 =E= 0;

e2.. -(2305.15431536512*x6_5**(-0.909090909090909)*x8 - (0.121267971709307*x8**
     1.90909090909091 + 8*x8)) + x2 =E= 0;

e3.. -(2305.15431536512*x6_6**(-0.909090909090909)*x9 - (0.1*x9**2 + 6*x9))
      + x3 =E= 0;

e4.. -(2305.15431536512*x6_7**(-0.909090909090909)*x10 - (0.0792237818795091*
     x10**2.11111111111111 + 4*x10)) + x4 =E= 0;

e5.. -(2305.15431536512*x6_8**(-0.909090909090909)*x11 - (0.0594435826645709*
     x11**2.25 + 2*x11)) + x5 =E= 0;

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;

* 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 / e1,e2,e3,e4,e5,e6_4,e6_5,e6_6,e6_7,e6_8 /;

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


File empinfo / '%emp.info%' /;

Put empinfo 'equilibrium' /;
Put 'min',x1,x7,x6_4,e1,e6_4 /;
Put 'min',x2,x8,x6_5,e2,e6_5 /;
Put 'min',x3,x9,x6_6,e3,e6_6 /;
Put 'min',x4,x10,x6_7,e4,e6_7 /;
Put 'min',x5,x11,x6_8,e5,e6_8 /;
Putclose empinfo;

m.optfile = 0;

Solve m using EMP;
$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 -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 12/05/16 14:35:44

********************************************************************************
 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
  ---------------

                  e1  defobj(1)
                  e2  defobj(2)
                  e3  defobj(3)
                  e4  defobj(4)
                  e5  defobj(5)
                e6_4  defz
                e6_5  defz
                e6_6  defz
                e6_7  defz
                e6_8  defz


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

                  x1  obj(1)
                  x2  obj(2)
                  x3  obj(3)
                  x4  obj(4)
                  x5  obj(5)
                x6_4  z
                  x7  q(1)
                  x8  q(2)
                  x9  q(3)
                 x10  q(4)
                 x11  q(5)
                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';

* testing with replication and matching
putclose opt
  'Dict     implRepMMDict.txt' /
  'FileName implRepMM.gms' /
  'CopyImplVar' /
  'MixMatch' /
  ;

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 > implRepMM_gms
***********************************************
* written by GAMS/JAMS at 12/05/16 14:36:19
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x2,x3,x4,x5,x6_4,x7,x8,x9,x10,x11,x6_5,x6_6,x6_7,x6_8;

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

Equations  e1,e2,e3,e4,e5,e6_4,e6_5,e6_6,e6_7,e6_8;


e1.. -(2305.15431536512*x6_4**(-0.909090909090909)*x7 - (0.142653871201291*x7**
     1.83333333333333 + 10*x7)) + x1 =E= 0;

e2.. -(2305.15431536512*x6_5**(-0.909090909090909)*x8 - (0.121267971709307*x8**
     1.90909090909091 + 8*x8)) + x2 =E= 0;

e3.. -(2305.15431536512*x6_6**(-0.909090909090909)*x9 - (0.1*x9**2 + 6*x9))
      + x3 =E= 0;

e4.. -(2305.15431536512*x6_7**(-0.909090909090909)*x10 - (0.0792237818795091*
     x10**2.11111111111111 + 4*x10)) + x4 =E= 0;

e5.. -(2305.15431536512*x6_8**(-0.909090909090909)*x11 - (0.0594435826645709*
     x11**2.25 + 2*x11)) + x5 =E= 0;

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;

* 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 / e1,e2,e3,e4,e5,e6_4,e6_5,e6_6,e6_7,e6_8 /;

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


File empinfo / '%emp.info%' /;

Put empinfo 'equilibrium' /;
Put 'min',x1,x7,x6_4,e1,e6_4 /;
Put 'min',x2,x8,x6_5,e2,e6_5 /;
Put 'min',x3,x9,x6_6,e3,e6_6 /;
Put 'min',x4,x10,x6_7,e4,e6_7 /;
Put 'min',x5,x11,x6_8,e5,e6_8 /;
Putclose empinfo;

m.optfile = 0;

Solve m using EMP;
$offecho

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

$onecho > implRepMM_dict
* written by GAMS/JAMS at 12/05/16 14:36:19

********************************************************************************
 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
  ---------------

                  e1  defobj(1)
                  e2  defobj(2)
                  e3  defobj(3)
                  e4  defobj(4)
                  e5  defobj(5)
                e6_4  defz
                e6_5  defz
                e6_6  defz
                e6_7  defz
                e6_8  defz


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

                  x1  obj(1)
                  x2  obj(2)
                  x3  obj(3)
                  x4  obj(4)
                  x5  obj(5)
                x6_4  z
                  x7  q(1)
                  x8  q(2)
                  x9  q(3)
                 x10  q(4)
                 x11  q(5)
                x6_5  z
                x6_6  z
                x6_7  z
                x6_8  z
$offecho

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