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;

execute '=diff -I ^\* -I reslim vi1Scalar.gms vi2Scalar.gms';
abort$errorlevel 'vi1Scalar.gms and vi2Scalar.gms differ';

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