\$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 'EMPInfoFile empinfo1.txt' / 'fileName vi1Scalar.gms' / 'dict dict1.txt' /; file empinfo / 'empinfo1.txt' /; 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 'EMPInfoFile empinfo2.txt' / 'fileName vi2Scalar.gms' / 'dict dict2.txt' /; file empinfo2 / 'empinfo2.txt' /; putclose empinfo2 '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; * AIX and Solaris have a deficient diff: just skip diffing there \$ifthen.aixskip not %system.buildcode% == AIX \$ifthen.solskip not %system.buildcode% == SOL \$ifthen.soxskip not %system.buildcode% == SOX execute '=diff -I ^\* vi1Scalar.gms vi2Scalar.gms'; abort\$errorlevel 'vi1Scalar.gms and vi2Scalar.gms differ'; \$endif.soxskip \$endif.solskip \$endif.aixskip execute 'rm -f vi1Scalar.??? vi2Scalar.??? dict1.txt dict2.txt empinfo1.txt empinfo2.txt' execute 'rm -f vi?Scalarpf.pf jams.opt jams.op2'