vi_equil.gms : Identical VI models with and without containing equilibrium

Description

Demonstrate that a VI can be expressed in two equivalent ways:
  1) using the VI keyword in an EMP info file
  2) as in 1), but inside a containing equilibrium block

Note that the identical VI is produced in the two cases above

Contributor: Steven Dirkse, August 2013


Small Model of Type : VI


Category : GAMS EMP library


Main file : vi_equil.gms   includes :  qpdata.inc [html]

$title Identical VI models with and without containing equilibrium (VI_EQUIL,SEQ=97)

$onText

Demonstrate that a VI can be expressed in two equivalent ways:
  1) using the VI keyword in an EMP info file
  2) as in 1), but inside a containing equilibrium block

Note that the identical VI is produced in the two cases above

Contributor: Steven Dirkse, August 2013

$offText

$include qpdata.inc

* ----------- STEP 0: solve QP as a QP
* solve
*   min   1/2 xQx + cx
*   s.t.  Ax >= b
*           x >=0

option nlp = conopt;
solve mqp using nlp min z;
abort$[mqp.solvestat <> %solveStat.normalCompletion%] 'mqp not solved', mqp.solvestat;
abort$[mqp.modelstat  > %modelStat.locallyOptimal%] 'mqp not solved', mqp.modelstat;


* ----------- STEP 1: formulate QP as a VI using JAMS & EMP -----------
* The QP can be reformulated as the VI(F,C) where
*  F(x) := Qx + c, C := {x : x >=0, Ax >= b}

equation F(j) 'the F in VI(F,C)';
F(j) .. sum{jj, Q(j,jj)*x(jj)} + c(j) =N= 0;

model vi / F, g /;

file opt1 / 'jams.opt' /;
putclose opt1 'fileName vi1Scalar.gms'
            / 'dict dict1.txt'
           /;

file empinfo / '%emp.info%' /;
putclose empinfo 'vi F x g';

vi.optfile = 1;
F.m(j) = eps;
solve vi using emp;
abort$[vi.solvestat <> %solveStat.normalCompletion%] 'VI not solved', vi.solvestat;
abort$[vi.iterusd <> 0]  'expected to start at a solution', vi.iterusd;


* ----------- STEP 2: formulate QP as a VI-inside-equilibrium using JAMS & EMP -----------
* The VI is unchanged from step 1: it is specified in the same way,
* and the same model results

file opt2 / 'jams.op2' /;
putclose opt2 'fileName vi2Scalar.gms'
            / 'dict dict2.txt'
           /;
putclose empinfo 'equilibrium'
               / 'vi F x g';

vi.optfile = 2;
solve vi using emp;
abort$[vi.solvestat <> %solveStat.normalCompletion%] 'VI not solved', vi.solvestat;
abort$[vi.iterusd <> 0]  'expected to start at a solution', vi.iterusd;

* Only JAMS exports scalar models
$ifThenI %gams.emp%==jams
execute 'diff -I ^[*] -I reslim vi1Scalar.gms vi2Scalar.gms';
abort$errorlevel 'vi1Scalar.gms and vi2Scalar.gms differ';
$endIf

execute 'rm -f vi1Scalar.??? vi2Scalar.??? dict1.txt dict2.txt empinfo1.txt empinfo2.txt'
execute 'rm -f vi?Scalarpf.pf jams.opt jams.op2'