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 : emp21.gms
$title 'Test JAMS/EMP on implicit variable handling' (EMP21,SEQ=703)
$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%' /;
set i agents / 1*5 /;
alias(i,ii);
parameter q(i) / 1 1.36, 2 1.5, 3 1.48, 4 1.5, 5 1.4 /;
parameter c(i) / 1 10 , 2 8 , 3 6 , 4 4 , 5 2 /;
parameter K(i) / 1 5 , 2 5 , 3 5 , 4 5 , 5 5 /;
parameter beta(i) / 1 1.2 , 2 1.1, 3 1.0 , 4 0.9, 5 0.8 /;
parameter e(i) / 1 25 , 2 25 , 3 25 , 4 25 , 5 25 /;
parameter gamma / 1.3 /;
parameter xi;
xi = sum(i, e(i));
* The scalar files generated depend on the variable declaration order,
* so do not change the declarations lightly
positive variable
y(i) production
pi price of the rare resource
;
variable
x(i) purchased rare resource
obj(i) objective variable of each agent
zExp(i) replication of z
z implicit variable
;
equation
defobjExp(i) objective function of each agent with replicated variables
defobj(i) objective function of each agent with implicit variable
defcons(i) constraint on production and trade
defequil Walas-equilibrium constraint
defzExp(i) replicated definition of z
defz definition of z
;
$macro cost(y,i) (c(i)*y(i) + \
(beta(i)/(1+beta(i)))*(K(i)**(-1/beta(i)))*(y(i)**((1+beta(i))/beta(i))))
$macro tech(y,i) ((q(i)*y(i) + sqrt(y(i)+1) - 1)$sameas(i,'1') + \
(q(i)*y(i))$(not sameas(i,'1')))
* testing with explicit formulation
$macro priceExp (5000**(1/gamma)*(zExp(i)**(-1/gamma)))
defobjExp(i)..
obj(i) =E= cost(y,i) + pi*x(i) - priceExp*y(i);
defcons(i)..
tech(y,i) =L= x(i) + e(i);
defequil..
xi - sum(i, e(i) + x(i)) =G= 0;
defzExp(i)..
zExp(i) =E= sum(ii, y(ii));
y.lo(i) = 0$(not sameas(i,'5')) + 1$sameas(i,'5');
y.up(i) = 30;
zExp.l(i) = 50;
model me 'explicit formulation' / defobjExp, defcons, defequil, defzExp /;
put info 'equilibrium';
loop(i,
put / 'min', obj(i), y(i), x(i), zExp(i);
put / defobjExp(i), defcons(i), defzExp(i);
);
put / 'vi', defequil, pi;
putclose;
putclose opt
'Dict explDict.txt' /
'FileName expl.gms' ;
me.optfile = 1;
solve me using emp;
display obj.l, y.l, x.l, zExp.l, pi.l;
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')+176.647) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+216.959) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+264.905) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')+309.177) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')+372.600) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(y.l('1')- 8.016) > tol ] 'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-13.597) > tol ] 'bad y.l("2")', y.l;
abort$[ abs(y.l('3')-18.218) > tol ] 'bad y.l("3")', y.l;
abort$[ abs(y.l('4')-21.009) > tol ] 'bad y.l("4")', y.l;
abort$[ abs(y.l('5')-23.732) > tol ] 'bad y.l("5")', y.l;
abort$[ abs(x.l('1')+12.096) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')+ 4.604) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 1.962) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(x.l('4')- 6.513) > tol ] 'bad x.l("4")', x.l;
abort$[ abs(x.l('5')- 8.224) > tol ] 'bad x.l("5")', x.l;
abort$[smax{i, abs(zExp.l(i)-84.571)} > tol ] 'bad zExp.l(i)', zExp.l;
abort$[ abs(pi.l- 6.484) > tol ] 'bad pi.l', pi.l;
obj.l(i) = 0;
y.l(i) = y.lo(i);
x.l(i) = 0;
z.l = 50;
pi.l = 0;
defobj.m(i) = 0;
defcons.m(i) = 0;
defequil.m = 0;
defz.m = 0;
$onEcho > expl_gms
***********************************************
* written by GAMS/JAMS at 12/04/16 09:42:37
* for more information use JAMS option "Dict"
***********************************************
Variables x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x17,x18,x19,x20,x21,u6,u7,u8,u9
,u10,u12,u13,u14,u15,u16;
Negative Variables u6,u7,u8,u9,u10;
Positive Variables x1,x2,x3,x4,x6;
Equations e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,dL_dx1,dL_dx2,dL_dx3,dL_dx4
,dL_dx5,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11,dL_dx17,dL_dx18,dL_dx19
,dL_dx20,dL_dx21;
e6.. sqrt(1 + x1) + 1.36*x1 - x7 =L= 26;
e7.. 1.5*x2 - x8 =L= 25;
e8.. 1.48*x3 - x9 =L= 25;
e9.. 1.5*x4 - x10 =L= 25;
e10.. 1.4*x5 - x11 =L= 25;
e11.. - x7 - x8 - x9 - x10 - x11 =G= 0;
e12.. - x1 - x2 - x3 - x4 - x5 + x17 =E= 0;
e13.. - x1 - x2 - x3 - x4 - x5 + x18 =E= 0;
e14.. - x1 - x2 - x3 - x4 - x5 + x19 =E= 0;
e15.. - x1 - x2 - x3 - x4 - x5 + x20 =E= 0;
e16.. - x1 - x2 - x3 - x4 - x5 + x21 =E= 0;
dL_dx1.. (-(10 + 0.261532097202366*x1**0.833333333333333 - 700.424843564501*x17
**(-0.769230769230769)))/(-1) - (1.36 + 0.5/sqrt(1 + x1))*u6 + u12
=N= 0;
dL_dx2.. (-(8 + 0.231511582354131*x2**0.909090909090909 - 700.424843564501*x18
**(-0.769230769230769)))/(-1) - 1.5*u7 + u13 =N= 0;
dL_dx3.. (-(6 + 0.2*x3**1 - 700.424843564501*x19**(-0.769230769230769)))/(-1)
- 1.48*u8 + u14 =N= 0;
dL_dx4.. (-(4 + 0.167250206190075*x4**1.11111111111111 - 700.424843564501*x20**
(-0.769230769230769)))/(-1) - 1.5*u9 + u15 =N= 0;
dL_dx5.. (-(2 + 0.133748060995284*x5**1.25 - 700.424843564501*x21**(-
0.769230769230769)))/(-1) - 1.4*u10 + u16 =N= 0;
dL_dx7.. (-x6)/(-1) + u6 + eps*x7 =E= 0;
dL_dx8.. (-x6)/(-1) + u7 + eps*x8 =E= 0;
dL_dx9.. (-x6)/(-1) + u8 + eps*x9 =E= 0;
dL_dx10.. (-x6)/(-1) + u9 + eps*x10 =E= 0;
dL_dx11.. (-x6)/(-1) + u10 + eps*x11 =E= 0;
dL_dx17.. (-538.788341203462*x17**(-1.76923076923077)*x1)/(-1) - u12 =E= 0;
dL_dx18.. (-538.788341203462*x18**(-1.76923076923077)*x2)/(-1) - u13 =E= 0;
dL_dx19.. (-538.788341203462*x19**(-1.76923076923077)*x3)/(-1) - u14 =E= 0;
dL_dx20.. (-538.788341203462*x20**(-1.76923076923077)*x4)/(-1) - u15 =E= 0;
dL_dx21.. (-538.788341203462*x21**(-1.76923076923077)*x5)/(-1) - u16 =E= 0;
* set non-default bounds
x1.up = 30;
x2.up = 30;
x3.up = 30;
x4.up = 30;
x5.lo = 1; x5.up = 30;
* set non-default levels
x5.l = 1;
x17.l = 50;
x18.l = 50;
x19.l = 50;
x20.l = 50;
x21.l = 50;
Model m / e6.u6,e7.u7,e8.u8,e9.u9,e10.u10,e11.x6,e12.u12,e13.u13,e14.u14
,e15.u15,e16.u16,dL_dx1.x1,dL_dx2.x2,dL_dx3.x3,dL_dx4.x4,dL_dx5.x5
,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10,dL_dx11.x11,dL_dx17.x17
,dL_dx18.x18,dL_dx19.x19,dL_dx20.x20,dL_dx21.x21 /;
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 09:42:37
********************************************************************************
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') y('1') x('1') zExp('1')
3:defobjExp('1') defcons('1') defzExp('1')
4:min obj('2') y('2') x('2') zExp('2')
5:defobjExp('2') defcons('2') defzExp('2')
6:min obj('3') y('3') x('3') zExp('3')
7:defobjExp('3') defcons('3') defzExp('3')
8:min obj('4') y('4') x('4') zExp('4')
9:defobjExp('4') defcons('4') defzExp('4')
10:min obj('5') y('5') x('5') zExp('5')
11:defobjExp('5') defcons('5') defzExp('5')
12:vi defequil pi
2 Processed EMP Information
---------------------------
Number of VI functions specified = 1
* e11 is VI Func and perpendicular to x6
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobjExp(1)
{reformulated} defobjExp(2)
{reformulated} defobjExp(3)
{reformulated} defobjExp(4)
{reformulated} defobjExp(5)
e6 defcons(1)
e7 defcons(2)
e8 defcons(3)
e9 defcons(4)
e10 defcons(5)
e11 defequil
e12 defzExp(1)
e13 defzExp(2)
e14 defzExp(3)
e15 defzExp(4)
e16 defzExp(5)
dL_dx1 {new}
dL_dx2 {new}
dL_dx3 {new}
dL_dx4 {new}
dL_dx5 {new}
dL_dx7 {new}
dL_dx8 {new}
dL_dx9 {new}
dL_dx10 {new}
dL_dx11 {new}
dL_dx17 {new}
dL_dx18 {new}
dL_dx19 {new}
dL_dx20 {new}
dL_dx21 {new}
3.2 Variables
--------------
x1 y(1)
x2 y(2)
x3 y(3)
x4 y(4)
x5 y(5)
x6 pi
x7 x(1)
x8 x(2)
x9 x(3)
x10 x(4)
x11 x(5)
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
{reformulated} obj(4)
{reformulated} obj(5)
x17 zExp(1)
x18 zExp(2)
x19 zExp(3)
x20 zExp(4)
x21 zExp(5)
u6 {new}
u7 {new}
u8 {new}
u9 {new}
u10 {new}
u12 {new}
u13 {new}
u14 {new}
u15 {new}
u16 {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';
$macro price (5000**(1/gamma)*(z**(-1/gamma)))
defobj(i)..
obj(i) =E= cost(y,i) + pi*x(i) - price*y(i);
defz..
z =E= sum(i, y(i));
model mi 'implicit formulation' / defobj, defcons, defequil, defz /;
put info 'equilibrium';
put / 'implicit z defz';
loop(i,
put / 'min', obj(i), y(i), x(i), z;
put / defobj(i), defcons(i);
);
put / 'vi', defequil, pi;
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')+176.647) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+216.959) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+264.905) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')+309.177) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')+372.600) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(y.l('1')- 8.016) > tol ] 'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-13.597) > tol ] 'bad y.l("2")', y.l;
abort$[ abs(y.l('3')-18.218) > tol ] 'bad y.l("3")', y.l;
abort$[ abs(y.l('4')-21.009) > tol ] 'bad y.l("4")', y.l;
abort$[ abs(y.l('5')-23.732) > tol ] 'bad y.l("5")', y.l;
abort$[ abs(x.l('1')+12.096) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')+ 4.604) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 1.962) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(x.l('4')- 6.513) > tol ] 'bad x.l("4")', x.l;
abort$[ abs(x.l('5')- 8.224) > tol ] 'bad x.l("5")', x.l;
abort$[ abs(z.l-84.571) > tol ] 'bad z.l', z.l;
abort$[ abs(pi.l- 6.484) > tol ] 'bad pi.l', pi.l;
obj.l(i) = 0;
y.l(i) = y.lo(i);
x.l(i) = 0;
z.l = 50;
pi.l = 0;
defobj.m(i) = 0;
defcons.m(i) = 0;
defequil.m = 0;
defz.m = 0;
$onEchoV > impl_gms
***********************************************
* written by GAMS/JAMS at 11/15/17 22:30:24
* for more information use JAMS option "Dict"
***********************************************
Variables x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x17,u6,u7,u8,u9,u10;
Negative Variables u6,u7,u8,u9,u10;
Positive Variables x1,x2,x3,x4,x6;
Equations e6,e7,e8,e9,e10,e11,e12,dL_dx1,dL_dx2,dL_dx3,dL_dx4,dL_dx5,dL_dx7
,dL_dx8,dL_dx9,dL_dx10,dL_dx11;
e6.. sqrt(1 + x1) + 1.36*x1 - x7 =L= 26;
e7.. 1.5*x2 - x8 =L= 25;
e8.. 1.48*x3 - x9 =L= 25;
e9.. 1.5*x4 - x10 =L= 25;
e10.. 1.4*x5 - x11 =L= 25;
e11.. - x7 - x8 - x9 - x10 - x11 =G= 0;
e12.. - x1 - x2 - x3 - x4 - x5 + x17 =E= 0;
dL_dx1.. (-(10 + 0.261532097202366*x1**0.833333333333333 - 700.424843564501*x17
**(-0.769230769230769)))/(-1) + ((-538.788341203462*x17**(-
1.76923076923077)*x1)/(-1))*(1) - (1.36 + 0.5/sqrt(1 + x1))*u6 =N= 0;
dL_dx2.. (-(8 + 0.231511582354131*x2**0.909090909090909 - 700.424843564501*x17
**(-0.769230769230769)))/(-1) + ((-538.788341203462*x17**(-
1.76923076923077)*x2)/(-1))*(1) - 1.5*u7 =N= 0;
dL_dx3.. (-(6 + 0.2*x3**1 - 700.424843564501*x17**(-0.769230769230769)))/(-1)
+ ((-538.788341203462*x17**(-1.76923076923077)*x3)/(-1))*(1)
- 1.48*u8 =N= 0;
dL_dx4.. (-(4 + 0.167250206190075*x4**1.11111111111111 - 700.424843564501*x17**
(-0.769230769230769)))/(-1) + ((-538.788341203462*x17**(-
1.76923076923077)*x4)/(-1))*(1) - 1.5*u9 =N= 0;
dL_dx5.. (-(2 + 0.133748060995284*x5**1.25 - 700.424843564501*x17**(-
0.769230769230769)))/(-1) + ((-538.788341203462*x17**(-
1.76923076923077)*x5)/(-1))*(1) - 1.4*u10 =N= 0;
dL_dx7.. (-x6)/(-1) + u6 + eps*x7 =E= 0;
dL_dx8.. (-x6)/(-1) + u7 + eps*x8 =E= 0;
dL_dx9.. (-x6)/(-1) + u8 + eps*x9 =E= 0;
dL_dx10.. (-x6)/(-1) + u9 + eps*x10 =E= 0;
dL_dx11.. (-x6)/(-1) + u10 + eps*x11 =E= 0;
* set non-default bounds
x1.up = 30;
x2.up = 30;
x3.up = 30;
x4.up = 30;
x5.lo = 1; x5.up = 30;
* set non-default levels
x5.l = 1;
x17.l = 50;
Model m / e6.u6,e7.u7,e8.u8,e9.u9,e10.u10,e11.x6,e12.x17,dL_dx1.x1,dL_dx2.x2
,dL_dx3.x3,dL_dx4.x4,dL_dx5.x5,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9
,dL_dx10.x10,dL_dx11.x11 /;
File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;
$onPutV
x17
$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 09:53: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') y('1') x('1') z
4:defobj('1') defcons('1')
5:min obj('2') y('2') x('2') z
6:defobj('2') defcons('2')
7:min obj('3') y('3') x('3') z
8:defobj('3') defcons('3')
9:min obj('4') y('4') x('4') z
10:defobj('4') defcons('4')
11:min obj('5') y('5') x('5') z
12:defobj('5') defcons('5')
13:vi defequil pi
2 Processed EMP Information
---------------------------
Number of VI functions specified = 1
* e11 is VI Func and perpendicular to x6
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
{reformulated} defobj(4)
{reformulated} defobj(5)
e6 defcons(1)
e7 defcons(2)
e8 defcons(3)
e9 defcons(4)
e10 defcons(5)
e11 defequil
e12 defz
dL_dx1 {new}
dL_dx2 {new}
dL_dx3 {new}
dL_dx4 {new}
dL_dx5 {new}
dL_dx7 {new}
dL_dx8 {new}
dL_dx9 {new}
dL_dx10 {new}
dL_dx11 {new}
3.2 Variables
--------------
x1 y(1)
x2 y(2)
x3 y(3)
x4 y(4)
x5 y(5)
x6 pi
x7 x(1)
x8 x(2)
x9 x(3)
x10 x(4)
x11 x(5)
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
{reformulated} obj(4)
{reformulated} obj(5)
x17 z
u6 {new}
u7 {new}
u8 {new}
u9 {new}
u10 {new}
$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')+176.647) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+216.959) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+264.905) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')+309.177) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')+372.600) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(y.l('1')- 8.016) > tol ] 'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-13.597) > tol ] 'bad y.l("2")', y.l;
abort$[ abs(y.l('3')-18.218) > tol ] 'bad y.l("3")', y.l;
abort$[ abs(y.l('4')-21.009) > tol ] 'bad y.l("4")', y.l;
abort$[ abs(y.l('5')-23.732) > tol ] 'bad y.l("5")', y.l;
abort$[ abs(x.l('1')+12.096) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')+ 4.604) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 1.962) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(x.l('4')- 6.513) > tol ] 'bad x.l("4")', x.l;
abort$[ abs(x.l('5')- 8.224) > tol ] 'bad x.l("5")', x.l;
abort$[ abs(z.l-84.571) > tol ] 'bad z.l', z.l;
abort$[ abs(pi.l- 6.484) > tol ] 'bad pi.l', pi.l;
obj.l(i) = 0;
y.l(i) = y.lo(i);
x.l(i) = 0;
z.l = 50;
pi.l = 0;
defobj.m(i) = 0;
defcons.m(i) = 0;
defequil.m = 0;
defz.m = 0;
$onEchoV > implSwitching_gms
***********************************************
* for more information use JAMS option "Dict"
***********************************************
Variables x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x17,u6,u7,u8,u9,u10,u12_4,u12_5
,u12_6,u12_7,u12_8;
Negative Variables u6,u7,u8,u9,u10;
Positive Variables x1,x2,x3,x4,x6;
Equations e6,e7,e8,e9,e10,e11,e12,dL_dx1,dL_dx2,dL_dx3,dL_dx4,dL_dx5,dL_dx7
,dL_dx8,dL_dx9,dL_dx10,dL_dx11,dL_dx17_4,dL_dx17_5,dL_dx17_6
,dL_dx17_7,dL_dx17_8;
e6.. sqrt(1 + x1) + 1.36*x1 - x7 =L= 26;
e7.. 1.5*x2 - x8 =L= 25;
e8.. 1.48*x3 - x9 =L= 25;
e9.. 1.5*x4 - x10 =L= 25;
e10.. 1.4*x5 - x11 =L= 25;
e11.. - x7 - x8 - x9 - x10 - x11 =G= 0;
e12.. - x1 - x2 - x3 - x4 - x5 + x17 =E= 0;
dL_dx1.. (-(10 + 0.261532097202366*x1**0.833333333333333 - 700.424843564501*x17
**(-0.769230769230769)))/(-1) - (1.36 + 0.5/sqrt(1 + x1))*u6 + u12_4
=N= 0;
dL_dx2.. (-(8 + 0.231511582354131*x2**0.909090909090909 - 700.424843564501*x17
**(-0.769230769230769)))/(-1) - 1.5*u7 + u12_5 =N= 0;
dL_dx3.. (-(6 + 0.2*x3**1 - 700.424843564501*x17**(-0.769230769230769)))/(-1)
- 1.48*u8 + u12_6 =N= 0;
dL_dx4.. (-(4 + 0.167250206190075*x4**1.11111111111111 - 700.424843564501*x17**
(-0.769230769230769)))/(-1) - 1.5*u9 + u12_7 =N= 0;
dL_dx5.. (-(2 + 0.133748060995284*x5**1.25 - 700.424843564501*x17**(-
0.769230769230769)))/(-1) - 1.4*u10 + u12_8 =N= 0;
dL_dx7.. (-x6)/(-1) + u6 + eps*x7 =E= 0;
dL_dx8.. (-x6)/(-1) + u7 + eps*x8 =E= 0;
dL_dx9.. (-x6)/(-1) + u8 + eps*x9 =E= 0;
dL_dx10.. (-x6)/(-1) + u9 + eps*x10 =E= 0;
dL_dx11.. (-x6)/(-1) + u10 + eps*x11 =E= 0;
dL_dx17_4.. (-538.788341203462*x17**(-1.76923076923077)*x1)/(-1) - u12_4 =E= 0;
dL_dx17_5.. (-538.788341203462*x17**(-1.76923076923077)*x2)/(-1) - u12_5 =E= 0;
dL_dx17_6.. (-538.788341203462*x17**(-1.76923076923077)*x3)/(-1) - u12_6 =E= 0;
dL_dx17_7.. (-538.788341203462*x17**(-1.76923076923077)*x4)/(-1) - u12_7 =E= 0;
dL_dx17_8.. (-538.788341203462*x17**(-1.76923076923077)*x5)/(-1) - u12_8 =E= 0;
* set non-default bounds
x1.up = 30;
x2.up = 30;
x3.up = 30;
x4.up = 30;
x5.lo = 1; x5.up = 30;
* set non-default levels
x5.l = 1;
x17.l = 50;
Model m / e6.u6,e7.u7,e8.u8,e9.u9,e10.u10,e11.x6,e12.x17,dL_dx1.x1,dL_dx2.x2
,dL_dx3.x3,dL_dx4.x4,dL_dx5.x5,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9
,dL_dx10.x10,dL_dx11.x11,dL_dx17_4.u12_4,dL_dx17_5.u12_5
,dL_dx17_6.u12_6,dL_dx17_7.u12_7,dL_dx17_8.u12_8 /;
File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;
$onPutV
x17
u12_4
u12_5
u12_6
u12_7
u12_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') y('1') x('1') z
4:defobj('1') defcons('1')
5:min obj('2') y('2') x('2') z
6:defobj('2') defcons('2')
7:min obj('3') y('3') x('3') z
8:defobj('3') defcons('3')
9:min obj('4') y('4') x('4') z
10:defobj('4') defcons('4')
11:min obj('5') y('5') x('5') z
12:defobj('5') defcons('5')
13:vi defequil pi
2 Processed EMP Information
---------------------------
Number of VI functions specified = 1
* e11 is VI Func and perpendicular to x6
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
{reformulated} defobj(4)
{reformulated} defobj(5)
e6 defcons(1)
e7 defcons(2)
e8 defcons(3)
e9 defcons(4)
e10 defcons(5)
e11 defequil
e12 defz
dL_dx1 {new}
dL_dx2 {new}
dL_dx3 {new}
dL_dx4 {new}
dL_dx5 {new}
dL_dx7 {new}
dL_dx8 {new}
dL_dx9 {new}
dL_dx10 {new}
dL_dx11 {new}
dL_dx17_4 {new}
dL_dx17_5 {new}
dL_dx17_6 {new}
dL_dx17_7 {new}
dL_dx17_8 {new}
3.2 Variables
--------------
x1 y(1)
x2 y(2)
x3 y(3)
x4 y(4)
x5 y(5)
x6 pi
x7 x(1)
x8 x(2)
x9 x(3)
x10 x(4)
x11 x(5)
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
{reformulated} obj(4)
{reformulated} obj(5)
x17 z
u6 {new}
u7 {new}
u8 {new}
u9 {new}
u10 {new}
u12_4 {new}
u12_5 {new}
u12_6 {new}
u12_7 {new}
u12_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')+176.647) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+216.959) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+264.905) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(obj.l('4')+309.177) > tol ] 'bad obj.l("4")', obj.l;
abort$[ abs(obj.l('5')+372.600) > tol ] 'bad obj.l("5")', obj.l;
abort$[ abs(y.l('1')- 8.016) > tol ] 'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-13.597) > tol ] 'bad y.l("2")', y.l;
abort$[ abs(y.l('3')-18.218) > tol ] 'bad y.l("3")', y.l;
abort$[ abs(y.l('4')-21.009) > tol ] 'bad y.l("4")', y.l;
abort$[ abs(y.l('5')-23.732) > tol ] 'bad y.l("5")', y.l;
abort$[ abs(x.l('1')+12.096) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')+ 4.604) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 1.962) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(x.l('4')- 6.513) > tol ] 'bad x.l("4")', x.l;
abort$[ abs(x.l('5')- 8.224) > tol ] 'bad x.l("5")', x.l;
abort$[ abs(z.l-84.571) > tol ] 'bad z.l', z.l;
abort$[ abs(pi.l- 6.484) > tol ] 'bad pi.l', pi.l;
obj.l(i) = 0;
y.l(i) = y.lo(i);
x.l(i) = 0;
z.l = 50;
pi.l = 0;
defobj.m(i) = 0;
defcons.m(i) = 0;
defequil.m = 0;
defz.m = 0;
$onEchoV > implRep_gms
***********************************************
* written by GAMS/JAMS at 11/17/17 15:29:39
* for more information use JAMS option "Dict"
***********************************************
Variables x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x17_4,x17_5,x17_6,x17_7,x17_8,u6
,u7,u8,u9,u10,u12_4,u12_5,u12_6,u12_7,u12_8;
Negative Variables u6,u7,u8,u9,u10;
Positive Variables x1,x2,x3,x4,x6;
Equations e6,e7,e8,e9,e10,e11,e12_4,e12_5,e12_6,e12_7,e12_8,dL_dx1,dL_dx2
,dL_dx3,dL_dx4,dL_dx5,dL_dx7,dL_dx8,dL_dx9,dL_dx10,dL_dx11,dL_dx17_4
,dL_dx17_5,dL_dx17_6,dL_dx17_7,dL_dx17_8;
e6.. sqrt(1 + x1) + 1.36*x1 - x7 =L= 26;
e7.. 1.5*x2 - x8 =L= 25;
e8.. 1.48*x3 - x9 =L= 25;
e9.. 1.5*x4 - x10 =L= 25;
e10.. 1.4*x5 - x11 =L= 25;
e11.. - x7 - x8 - x9 - x10 - x11 =G= 0;
e12_4.. - x1 - x2 - x3 - x4 - x5 + x17_4 =E= 0;
e12_5.. - x1 - x2 - x3 - x4 - x5 + x17_5 =E= 0;
e12_6.. - x1 - x2 - x3 - x4 - x5 + x17_6 =E= 0;
e12_7.. - x1 - x2 - x3 - x4 - x5 + x17_7 =E= 0;
e12_8.. - x1 - x2 - x3 - x4 - x5 + x17_8 =E= 0;
dL_dx1.. (-(10 + 0.261532097202366*x1**0.833333333333333 - 700.424843564501*
x17_4**(-0.769230769230769)))/(-1) - (1.36 + 0.5/sqrt(1 + x1))*u6 +
u12_4 =N= 0;
dL_dx2.. (-(8 + 0.231511582354131*x2**0.909090909090909 - 700.424843564501*
x17_5**(-0.769230769230769)))/(-1) - 1.5*u7 + u12_5 =N= 0;
dL_dx3.. (-(6 + 0.2*x3**1 - 700.424843564501*x17_6**(-0.769230769230769)))/(-1)
- 1.48*u8 + u12_6 =N= 0;
dL_dx4.. (-(4 + 0.167250206190075*x4**1.11111111111111 - 700.424843564501*x17_7
**(-0.769230769230769)))/(-1) - 1.5*u9 + u12_7 =N= 0;
dL_dx5.. (-(2 + 0.133748060995284*x5**1.25 - 700.424843564501*x17_8**(-
0.769230769230769)))/(-1) - 1.4*u10 + u12_8 =N= 0;
dL_dx7.. (-x6)/(-1) + u6 + eps*x7 =E= 0;
dL_dx8.. (-x6)/(-1) + u7 + eps*x8 =E= 0;
dL_dx9.. (-x6)/(-1) + u8 + eps*x9 =E= 0;
dL_dx10.. (-x6)/(-1) + u9 + eps*x10 =E= 0;
dL_dx11.. (-x6)/(-1) + u10 + eps*x11 =E= 0;
dL_dx17_4.. (-538.788341203462*x17_4**(-1.76923076923077)*x1)/(-1) - u12_4
=E= 0;
dL_dx17_5.. (-538.788341203462*x17_5**(-1.76923076923077)*x2)/(-1) - u12_5
=E= 0;
dL_dx17_6.. (-538.788341203462*x17_6**(-1.76923076923077)*x3)/(-1) - u12_6
=E= 0;
dL_dx17_7.. (-538.788341203462*x17_7**(-1.76923076923077)*x4)/(-1) - u12_7
=E= 0;
dL_dx17_8.. (-538.788341203462*x17_8**(-1.76923076923077)*x5)/(-1) - u12_8
=E= 0;
* set non-default bounds
x1.up = 30;
x2.up = 30;
x3.up = 30;
x4.up = 30;
x5.lo = 1; x5.up = 30;
* set non-default levels
x5.l = 1;
x17_4.l = 50;
x17_5.l = 50;
x17_6.l = 50;
x17_7.l = 50;
x17_8.l = 50;
Model m / e6.u6,e7.u7,e8.u8,e9.u9,e10.u10,e11.x6,e12_4.u12_4,e12_5.u12_5
,e12_6.u12_6,e12_7.u12_7,e12_8.u12_8,dL_dx1.x1,dL_dx2.x2,dL_dx3.x3
,dL_dx4.x4,dL_dx5.x5,dL_dx7.x7,dL_dx8.x8,dL_dx9.x9,dL_dx10.x10
,dL_dx11.x11,dL_dx17_4.x17_4,dL_dx17_5.x17_5,dL_dx17_6.x17_6
,dL_dx17_7.x17_7,dL_dx17_8.x17_8 /;
File implvarfile / '%gams.scrdir%implvar.dat' /;
Put implvarfile;
$onPutV
x17_4
x17_5
x17_6
x17_7
x17_8
u12_4
u12_5
u12_6
u12_7
u12_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:30:23
********************************************************************************
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') y('1') x('1') z
4:defobj('1') defcons('1')
5:min obj('2') y('2') x('2') z
6:defobj('2') defcons('2')
7:min obj('3') y('3') x('3') z
8:defobj('3') defcons('3')
9:min obj('4') y('4') x('4') z
10:defobj('4') defcons('4')
11:min obj('5') y('5') x('5') z
12:defobj('5') defcons('5')
13:vi defequil pi
2 Processed EMP Information
---------------------------
Number of VI functions specified = 1
* e11 is VI Func and perpendicular to x6
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
{reformulated} defobj(4)
{reformulated} defobj(5)
e6 defcons(1)
e7 defcons(2)
e8 defcons(3)
e9 defcons(4)
e10 defcons(5)
e11 defequil
e12_4 defz
e12_5 defz
e12_6 defz
e12_7 defz
e12_8 defz
dL_dx1 {new}
dL_dx2 {new}
dL_dx3 {new}
dL_dx4 {new}
dL_dx5 {new}
dL_dx7 {new}
dL_dx8 {new}
dL_dx9 {new}
dL_dx10 {new}
dL_dx11 {new}
dL_dx17_4 {new}
dL_dx17_5 {new}
dL_dx17_6 {new}
dL_dx17_7 {new}
dL_dx17_8 {new}
3.2 Variables
--------------
x1 y(1)
x2 y(2)
x3 y(3)
x4 y(4)
x5 y(5)
x6 pi
x7 x(1)
x8 x(2)
x9 x(3)
x10 x(4)
x11 x(5)
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
{reformulated} obj(4)
{reformulated} obj(5)
x17_4 z
u6 {new}
u7 {new}
u8 {new}
u9 {new}
u10 {new}
u12_4 {new}
u12_5 {new}
u12_6 {new}
u12_7 {new}
u12_8 {new}
x17_5 z
x17_6 z
x17_7 z
x17_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';