examin05.gms : EXAMINER test suite - test merit function value in m.RObj

Description

For an NLP, we can define a merit function based on the level and
marginal values - this merit function is small iff the levels and
marginals are close to a solution.  Examiner returns the value of such
a merit function in the m.RObj model attribute.  This model
tests that functionality.

Contributor: Steve Dirkse, Jul 2020

  one point is selected to examine:
  this uniquely defines an input point for the merit function


Small Model of Type : GAMS


Category : GAMS Test library


Main file : examin05.gms

$title EXAMINER test suite - test merit function value in m.RObj (EXAMIN05,SEQ=825)

$onText
For an NLP, we can define a merit function based on the level and
marginal values - this merit function is small iff the levels and
marginals are close to a solution.  Examiner returns the value of such
a merit function in the m.RObj model attribute.  This model
tests that functionality.

Contributor: Steve Dirkse, Jul 2020
$offText

$onEcho > examiner.o98
* one point is selected to examine:
* this uniquely defines an input point for the merit function
examineInitPoint yes
$offEcho

$onEcho > examiner.o99
* multiple point are selected to examine, but only one is returned:
* this uniquely defines an input point for the merit function
examineGamsPoint yes
examineInitPoint yes
returnInitPoint yes
$offEcho

$if not set TESTTOL $set TESTTOL 1e-6
scalar tol / %TESTTOL% / ;

variables x, y, z;
equations f, g;
f.. 4*sqr(x-1) + x + sqr(y-1) =E= z;
g.. 3*x + 2*y =G= 14;

model m / f, g /;
option nlp = examiner;
m.optfile = 98;

solve m using nlp min z;
abort$(m.modelstat <> %modelStat.noSolutionReturned%) 'wrong modelstat for EXAMINER', m.modelstat;
abort$(m.solvestat <> %solveStat.normalCompletion%)   'wrong solvestat for EXAMINER', m.solvestat;
* we get merit function (i.e. robj) of 14
abort$(abs(m.robj - 14) > tol) 'bad merit function: case 1', m.robj;

x.L = 2;
y.L = 4;
z.L = 15;
solve m using nlp min z;
abort$(m.modelstat <> %modelStat.noSolutionReturned%) 'wrong modelstat for EXAMINER', m.modelstat;
abort$(m.solvestat <> %solveStat.normalCompletion%)   'wrong solvestat for EXAMINER', m.solvestat;
* we get merit function (i.e. robj) of 1
abort$(abs(m.robj - 1) > tol) 'bad merit function: case 2', m.robj;

m.optfile = 99;
g.m = 3;
solve m using nlp min z;
abort$(m.modelstat <> %modelStat.feasibleSolution%)   'wrong modelstat for EXAMINER', m.modelstat;
abort$(m.solvestat <> %solveStat.terminatedBySolver%) 'wrong solvestat for EXAMINER', m.solvestat;
* we get merit function (i.e. robj) of 9
abort$(abs(m.robj - 9) > tol) 'bad merit function: case 3', m.robj;

f.m = -1;
solve m using nlp min z;
abort$(m.modelstat <> %modelStat.locallyOptimal%)   'wrong modelstat for EXAMINER', m.modelstat;
abort$(m.solvestat <> %solveStat.normalCompletion%) 'wrong solvestat for EXAMINER', m.solvestat;
* finally we get merit function (i.e. robj) of 0
abort$(abs(m.robj - 0) > tol) 'bad merit function: case 4', m.robj;