Description
Test JAMS behavior on a small equilibrium model with shared constraints. Contributors: Youngdae Kim & Steve Dirkse, Dec 2016
Small Model of Type : GAMS
Category : GAMS Test library
Main file : emp26.gms
$title 'Test JAMS/EMP on implicit variable handling' (EMP26,SEQ=708)
$onText
Test JAMS behavior on a small equilibrium model with shared constraints.
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*3 /;
alias(i,ii);
parameter alpha(i) / 1 0.01, 2 0.05, 3 0.01 /;
parameter xi(i) / 1 2.9 , 2 2.88, 3 2.85 /;
variable obj(i);
positive variable x(i);
equation
defobj(i)
defshared1Exp(i) 'copy of shared1 equation for agent i'
defshared2Exp(i) 'copy of shared2 equation for agent i'
defshared1 'shared equation'
defshared2 'shared equation'
defobjFlip1(i) 'objective definition for flipping test'
defobjFlip2(i) 'objective definition for flipping test'
;
defobj(i)..
obj(i) =E= (alpha(i)*x(i) + 0.01*sum(ii, x(ii)) - xi(i))*x(i);
defshared1Exp(i)..
-100 =L= -3.25*x('1') - 1.25*x('2') - 4.125*x('3');
defshared2Exp(i)..
-100 =L= -2.2915*x('1') - 1.5625*x('2') - 2.8125*x('3');
* test with replication
model me 'explicit formulation' / defobj, defshared1Exp, defshared2Exp /;
put info 'equilibrium' /;
loop(i,
put 'min', obj(i), x(i), defobj(i), defshared1Exp(i), defshared2Exp(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')- 0) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+14.687) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+52.129) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')- 0) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')- 6.473) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')-22.281) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(defshared1Exp.m('1')+0.804) > tol ]
'bad defshared1Exp.m("1")', defshared1Exp.m;
abort$[ abs(defshared1Exp.m('2')+1.504) > tol ]
'bad defshared1Exp.m("2")', defshared1Exp.m;
abort$[ abs(defshared1Exp.m('3')+0.459) > tol ]
'bad defshared1Exp.m("3")', defshared1Exp.m;
abort$[ smax{i, abs(defshared2Exp.m(i)- 0)} > tol ]
'bad defshared2Exp.m("i")', defshared2Exp.m;
obj.l(i) = 0;
x.l(i) = 0;
defobj.m(i) = 0;
$onEcho > expl_gms
***********************************************
* written by GAMS/JAMS at 12/03/16 19:30:41
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4,u5,u6,u7,u8,u9;
Negative Variables u4,u5,u6,u7,u8,u9;
Positive Variables x4,x5,x6;
Equations e4,e5,e6,e7,e8,e9,dL_dx4,dL_dx5,dL_dx6;
e4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e6.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e7.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e8.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e9.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4
- 2.2915*u7 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u5
- 1.5625*u8 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u6
- 2.8125*u9 =G= 0;
Model m / e4.u4,e5.u5,e6.u6,e7.u7,e8.u8,e9.u9,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" 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/03/16 19:40:04
********************************************************************************
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') x('1') defobj('1') defshared1Exp('1') defshared2Exp('1')
3:min obj('2') x('2') defobj('2') defshared1Exp('2') defshared2Exp('2')
4:min obj('3') x('3') defobj('3') defshared1Exp('3') defshared2Exp('3')
2 Processed EMP Information
---------------------------
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
e4 defshared1Exp(1)
e5 defshared1Exp(2)
e6 defshared1Exp(3)
e7 defshared2Exp(1)
e8 defshared2Exp(2)
e9 defshared2Exp(3)
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4 {new}
u5 {new}
u6 {new}
u7 {new}
u8 {new}
u9 {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';
* test with GNEP type shared constraint
defshared1..
-100 =L= -3.25*x('1') - 1.25*x('2') - 4.125*x('3');
defshared2..
-100 =L= -2.2915*x('1') - 1.5625*x('2') - 2.8125*x('3');
model ms / defobj, defshared1, defshared2 /;
put info 'equilibrium' /;
loop(i,
put 'min', obj(i), x(i), defobj(i), defshared1, defshared2 /;
);
putclose;
putclose opt
'Dict sharedGNEPDict.txt' /
'FileName sharedGNEP.gms' /
'SharedEqu' ;
ms.optfile = 1;
solve ms using emp;
abort$[ms.solvestat <> %solveStat.normalCompletion%]
'wrong ms.solvestat', ms.solvestat;
abort$[ms.modelstat <> %modelStat.locallyOptimal%]
'wrong ms.modelstat', ms.modelstat;
abort$[ abs(obj.l('1')- 0) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+14.687) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+52.129) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')- 0) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')- 6.473) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')-22.281) > tol ] 'bad x.l("3")', x.l;
parameter defshared1_m(i), defshared2_m(i);
execute_load '%gams.scrdir%/ugdx.dat', defshared1_m=defshared1, defshared2_m=defshared2;
abort$[ abs(defshared1_m('1')+0.804) > tol ]
'bad defshared1_m("1")', defshared1_m;
abort$[ abs(defshared1_m('2')+1.504) > tol ]
'bad defshared1_m("2")', defshared1_m;
abort$[ abs(defshared1_m('3')+0.459) > tol ]
'bad defshared1_m("3")', defshared1_m;
abort$[ smax{i, abs(defshared2_m(i)- 0)} > tol ]
'bad defshared2_m("i")', defshared2_m;
obj.l(i) = 0;
x.l(i) = 0;
defobj.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedGNEP_gms
***********************************************
* written by GAMS/JAMS at 12/05/16 14:45:02
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4_4,u5_4,u4_5,u4_6,u5_5,u5_6;
Negative Variables u4_4,u5_4,u4_5,u4_6,u5_5,u5_6;
Positive Variables x4,x5,x6;
Equations e4_4,e5_4,e4_5,e4_6,e5_5,e5_6,dL_dx4,dL_dx5,dL_dx6;
e4_4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5_4.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e4_5.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e4_6.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5_5.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e5_6.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4_4
- 2.2915*u5_4 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u4_5
- 1.5625*u5_5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u4_6
- 2.8125*u5_6 =G= 0;
Model m / e4_4.u4_4,e5_4.u5_4,e4_5.u4_5,e4_6.u4_6,e5_5.u5_5,e5_6.u5_6
,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedGNEP_gms > sharedGNEP.gms.want'
execute 'grep -v " written by GAMS" sharedGNEP.gms > sharedGNEP.gms.got'
execute '=diff -I reslim -bw sharedGNEP.gms.want sharedGNEP.gms.got'
abort$errorlevel 'Files sharedGNEP.gms.want and sharedGNEP.gms.got differ';
$onEcho > sharedGNEP_dict
* written by GAMS/JAMS at 12/05/16 14:45:02
********************************************************************************
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') x('1') defobj('1') defshared1 defshared2
3:min obj('2') x('2') defobj('2') defshared1 defshared2
4:min obj('3') x('3') defobj('3') defshared1 defshared2
2 Processed EMP Information
---------------------------
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
e4_4 defshared1
e5_4 defshared2
e4_5 defshared1
e4_6 defshared1
e5_5 defshared2
e5_6 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4_4 {new}
u5_4 {new}
u4_5 {new}
u4_6 {new}
u5_5 {new}
u5_6 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedGNEP_dict > sharedGNEPdict.txt.want'
execute 'grep -v " written by GAMS" sharedGNEPDict.txt > sharedGNEPdict.txt.got'
execute '=diff -bw sharedGNEPdict.txt.want sharedGNEPdict.txt.got'
abort$errorlevel 'Files sharedGNEPdict.txt.want and sharedGNEPdict.txt.got differ';
* test with VI type shared constraint
put info 'equilibrium' /;
put 'visol defshared1 defshared2' /;
loop(i,
put 'min', obj(i), x(i), defobj(i), defshared1, defshared2 /;
);
putclose;
putclose opt
'Dict sharedVIDict.txt' /
'FileName sharedVI.gms' /
'SharedEqu';
ms.optfile = 1;
solve ms using emp;
abort$[ms.solvestat <> %solveStat.normalCompletion%]
'wrong ms.solvestat', ms.solvestat;
abort$[ms.modelstat <> %modelStat.locallyOptimal%]
'wrong ms.modelstat', ms.modelstat;
abort$[ abs(obj.l('1')+48.412) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+26.921) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+ 6.607) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')-21.145) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')-16.028) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 2.726) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(defshared1.m+.574) > tol ] 'bad defshared1.m', defshared1.m;
abort$[ abs(defshared2.m-0) > tol ] 'bad defshared2.m', defshared2.m;
obj.l(i) = 0;
x.l(i) = 0;
defobj.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedVI_gms
***********************************************
* written by GAMS/JAMS at 12/04/16 22:57:52
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4,u5;
Negative Variables u4,u5;
Positive Variables x4,x5,x6;
Equations e4,e5,dL_dx4,dL_dx5,dL_dx6;
e4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4
- 2.2915*u5 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u4
- 1.5625*u5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u4
- 2.8125*u5 =G= 0;
Model m / e4.u4,e5.u5,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedVI_gms > sharedVI.gms.want'
execute 'grep -v " written by GAMS" sharedVI.gms > sharedVI.gms.got'
execute '=diff -I reslim -bw sharedVI.gms.want sharedVI.gms.got'
abort$errorlevel 'Files sharedVI.gms.want and sharedVI.gms.got differ';
$onEcho > sharedVI_dict
* written by GAMS/JAMS at 12/04/16 22:57:52
********************************************************************************
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:visol defshared1 defshared2
3:min obj('1') x('1') defobj('1') defshared1 defshared2
4:min obj('2') x('2') defobj('2') defshared1 defshared2
5:min obj('3') x('3') defobj('3') defshared1 defshared2
2 Processed EMP Information
---------------------------
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobj(1)
{reformulated} defobj(2)
{reformulated} defobj(3)
e4 defshared1
e5 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4 {new}
u5 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedVI_dict > sharedVIdict.txt.want'
execute 'grep -v " written by GAMS" sharedVIDict.txt > sharedVIdict.txt.got'
execute '=diff -bw sharedVIdict.txt.want sharedVIdict.txt.got'
abort$errorlevel 'Files sharedVIdict.txt.want and sharedVIdict.txt.got differ';
* objective functions to test with flipping:
* In defobjFlip1, the second agent maximizes.
* In defobjFlip2, the second and third agents maximizes.
* These changes are made to make the multiplier sign consistent for VI case.
defobjFlip1(i)..
(obj(i))$(ord(i) ne 2) + (-obj(i))$(ord(i) eq 2) =E=
(alpha(i)*x(i) + 0.01*sum(ii, x(ii)) - xi(i))*x(i);
defobjFlip2(i)..
(obj(i))$(ord(i) eq 1) + (-obj(i))$(ord(i) ne 1) =E=
(alpha(i)*x(i) + 0.01*sum(ii, x(ii)) - xi(i))*x(i);
model mf1 / defobjFlip1, defshared1, defshared2 /;
model mf2 / defobjFlip2, defshared1, defshared2 /;
mf1.optfile = 1;
mf2.optfile = 1;
* testing GNEP constraint with flipping:
* In whatever way we flip, it should give us a correct solution.
put info 'equilibrium' /;
put 'min', obj('1'), x('1');
put defobjFlip1('1'), defshared1, '-defshared2' /;
put 'max', obj('2'), x('2');
put defobjFlip1('2'), '-defshared1', '-defshared2' /;
put 'min', obj('3'), x('3');
put defobjFlip1('3'), '-defshared1', defshared2 /;
putclose;
putclose opt
'Dict sharedGNEPFlip1Dict.txt' /
'FileName sharedGNEPFlip1.gms' /
'SharedEqu' ;
solve mf1 using emp;
obj.l(i)$(ord(i) eq 2) = -obj.l(i);
abort$[mf1.solvestat <> %solveStat.normalCompletion%]
'wrong mf1.solvestat', mf1.solvestat;
abort$[mf1.modelstat <> %modelStat.locallyOptimal%]
'wrong mf1.modelstat', mf1.modelstat;
abort$[ abs(obj.l('1')- 0) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+14.687) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+52.129) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')- 0) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')- 6.473) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')-22.281) > tol ] 'bad x.l("3")', x.l;
parameter defshared1_m(i), defshared2_m(i);
execute_load '%gams.scrdir%/ugdx.dat', defshared1_m=defshared1, defshared2_m=defshared2;
abort$[ abs(defshared1_m('1')+0.804) > tol ]
'bad defshared1_m("1")', defshared1_m;
abort$[ abs(defshared1_m('2')+1.504) > tol ]
'bad defshared1_m("2")', defshared1_m;
abort$[ abs(defshared1_m('3')-0.459) > tol ]
'bad defshared1_m("3")', defshared1_m;
abort$[ smax{i, abs(defshared2_m(i)- 0)} > tol ]
'bad defshared2_m("i")', defshared2_m;
obj.l(i) = 0;
x.l(i) = 0;
defobjFlip1.m(i) = 0;
defobjFlip2.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedGNEPFlip1_gms
***********************************************
* written by GAMS/JAMS at 12/06/16 14:40:18
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4_4,u5_4,u4_5,u4_6,u5_5,u5_6;
Negative Variables u4_4,u4_5,u5_5,u5_6;
Positive Variables x4,x5,x6;
Positive Variables u5_4,u4_6;
Equations e4_4,e5_4,e4_5,e4_6,e5_5,e5_6,dL_dx4,dL_dx5,dL_dx6;
e4_4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5_4.. 100 =G= 2.2915*x4 + 1.5625*x5 + 2.8125*x6;
e4_5.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e4_6..100 =G= 3.25*x4 + 1.25*x5 + 4.125*x6;
e5_5.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e5_6.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4_4
+ 2.2915*u5_4 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u4_5
- 1.5625*u5_5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) + 4.125*u4_6
- 2.8125*u5_6 =G= 0;
Model m / e4_4.u4_4,e5_4.u5_4,e4_5.u4_5,e4_6.u4_6,e5_5.u5_5,e5_6.u5_6
,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedGNEPFlip1_gms > sharedGNEPFlip1.gms.want'
execute 'grep -v " written by GAMS" sharedGNEPFlip1.gms > sharedGNEPFlip1.gms.got'
execute '=diff -I reslim -bw sharedGNEPFlip1.gms.want sharedGNEPFlip1.gms.got'
abort$errorlevel 'Files sharedGNEPFlip1.gms.want and sharedGNEPFlip1.gms.got differ';
$onEcho > sharedGNEPFlip1_dict
* written by GAMS/JAMS at 12/06/16 14:40:18
********************************************************************************
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') x('1') defobjFlip1('1') defshared1 -defshared2
3:max obj('2') x('2') defobjFlip1('2') -defshared1 -defshared2
4:min obj('3') x('3') defobjFlip1('3') -defshared1 defshared2
2 Processed EMP Information
---------------------------
Number of constraints to be flipped = 4
* e5_4 will be flipped internally
* e4_5 will be flipped internally
* e4_6 will be flipped internally
* e5_5 will be flipped internally
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobjFlip1(1)
{reformulated} defobjFlip1(2)
{reformulated} defobjFlip1(3)
e4_4 defshared1
e5_4 defshared2
e4_5 defshared1
e4_6 defshared1
e5_5 defshared2
e5_6 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4_4 {new}
u5_4 {new}
u4_5 {new}
u4_6 {new}
u5_5 {new}
u5_6 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedGNEPFlip1_dict > sharedGNEPFlip1dict.txt.want'
execute 'grep -v " written by GAMS" sharedGNEPFlip1Dict.txt > sharedGNEPFlip1dict.txt.got'
execute '=diff -bw sharedGNEPFlip1dict.txt.want sharedGNEPFlip1dict.txt.got'
abort$errorlevel 'Files sharedGNEPFlip1dict.txt.want and sharedGNEPFlip1dict.txt.got differ';
* another testing GNEP constraint with flipping:
* In whatever way we flip, it should give us a correct solution.
put info 'equilibrium' /;
put 'min', obj('1'), x('1');
put defobjFlip2('1'), '-defshared1', defshared2 /;
put 'max', obj('2'), x('2');
put defobjFlip2('2'), defshared1, '-defshared2' /;
put 'max', obj('3'), x('3');
put defobjFlip2('3'), '-defshared1', defshared2 /;
putclose;
putclose opt
'Dict sharedGNEPFlip2Dict.txt' /
'FileName sharedGNEPFlip2.gms' /
'SharedEqu' ;
solve mf2 using emp;
obj.l(i)$(ord(i) ne 1) = -obj.l(i);
abort$[mf2.solvestat <> %solveStat.normalCompletion%]
'wrong mf2.solvestat', mf2.solvestat;
abort$[mf2.modelstat <> %modelStat.locallyOptimal%]
'wrong mf2.modelstat', mf2.modelstat;
abort$[ abs(obj.l('1')- 0) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+14.687) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+52.129) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')- 0) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')- 6.473) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')-22.281) > tol ] 'bad x.l("3")', x.l;
parameter defshared1_m(i), defshared2_m(i);
execute_load '%gams.scrdir%/ugdx.dat', defshared1_m=defshared1, defshared2_m=defshared2;
abort$[ abs(defshared1_m('1')-0.804) > tol ]
'bad defshared1_m("1")', defshared1_m;
abort$[ abs(defshared1_m('2')-1.504) > tol ]
'bad defshared1_m("2")', defshared1_m;
abort$[ abs(defshared1_m('3')+0.459) > tol ]
'bad defshared1_m("3")', defshared1_m;
abort$[ smax{i, abs(defshared2_m(i)- 0)} > tol ]
'bad defshared2_m("i")', defshared2_m;
obj.l(i) = 0;
x.l(i) = 0;
defobjFlip1.m(i) = 0;
defobjFlip2.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedGNEPFlip2_gms
***********************************************
* written by GAMS/JAMS at 12/06/16 14:48:57
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4_4,u5_4,u4_5,u4_6,u5_5,u5_6;
Negative Variables u5_4,u4_6,u5_5;
Positive Variables x4,x5,x6;
Positive Variables u4_4,u4_5,u5_6;
Equations e4_4,e5_4,e4_5,e4_6,e5_5,e5_6,dL_dx4,dL_dx5,dL_dx6;
e4_4.. 100 =G= 3.25*x4 + 1.25*x5 + 4.125*x6;
e5_4.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e4_5..100 =G= 3.25*x4 + 1.25*x5 + 4.125*x6;
e4_6.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5_5.. 2.2915*x4 + 1.5625*x5 + 2.8125*x6 =L= 100;
e5_6..100 =G= 2.2915*x4 + 1.5625*x5 + 2.8125*x6;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) + 3.25*u4_4
- 2.2915*u5_4 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) + 1.25*u4_5
- 1.5625*u5_5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u4_6
+ 2.8125*u5_6 =G= 0;
Model m / e4_4.u4_4,e5_4.u5_4,e4_5.u4_5,e4_6.u4_6,e5_5.u5_5,e5_6.u5_6
,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedGNEPFlip2_gms > sharedGNEPFlip2.gms.want'
execute 'grep -v " written by GAMS" sharedGNEPFlip2.gms > sharedGNEPFlip2.gms.got'
execute '=diff -I reslim -bw sharedGNEPFlip2.gms.want sharedGNEPFlip2.gms.got'
abort$errorlevel 'Files sharedGNEPFlip2.gms.want and sharedGNEPFlip2.gms.got differ';
$onEcho > sharedGNEPFlip2_dict
* written by GAMS/JAMS at 12/06/16 14:48:57
********************************************************************************
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') x('1') defobjFlip2('1') -defshared1 defshared2
3:max obj('2') x('2') defobjFlip2('2') defshared1 -defshared2
4:max obj('3') x('3') defobjFlip2('3') -defshared1 defshared2
2 Processed EMP Information
---------------------------
Number of constraints to be flipped = 3
* e4_4 will be flipped internally
* e4_6 will be flipped internally
* e5_5 will be flipped internally
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobjFlip2(1)
{reformulated} defobjFlip2(2)
{reformulated} defobjFlip2(3)
e4_4 defshared1
e5_4 defshared2
e4_5 defshared1
e4_6 defshared1
e5_5 defshared2
e5_6 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4_4 {new}
u5_4 {new}
u4_5 {new}
u4_6 {new}
u5_5 {new}
u5_6 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedGNEPFlip2_dict > sharedGNEPFlip2dict.txt.want'
execute 'grep -v " written by GAMS" sharedGNEPFlip2Dict.txt > sharedGNEPFlip2dict.txt.got'
execute '=diff -bw sharedGNEPFlip2dict.txt.want sharedGNEPFlip2dict.txt.got'
abort$errorlevel 'Files sharedGNEPFlip2dict.txt.want and sharedGNEPFlip2dict.txt.got differ';
* testing VI constraint with flipping:
* Agents flip constraint but they result in all the same sign, thus correct.
put info 'equilibrium' /;
put 'visol defshared1 defshared2' /;
put 'min', obj('1'), x('1');
put defobjFlip1('1'), defshared1, '-defshared2' /;
put 'max', obj('2'), x('2');
put defobjFlip1('2'), '-defshared1', defshared2 /;
put 'min', obj('3'), x('3');
put defobjFlip1('3'), defshared1, '-defshared2' /;
putclose;
putclose opt
'Dict sharedVIFlip1Dict.txt' /
'FileName sharedVIFlip1.gms' /
'SharedEqu';
solve mf1 using emp;
obj.l(i)$(ord(i) eq 2) = -obj.l(i);
abort$[mf1.solvestat <> %solveStat.normalCompletion%]
'wrong mf1.solvestat', mf1.solvestat;
abort$[mf1.modelstat <> %modelStat.locallyOptimal%]
'wrong mf1.modelstat', mf1.modelstat;
abort$[ abs(obj.l('1')+48.412) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+26.921) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+ 6.607) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')-21.145) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')-16.028) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 2.726) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(defshared1.m+.574) > tol ] 'bad defshared1.m', defshared1.m;
abort$[ abs(defshared2.m-0) > tol ] 'bad defshared2.m', defshared2.m;
obj.l(i) = 0;
x.l(i) = 0;
defobjFlip1.m(i) = 0;
defobjFlip2.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedVIFlip1_gms
***********************************************
* written by GAMS/JAMS at 12/06/16 14:53:24
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4,u5;
Negative Variables u4;
Positive Variables x4,x5,x6;
Positive Variables u5;
Equations e4,e5,dL_dx4,dL_dx5,dL_dx6;
e4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5.. 100 =G= 2.2915*x4 + 1.5625*x5 + 2.8125*x6;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4 +
2.2915*u5 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u4 +
1.5625*u5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u4
+ 2.8125*u5 =G= 0;
Model m / e4.u4,e5.u5,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedVIFlip1_gms > sharedVIFlip1.gms.want'
execute 'grep -v " written by GAMS" sharedVIFlip1.gms > sharedVIFlip1.gms.got'
execute '=diff -I reslim -bw sharedVIFlip1.gms.want sharedVIFlip1.gms.got'
abort$errorlevel 'Files sharedVIFlip1.gms.want and sharedVIFlip1.gms.got differ';
$onEcho > sharedVIFlip1_dict
* written by GAMS/JAMS at 12/06/16 14:53:24
********************************************************************************
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:visol defshared1 defshared2
3:min obj('1') x('1') defobjFlip1('1') defshared1 -defshared2
4:max obj('2') x('2') defobjFlip1('2') -defshared1 defshared2
5:min obj('3') x('3') defobjFlip1('3') defshared1 -defshared2
2 Processed EMP Information
---------------------------
Number of constraints to be flipped = 1
* e5 will be flipped internally
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobjFlip1(1)
{reformulated} defobjFlip1(2)
{reformulated} defobjFlip1(3)
e4 defshared1
e5 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4 {new}
u5 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedVIFlip1_dict > sharedVIFlip1dict.txt.want'
execute 'grep -v " written by GAMS" sharedVIFlip1Dict.txt > sharedVIFlip1dict.txt.got'
execute '=diff -bw sharedVIFlip1dict.txt.want sharedVIFlip1dict.txt.got'
abort$errorlevel 'Files sharedVIFlip1dict.txt.want and sharedVIFlip1dict.txt.got differ';
* another testing VI constraint with flipping:
* Agents flip constraint but they result in all the same sign, thus correct.
put info 'equilibrium' /;
put 'visol defshared1 defshared2' /;
put 'min', obj('1'), x('1');
put defobjFlip2('1'), defshared1, '-defshared2' /;
put 'max', obj('2'), x('2');
put defobjFlip2('2'), '-defshared1', defshared2 /;
put 'max', obj('3'), x('3');
put defobjFlip2('3'), '-defshared1', defshared2 /;
putclose;
putclose opt
'Dict sharedVIFlip2Dict.txt' /
'FileName sharedVIFlip2.gms' /
'SharedEqu';
solve mf2 using emp;
obj.l(i)$(ord(i) ne 1) = -obj.l(i);
abort$[mf2.solvestat <> %solveStat.normalCompletion%]
'wrong mf2.solvestat', mf2.solvestat;
abort$[mf2.modelstat <> %modelStat.locallyOptimal%]
'wrong mf2.modelstat', mf2.modelstat;
abort$[ abs(obj.l('1')+48.412) > tol ] 'bad obj.l("1")', obj.l;
abort$[ abs(obj.l('2')+26.921) > tol ] 'bad obj.l("2")', obj.l;
abort$[ abs(obj.l('3')+ 6.607) > tol ] 'bad obj.l("3")', obj.l;
abort$[ abs(x.l('1')-21.145) > tol ] 'bad x.l("1")', x.l;
abort$[ abs(x.l('2')-16.028) > tol ] 'bad x.l("2")', x.l;
abort$[ abs(x.l('3')- 2.726) > tol ] 'bad x.l("3")', x.l;
abort$[ abs(defshared1.m+.574) > tol ] 'bad defshared1.m', defshared1.m;
abort$[ abs(defshared2.m-0) > tol ] 'bad defshared2.m', defshared2.m;
obj.l(i) = 0;
x.l(i) = 0;
defobjFlip1.m(i) = 0;
defobjFlip2.m(i) = 0;
defshared1.m = 0;
defshared2.m = 0;
$onEcho > sharedVIFlip2_gms
***********************************************
* written by GAMS/JAMS at 12/06/16 14:58:38
* for more information use JAMS option "Dict"
***********************************************
Variables x4,x5,x6,u4,u5;
Negative Variables u4;
Positive Variables x4,x5,x6;
Positive Variables u5;
Equations e4,e5,dL_dx4,dL_dx5,dL_dx6;
e4.. 3.25*x4 + 1.25*x5 + 4.125*x6 =L= 100;
e5.. 100 =G= 2.2915*x4 + 1.5625*x5 + 2.8125*x6;
dL_dx4.. (-(0.02*x4 + (-2.9) + 0.02*x4 + 0.01*x5 + 0.01*x6))/(-1) - 3.25*u4 +
2.2915*u5 =G= 0;
dL_dx5.. (-(0.06*x5 + (-2.88) + 0.01*x4 + 0.06*x5 + 0.01*x6))/(-1) - 1.25*u4 +
1.5625*u5 =G= 0;
dL_dx6.. (-(0.02*x6 + (-2.85) + 0.01*x4 + 0.01*x5 + 0.02*x6))/(-1) - 4.125*u4
+ 2.8125*u5 =G= 0;
Model m / e4.u4,e5.u5,dL_dx4.x4,dL_dx5.x5,dL_dx6.x6 /;
m.limrow=0; m.limcol=0;
Solve m using MCP;
$offEcho
execute 'grep -v " written by GAMS" sharedVIFlip2_gms > sharedVIFlip2.gms.want'
execute 'grep -v " written by GAMS" sharedVIFlip2.gms > sharedVIFlip2.gms.got'
execute '=diff -I reslim -bw sharedVIFlip2.gms.want sharedVIFlip2.gms.got'
abort$errorlevel 'Files sharedVIFlip2.gms.want and sharedVIFlip2.gms.got differ';
$onEcho > sharedVIFlip2_dict
* written by GAMS/JAMS at 12/06/16 14:58:38
********************************************************************************
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:visol defshared1 defshared2
3:min obj('1') x('1') defobjFlip2('1') defshared1 -defshared2
4:max obj('2') x('2') defobjFlip2('2') -defshared1 defshared2
5:max obj('3') x('3') defobjFlip2('3') -defshared1 defshared2
2 Processed EMP Information
---------------------------
Number of constraints to be flipped = 1
* e5 will be flipped internally
3 Dictionary
------------
3.1 Constraints
---------------
{reformulated} defobjFlip2(1)
{reformulated} defobjFlip2(2)
{reformulated} defobjFlip2(3)
e4 defshared1
e5 defshared2
dL_dx4 {new}
dL_dx5 {new}
dL_dx6 {new}
3.2 Variables
--------------
{reformulated} obj(1)
{reformulated} obj(2)
{reformulated} obj(3)
x4 x(1)
x5 x(2)
x6 x(3)
u4 {new}
u5 {new}
$offEcho
execute 'grep -v " written by GAMS" sharedVIFlip2_dict > sharedVIFlip2dict.txt.want'
execute 'grep -v " written by GAMS" sharedVIFlip2Dict.txt > sharedVIFlip2dict.txt.got'
execute '=diff -bw sharedVIFlip2dict.txt.want sharedVIFlip2dict.txt.got'
abort$errorlevel 'Files sharedVIFlip2dict.txt.want and sharedVIFlip2dict.txt.got differ';