cns07.gms : CNS model with globally unique solution

Description

The following model has a globally unique solution even though it
is nonlinear and simultaneous.
Not all solvers will recognize that the solution is globally unique
(hardly any will).

The Jacobian of the model

exp(x1)   +1
 -1     exp(x2)

has the determinant exp(x1)*exp(x2)+1 and is therefore always strictly
positive (bounded away from zero) and if a solution exist it is
therefore unique.


Small Model of Type : CNS


Category : GAMS Test library


Main file : cns07.gms

$title CNS model with globally unique solution (cns07,SEQ=97)

$onText
  The following model has a globally unique solution even though it
  is nonlinear and simultaneous.
  Not all solvers will recognize that the solution is globally unique
  (hardly any will).

  The Jacobian of the model

  exp(x1)   +1
   -1     exp(x2)

  has the determinant exp(x1)*exp(x2)+1 and is therefore always strictly
  positive (bounded away from zero) and if a solution exist it is
  therefore unique.
$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% /;
scalars rhs1, rhs2;
rhs1 = exp(-1) +    (-1);
rhs2 =   -(-1) + exp(-1);

variable x1, x2;
equation e1, e2;


e1 .. exp(x1) +     x2  =e= rhs1;
e2 ..    -x1  + exp(x2) =e= rhs2;

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