emp35.gms : JAMS: test of flipping constraints with VI

Description

With the EMP keyword VI it is possible to specify a constraint set for
the VI.  In such a case, we can flip an equation specifying the
constraint set.  This should flip 3 things in the generated MCP:
  1. The constraint itself (e.g. Ax >= b  becomes b <= Ax)
  2. the multiplier perp to the flipped constraint (e.g. positive var to negative var)
  3. The skew-symmetric reflection of the constraint in the NE corner of the MCP.

The reported values for the equation are unchanged by the flip:
we test for this below.

Contributor: Steve Dirkse, Dec 2023


Small Model of Type : GAMS


Category : GAMS Test library


Main file : emp35.gms

$title 'JAMS: test of flipping constraints with VI' (EMP35, SEQ=948)

$onText
With the EMP keyword VI it is possible to specify a constraint set for
the VI.  In such a case, we can flip an equation specifying the
constraint set.  This should flip 3 things in the generated MCP:
  1. The constraint itself (e.g. Ax >= b  becomes b <= Ax)
  2. the multiplier perp to the flipped constraint (e.g. positive var to negative var)
  3. The skew-symmetric reflection of the constraint in the NE corner of the MCP.

The reported values for the equation are unchanged by the flip:
we test for this below.

Contributor: Steve Dirkse, Dec 2023
$offText

sets
  j  / j1 * j3 /
  i  / i1 * i2 /
  ;
parameters
  d(j) /
    j1   1
    j2   1
    j3   1
  /
  b(i) /
    i1   6
    i2   6
  /
  ;
table A(i,j)
    j1  j2  j3
i1   2  1
i2      1   2  ;

variables
  z
  x(j)
  ;
equations
  f
  df(j)
  g(i)
  ;
f..     sum{j, sqr(x(j)-d(j))} =E= z;
df(j).. 2 * (x(j)-d(j)) =N= 0;
g(i)..  sum{j, A(i,j)*x(j)} =G= b(i);

model mnlp / f, g /;
model mvi  / df, g /;

solve mnlp using nlp min z;

file myinfo / '%emp.info%' /;

putclose myinfo 'vi df x   g';
mvi.iterlim = 0;
solve mvi using emp;
abort$[mvi.solvestat <> %solveStat.normalCompletion%] 'Expected mvi to solve nicely';
abort$[smax{i, abs(g.lo(i) - 6)} > 0]   'bad g.lo, expected 6', g.lo;
abort$[smax{i, abs(g.L(i) - 6)} > 1e-5] 'bad g.L, expected 6', g.L;
abort$[smax{i, abs(g.m(i) - 1)} > 1e-5] 'bad g.m, expected 1', g.m;

putclose myinfo 'vi df x   -g';
solve mvi using emp;
abort$[mvi.solvestat <> %solveStat.normalCompletion%] 'Expected mvi with flip to solve nicely';
* we expect the same g-values in the reported solution as with the unflipped constraint g
abort$[smax{i, abs(g.lo(i) - 6)} > 0]   'bad g.lo, expected 6', g.lo;
abort$[smax{i, abs(g.L(i) - 6)} > 1e-5] 'bad g.L, expected 6', g.L;
abort$[smax{i, abs(g.m(i) - 1)} > 1e-5] 'bad g.m, expected 1', g.m;