$title simple MPEC unique solution lower bounded matches (MPEC05,SEQ=616) $onText extremely simple MPEC model with some useful features: a) it has a unique solution b) all matched vars are lower-bounded Contributor: Steve Dirkse, Sep 2013 $offText $if not set TESTTOL $set TESTTOL 1e-4 scalars tol / %TESTTOL% / c1 / -1 / c2 / -2 / ; positive variables x1, x2, y; free variable z; equation f1, f2, o; f1 .. 2*x1 + x2 + y + c1 =N= 0; f2 .. x1 + 2*x2 + y + c2 =G= 0; o .. sqr(x1-2) + sqr(x2-2) + sqr(y-1) =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-0 ) > tol) 'var x1.l should be 0' , x1.l; abort$(abs(x2.l-0.8) > tol) 'var x2.l should be 0.8', x2.l; abort$(abs( y.l-0.4) > tol) 'var y.l should be 0.4', y.l; abort$(abs( z.l-5.8) > tol) 'var z.l should be 5.8', z.l; abort$(abs(f1.l-0.2) > tol) 'equ f1.l should be 0.2', f1.l; abort$(abs(f2.l-2.0) > tol) 'equ f2.l should be 2.0', f2.l; abort$(abs( o.l-0 ) > tol) 'equ o.l should be 0' , o.l;