emp29.gms : Test JAMS/EMP on QVI model

Description

Test JAMS behavior on a small QVI model.

Contributors: Youngdae Kim & Steve Dirkse, Feb 2018


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emp29.gms

$TITLE 'Test JAMS/EMP on QVI model' (EMP29,SEQ=743)

$ontext
Test JAMS behavior on a small QVI model.

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

set
    i        / 1*5 /
    isub1(i) / 1*2 /
    isub2(i) / 3*5 /
    p        / 1*3 /
;

alias(p,pp);

table Q1(p,pp)
     1    2    3
1    6   -2    5
2   -2    6   -7
3    5   -7   20;

table Q2(p,pp)
     1    2    3
1    6    1    0
2    1    7   -5
3    0   -5    7;

parameter Q(i,p,pp);
Q(isub1,p,pp) = Q1(p,pp);
Q(isub2,p,pp) = Q2(p,pp);

parameter b(i,p);
b(isub1,p) = 32 + isub1.val;
b(isub2,p) = 30 + (isub2.val+2)*2;

parameter xi1(p) / 1 2, 2 3, 3 4 /;
parameter xi2(p) / 1 6, 2 5, 3 4 /;

parameter xi(i,p);
xi(isub1,p) = xi1(p);
xi(isub2,p) = xi2(p);

positive variables y0(p), x0(p), y(i,p);
equations F0(p), F(i,p), gm, gp(i);

F0(p)..
    sum(i, xi(i,p) - y(i,p)) =N= 0;

F(i,p)..
    sum(pp, Q(i,p,pp)*y(i,pp)) - b(i,p) =N= 0;

gm..
    sum(p, y0(p)) - 1 =E= 0;

gp(i)..
    sum(p, x0(p)*(y(i,p) - xi(i,p))) =L= 0;

model m / F0, F, gm, gp /;

* Test QVI.
putclose info 'qvi F0 y0 x0 F y gm gp';
putclose opt
   'Dict     qviDict.txt' /
   'FileName qvi.gms' ;

m.optfile = 1;
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(y0.l('1')    - 0.167) > tol ] 'bad y0.l("1")', y0.l;
abort$[ abs(y0.l('2')    - 0.518) > tol ] 'bad y0.l("2")', y0.l;
abort$[ abs(y0.l('3')    - 0.315) > tol ] 'bad y0.l("3")', y0.l;
abort$[ abs(y.l('1','1') - 4.489) > tol ] 'bad y.l("1","1")', y.l;
abort$[ abs(y.l('1','2') - 3.954) > tol ] 'bad y.l("1","2")', y.l;
abort$[ abs(y.l('1','3') - 1.118) > tol ] 'bad y.l("1","3")', y.l;
abort$[ abs(y.l('2','1') - 4.603) > tol ] 'bad y.l("2","1")', y.l;
abort$[ abs(y.l('2','2') - 3.931) > tol ] 'bad y.l("2","2")', y.l;
abort$[ abs(y.l('2','3') - 1.095) > tol ] 'bad y.l("2","3")', y.l;
abort$[ abs(y.l('3','1') - 4.086) > tol ] 'bad y.l("3","1")', y.l;
abort$[ abs(y.l('3','2') - 4.452) > tol ] 'bad y.l("3","2")', y.l;
abort$[ abs(y.l('3','3') - 5.912) > tol ] 'bad y.l("3","3")', y.l;
abort$[ abs(y.l('4','1') - 4.303) > tol ] 'bad y.l("4","1")', y.l;
abort$[ abs(y.l('4','2') - 4.372) > tol ] 'bad y.l("4","2")', y.l;
abort$[ abs(y.l('4','3') - 5.929) > tol ] 'bad y.l("4","3")', y.l;
abort$[ abs(y.l('5','1') - 4.519) > tol ] 'bad y.l("5","1")', y.l;
abort$[ abs(y.l('5','2') - 4.292) > tol ] 'bad y.l("5","2")', y.l;
abort$[ abs(y.l('5','3') - 5.946) > tol ] 'bad y.l("5","3")', y.l;
abort$[ abs(gm.m) > tol ]                 'bad gm.m', gm.m;
abort$[ abs(gp.m('1')   + 50.338) > tol ] 'bad gp.m', gp.m;
abort$[ abs(gp.m('2')   + 52.659) > tol ] 'bad gp.m', gp.m;
abort$[ abs(gp.m('3')   + 66.216) > tol ] 'bad gp.m', gp.m;
abort$[ abs(gp.m('4')   + 70.906) > tol ] 'bad gp.m', gp.m;
abort$[ abs(gp.m('5')   + 75.597) > tol ] 'bad gp.m', gp.m;

$onecho > qvi_gms
***********************************************
* written by GAMS/JAMS at 06/21/17 13:28:31
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x2,x3,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21
          ,u19,u20,u21,u22,u23,u24;

Negative Variables  u20,u21,u22,u23,u24;

Positive Variables  x1,x2,x3,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19
          ,x20,x21;

Equations  e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19
          ,e20,e21,e22,e23,e24;


e1..  - x7 - x10 - x13 - x16 - x19 - u19 =N= -22;

