cns06.gms : CNS model with globally unique solution

Description

The following model has a globally unique solution even though it
is nonlinear.
Not all solvers will recognize that the solution is globally unique.
Equation e1 can be solved uniquely w.r.t. x1 because the function
exp is monotone.
Equation e2 can then be solved uniquely w.r.t. x2 even though it
  is nonlinear in x1 since x1 has a unique nonzero value.


Small Model of Type : CNS


Category : GAMS Test library


Main file : cns06.gms

$title CNS model with globally unique solution (cns06,SEQ=96)

$onText
  The following model has a globally unique solution even though it
  is nonlinear.
  Not all solvers will recognize that the solution is globally unique.
  Equation e1 can be solved uniquely w.r.t. x1 because the function
  exp is monotone.
  Equation e2 can then be solved uniquely w.r.t. x2 even though it
    is nonlinear in x1 since x1 has a unique nonzero value.
$offText

$if not set TESTTOL $set TESTTOL 1e-6
scalar tol / %TESTTOL% /;
$if not set SLOWOK $set SLOWOK 0
scalar slowOK 'slow solves are OK: just abort.noerror in this case' / %SLOWOK% /;

variable x1, x2;
equation e1, e2;

e1 .. exp(x1) =e= exp(1);
e2 .. x1 * x2 =e= 9;

model cns06 / all /;
option limrow = 0, limcol = 0;
solve cns06 using cns;
abort.noError$[slowOK and %solveStat.resourceInterrupt% = cns06.solvestat] 'Solve too slow';
abort$(cns06.solvestat <> %solveStat.normalCompletion%
    or (cns06.modelstat <> %modelStat.solvedUnique%) and (cns06.modelstat <> %modelStat.solved%))
   'bad return codes', cns06.solvestat, cns06.modelstat;
abort$(abs(x1.l-1) > tol)       'bad x1.l';
abort$(abs(x2.l-9) > tol)       'bad x2.l';
abort$(abs(e1.l-exp(1)) > tol)  'bad e1.l';
abort$(abs(e2.l-9) > tol)       'bad e2.l';