mpec06.gms : simple MPEC unique solution upper bounded matches

Description

extremely simple MPEC model with some useful features:
 a) it has a unique solution
 b) all matched vars are upper-bounded

Contributor: Steve Dirkse, Sep 2013


Small Model of Type : MPEC


Category : GAMS Test library


Main file : mpec06.gms

$title simple MPEC unique solution upper bounded matches (MPEC06,SEQ=617)

$onText
  extremely simple MPEC model with some useful features:
   a) it has a unique solution
   b) all matched vars are upper-bounded

Contributor: Steve Dirkse, Sep 2013
$offText

$if not set TESTTOL $set TESTTOL 1e-4

scalars
  tol / %TESTTOL% /
  c1  / 5 /
  c2  / 8 /
  ;
free variables x1, x2, y;
x1.up = -1;
x2.up = -2;
y.up = 0;
free variable z;
equation f1, f2, o;

f1 .. 2*x1 +   x2 + y + c1 =L= 0;
f2 ..   x1 + 2*x2 + y + c2 =N= 0;
o  .. sqr(x1+5) + sqr(x2-2) + sqr(y) =E= z;

model m / f1.x1, f2.x2, o /;

solve m using mpec min z;
if {(m.solvestat = %solveStat.capabilityProblems%),
  abort$[m.modelstat <> %modelStat.noSolutionReturned%] 'Wrong status codes',
    m.solvestat, m.modelstat;
  abort.noerror 'no solution, no point in checking further';
else
  abort$[not((m.solvestat = %solveStat.normalCompletion%) and (m.modelstat = %modelStat.optimal% or
              m.modelstat = %modelStat.locallyOptimal% or m.modelstat = %modelStat.feasibleSolution%))] 'Wrong status codes',
    m.solvestat, m.modelstat;
};

scalars r1, r2;
r1 = 2*x1.l +   x2.l + y.l + c1;
r2 =   x1.l + 2*x2.l + y.l + c2;

file log / '' /;
putclose log
 ' ' /
 'F1 := ', r1:6:2, '  perp x1 ', x1.lo:8:2, ' <= ', x1.L:6:2 ' <= ', x1.up:6:2 /
 'F2 := ', r2:6:2, '  perp x2 ', x2.lo:8:2, ' <= ', x2.L:6:2 ' <= ', x2.up:6:2 /
 '  y = ', y.L:6:2 /
 ' ' / ;

abort$(abs(x1.l+1.0) > tol) 'var x1.l should be -1.0', x1.l;
abort$(abs(x2.l+2.4) > tol) 'var x2.l should be -2.4', x2.l;
abort$(abs( y.l+2.2) > tol) 'var  y.l should be -2.2',  y.l;
abort$(abs( z.l-40.2)> tol) 'var  z.l should be 40.2',  z.l;

abort$(abs(f1.l+6.6) > tol) 'equ f1.l should be -6.6', f1.l;
abort$(abs(f2.l+0.0) > tol) 'equ f2.l should be  0.0', f2.l;
abort$(abs( o.l-0.0) > tol) 'equ  o.l should be  0.0',  o.l;