emp28.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 : emp28.gms

$TITLE 'Test JAMS/EMP on QVI model' (EMP28,SEQ=742)

$ontext
Test JAMS behavior on a small QVI model.

Contributors: Youngdae Kim & Steve Dirkse, Feb 2018
$offtext

$if not set TESTTOL $set TESTTOL 1e-6
scalars tol / %TESTTOL% /;
file opt  / 'jams.opt' /;
file info / '%emp.info%' /;

set i / 1*2 /;
alias(i,j);

table A(i,j)
      1       2
1     2     [8/3]
2   [5/4]     2   ;

parameters
  b(i) / 1 [100/3],  2 22.5 /
  Cy(i,j) / 1.1 1,  2.2 1 /
  Cx(i,j) / 1.2 1,  2.1 1 /
  rhs(i) / 1 15, 2 20 / ;

variables y(j), x(j);
equations F(i), g(i);

F(i)..
    sum(j, A(i,j)*y(j)) - b(i) =N= 0;

g(i)..
    sum(j, Cy(i,j)*y(j)) + sum(j, Cx(i,j)*x(j)) - rhs(i) =L= 0;

model m / F, g /;

* Test QVI.
putclose info 'qvi F y x g';
putclose opt
   'Dict     qviDict.txt' /
   'FileName qvi.gms' ;

y.lo(j) = 0;
y.up(j) = 11;
x.lo(j) = 0;
x.up(j) = 11;

m.optfile = 1;
solve m using emp;
abort$[m.solvestat <> %solvestat.NormalCompletion%]
     'wrong m.solvestat', m.solvestat;
abort$[m.modelstat <> %modelstat.Optimal%]
     'wrong m.modelstat', m.modelstat;
abort$[ abs(y.l('1')-    10) > tol ]     'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-     5) > tol ]     'bad y.l("2")', y.l;
abort$[ abs(x.l('1')-    10) > tol ]     'bad x.l("1")', x.l;
abort$[ abs(x.l('2')-     5) > tol ]     'bad x.l("2")', x.l;
abort$[ smax{i, abs(g.m(i)-  0)} > tol ] 'bad g.m("i")', g.m;

y.l(j) = 0;
x.l(j) = 0;
g.m(i) = 0;

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

Variables  x1,x2,u3,u4;

Negative Variables  u3,u4;

Positive Variables  x1,x2;

Equations  e1,e2,e3,e4;


e1..    2*x1 + 2.66666666666667*x2 - u3 =N= 33.3333333333333;

e2..    1.25*x1 + 2*x2 - u4 =N= 22.5;

e3..    x1 + x2 =L= 15;

e4..    x2 + x1 =L= 20;

* set non-default bounds
x1.up = 11;
x2.up = 11;

Model m / e1.x1,e2.x2,e3.u3,e4.u4 /;

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 11:08:51

********************************************************************************
 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 F y x g


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

   Number of VI functions specified = 2
   * e1 is VI Func and perpendicular to x1
   * e2 is VI Func and perpendicular to x2


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

                  e1  F(1)
                  e2  F(2)
                  e3  g(1)
                  e4  g(2)


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

                  x1  y(1)
                  x2  y(2)
                  x1  x(1)
                  x2  x(2)
                  u3  {new}
                  u4  {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';

* Change the bounds to larger than the ones of the parameter variable.
* In this case, we should adjust those bounds to be consistent with
* the ones of the parameter variable, i.e., take the intersection.
y.lo(j) = -10;
y.up(j) = 20;

putclose opt
   'Dict     qviBndDict.txt' /
   'FileName qviBnd.gms' ;

m.optfile = 1;
solve m using emp;
abort$[m.solvestat <> %solvestat.NormalCompletion%]
     'wrong m.solvestat', m.solvestat;
abort$[m.modelstat <> %modelstat.Optimal%]
     'wrong m.modelstat', m.modelstat;
abort$[ abs(y.l('1')-    10) > tol ]     'bad y.l("1")', y.l;
abort$[ abs(y.l('2')-     5) > tol ]     'bad y.l("2")', y.l;
abort$[ abs(x.l('1')-    10) > tol ]     'bad x.l("1")', x.l;
abort$[ abs(x.l('2')-     5) > tol ]     'bad x.l("2")', x.l;
abort$[ smax{i, abs(g.m(i)-  0)} > tol ] 'bad g.m("i")', g.m;

$onecho > qviBnd_gms
***********************************************
* written by GAMS/JAMS at 06/21/17 12:13:40
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x2,u3,u4;

Negative Variables  u3,u4;

Equations  e1,e2,e3,e4;


e1..    2*x1 + 2.66666666666667*x2 - u3 =N= 33.3333333333333;

e2..    1.25*x1 + 2*x2 - u4 =N= 22.5;

e3..    x1 + x2 =L= 15;

e4..    x2 + x1 =L= 20;

* set non-default bounds
x1.lo = 0; x1.up = 11;
x2.lo = 0; x2.up = 11;

Model m / e1.x1,e2.x2,e3.u3,e4.u4 /;

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

option bratio = 0;
Solve m using MCP;
$offecho

execute 'grep -v " written by GAMS" qviBnd_gms > qvi.gms.want'
execute 'grep -v " written by GAMS" qviBnd.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 > qviBnd_dict
* written by GAMS/JAMS at 06/21/17 11:08:51

********************************************************************************
 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 F y x g


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

   Number of VI functions specified = 2
   * e1 is VI Func and perpendicular to x1
   * e2 is VI Func and perpendicular to x2


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

                  e1  F(1)
                  e2  F(2)
                  e3  g(1)
                  e4  g(2)


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

                  x1  y(1)
                  x2  y(2)
                  x1  x(1)
                  x2  x(2)
                  u3  {new}
                  u4  {new}
$offecho

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