emp32.gms : Test JAMS/EMP on QVI model with zero function

Description

Test behavior on a QVI model having a zero function.
 - Zero function needs to be explicitly specified using 0.

Contributor: Youngdae Kim, February 2018


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emp32.gms

$TITLE 'Test JAMS/EMP on QVI model with zero function' (EMP32,SEQ=749)

$ontext
Test behavior on a QVI model having a zero function.
 - Zero function needs to be explicitly specified using 0.

Contributor: Youngdae Kim, February 2018

$offtext

file opt  / 'jams.opt' /;
file info / '%emp.info%' /;

positive variables y,x,w,v;
equations Fy, gw, gy;

Fy..
    y - w - 1 =N= 0;

gw..
    w + v =G= 2;

gy..
    y + x =G= 4;

model m / Fy, gw, gy /;

* case 1)
putclose info 'qvi  0 w v  Fy y x  gw  gy';
putclose opt
   'Dict     qvi1Dict.txt' /
   'FileName qvi1.gms';

m.optfile = 1;
solve m using emp;

abort$[m.modelstat <> %MODELSTAT.OPTIMAL%] 'QVI should solve OK';
abort$[m.solvestat <> %SOLVESTAT.NORMAL COMPLETION%] 'QVI should solve OK';
abort$[abs(y.l - 2)] 'bad y.l', y.l;
abort$[abs(x.l - 2)] 'bad x.l', x.l;
abort$[abs(w.l - 1)] 'bad w.l', w.l;
abort$[abs(v.l - 1)] 'bad v.l', v.l;

$onecho > qvi1_gms
***********************************************
* written by GAMS/JAMS at 02/12/18 14:29:16
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x3,u2,u3;

Positive Variables  x1,x3;

Positive Variables  u2,u3;

Equations  e1,e2,e3,zero_x3;


e1..    x1 - x3 - u3 =N= 1;

e2..    x3 + x3 =G= 2;

e3..    x1 + x1 =G= 4;

zero_x3..  - u2 =G= 0;

Model m / e1.x1,e2.u2,e3.u3,zero_x3.x3 /;

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

Solve m using MCP;
$offecho

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

$onecho > qvi1_dict
* written by GAMS/JAMS at 02/12/18 14:49:16

********************************************************************************
 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  0 w v  Fy y x  gw  gy


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

   Number of VI functions specified = 1
   * e1 is VI Func and perpendicular to x1


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

                  e1  Fy
                  e2  gw
                  e3  gy
             zero_x3  {new}


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

                  x1  y
                  x1  x
                  x3  w
                  x3  v
                  u2  {new}
                  u3  {new}
$offecho

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

y.l = 0;
y.m = 0;
x.l = 0;
x.m = 0;
w.l = 0;
w.m = 0;
v.l = 0;
v.m = 0;

Fy.m = 0;
gw.m = 0;
gy.m = 0;

* case 2)
putclose info 'qvi  Fy y x  0 w v  gw  gy';
putclose opt
   'Dict     qvi2Dict.txt' /
   'FileName qvi2.gms';

m.optfile = 1;
solve m using emp;
abort$[m.modelstat <> %MODELSTAT.OPTIMAL%] 'QVI should solve OK';
abort$[m.solvestat <> %SOLVESTAT.NORMAL COMPLETION%] 'QVI should solve OK';
abort$[abs(y.l - 2)] 'bad y.l', y.l;
abort$[abs(x.l - 2)] 'bad x.l', x.l;
abort$[abs(w.l - 1)] 'bad w.l', w.l;
abort$[abs(v.l - 1)] 'bad v.l', v.l;

$onecho > qvi2_gms
***********************************************
* written by GAMS/JAMS at 02/12/18 14:29:16
* for more information use JAMS option "Dict"
***********************************************

Variables  x1,x3,u2,u3;

Positive Variables  x1,x3;

Positive Variables  u2,u3;

Equations  e1,e2,e3,zero_x3;


e1..    x1 - x3 - u3 =N= 1;

e2..    x3 + x3 =G= 2;

e3..    x1 + x1 =G= 4;

zero_x3..  - u2 =G= 0;

Model m / e1.x1,e2.u2,e3.u3,zero_x3.x3 /;

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

Solve m using MCP;
$offecho

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

$onecho > qvi2_dict
* written by GAMS/JAMS at 02/12/18 14:51:27

********************************************************************************
 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  Fy y x  0 w v  gw  gy


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

   Number of VI functions specified = 1
   * e1 is VI Func and perpendicular to x1


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

                  e1  Fy
                  e2  gw
                  e3  gy
             zero_x3  {new}


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

                  x1  y
                  x1  x
                  x3  w
                  x3  v
                  u2  {new}
                  u3  {new}
$offecho

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