e2..  - x8 - x11 - x14 - x17 - x20 - u19 =N= -21;

e3..  - x9 - x12 - x15 - x18 - x21 - u19 =N= -20;

e4..    6*x7 - 2*x8 + 5*x9 - (x1)*u20 =N= 33;

e5..  - 2*x7 + 6*x8 - 7*x9 - (x2)*u20 =N= 33;

e6..    5*x7 - 7*x8 + 20*x9 - (x3)*u20 =N= 33;

e7..    6*x10 - 2*x11 + 5*x12 - (x1)*u21 =N= 34;

e8..  - 2*x10 + 6*x11 - 7*x12 - (x2)*u21 =N= 34;

e9..    5*x10 - 7*x11 + 20*x12 - (x3)*u21 =N= 34;

e10..    6*x13 + x14 - (x1)*u22 =N= 40;

e11..    x13 + 7*x14 - 5*x15 - (x2)*u22 =N= 40;

e12..  - 5*x14 + 7*x15 - (x3)*u22 =N= 40;

e13..    6*x16 + x17 - (x1)*u23 =N= 42;

e14..    x16 + 7*x17 - 5*x18 - (x2)*u23 =N= 42;

e15..  - 5*x17 + 7*x18 - (x3)*u23 =N= 42;

e16..    6*x19 + x20 - (x1)*u24 =N= 44;

e17..    x19 + 7*x20 - 5*x21 - (x2)*u24 =N= 44;

e18..  - 5*x20 + 7*x21 - (x3)*u24 =N= 44;

e19..    x1 + x2 + x3 =E= 1;

e20.. x1*(-2 + x7) + x2*(-3 + x8) + x3*(-4 + x9) =L= 0;

e21.. x1*(-2 + x10) + x2*(-3 + x11) + x3*(-4 + x12) =L= 0;

e22.. x1*(-6 + x13) + x2*(-5 + x14) + x3*(-4 + x15) =L= 0;

e23.. x1*(-6 + x16) + x2*(-5 + x17) + x3*(-4 + x18) =L= 0;

e24.. x1*(-6 + x19) + x2*(-5 + x20) + x3*(-4 + x21) =L= 0;

Model m / e1.x1,e2.x2,e3.x3,e4.x7,e5.x8,e6.x9,e7.x10,e8.x11,e9.x12,e10.x13
         ,e11.x14,e12.x15,e13.x16,e14.x17,e15.x18,e16.x19,e17.x20,e18.x21
         ,e19.u19,e20.u20,e21.u21,e22.u22,e23.u23,e24.u24 /;

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

Solve m using MCP;
$offecho

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

$onecho > qvi_dict
* written by GAMS/JAMS at 06/21/17 13:29: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:qvi F0 y0 x0 F y gm gp


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

   Number of VI functions specified = 18
   * e1 is VI Func and perpendicular to x1
   * e2 is VI Func and perpendicular to x2
   * e3 is VI Func and perpendicular to x3
   * e4 is VI Func and perpendicular to x7
   * e5 is VI Func and perpendicular to x8
   * e6 is VI Func and perpendicular to x9
   * e7 is VI Func and perpendicular to x10
   * e8 is VI Func and perpendicular to x11
   * e9 is VI Func and perpendicular to x12
   * e10 is VI Func and perpendicular to x13
   * e11 is VI Func and perpendicular to x14
   * e12 is VI Func and perpendicular to x15
   * e13 is VI Func and perpendicular to x16
   * e14 is VI Func and perpendicular to x17
   * e15 is VI Func and perpendicular to x18
   * e16 is VI Func and perpendicular to x19
   * e17 is VI Func and perpendicular to x20
   * e18 is VI Func and perpendicular to x21


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

                  e1  F0(1)
                  e2  F0(2)
                  e3  F0(3)
                  e4  F(1,1)
                  e5  F(1,2)
                  e6  F(1,3)
                  e7  F(2,1)
                  e8  F(2,2)
                  e9  F(2,3)
                 e10  F(3,1)
                 e11  F(3,2)
                 e12  F(3,3)
                 e13  F(4,1)
                 e14  F(4,2)
                 e15  F(4,3)
                 e16  F(5,1)
                 e17  F(5,2)
                 e18  F(5,3)
                 e19  gm
                 e20  gp(1)
                 e21  gp(2)
                 e22  gp(3)
                 e23  gp(4)
                 e24  gp(5)


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

                  x1  y0(1)
                  x2  y0(2)
                  x3  y0(3)
                  x1  x0(1)
                  x2  x0(2)
                  x3  x0(3)
                  x7  y(1,1)
                  x8  y(1,2)
                  x9  y(1,3)
                 x10  y(2,1)
                 x11  y(2,2)
                 x12  y(2,3)
                 x13  y(3,1)
                 x14  y(3,2)
                 x15  y(3,3)
                 x16  y(4,1)
                 x17  y(4,2)
                 x18  y(4,3)
                 x19  y(5,1)
                 x20  y(5,2)
                 x21  y(5,3)
                 u19  {new}
                 u20  {new}
                 u21  {new}
                 u22  {new}
                 u23  {new}
                 u24  {new}
$offecho

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