Description
LSE max LSEMax is defined as: f := log(exp(x1)+exp(x2)+...) Not every GAMS solver can handle this. For those, who cannot deal with this function, we expect a capability error. For others we check the evaluation of random input points. Contributor: Lutz Westermann, September 2022
Small Model of Type : NLP
Category : GAMS Test library
Main file : fnlseslv.gms
$title 'Rough solver correctness test for LSEMax intrinsics' (FNLSESLV,SEQ=917)
$onText
LSE max LSEMax is defined as: f := log(exp(x1)+exp(x2)+...)
Not every GAMS solver can handle this. For those, who cannot deal
with this function, we expect a capability error. For others we
check the evaluation of random input points.
Contributor: Lutz Westermann, September 2022
$offText
Sets
* Allow to fit into global demo limit
arg / n00*n07 /
P / p1*p100 /;
Scalars
aTol0 / 3e-14 /;
Parameters
data(arg)
wantZ;
Variable z, Vdata(arg);
Equation e, fx(arg);
e.. z =e= LSEMax(Vdata('n00'),Vdata('n01'),Vdata('n02'),Vdata('n03'),
Vdata('n04'),Vdata('n05'),Vdata('n06'),Vdata('n07') );
fx(arg).. Vdata(arg) =e= data(arg);
model m /all/;
loop {P,
data(arg) = uniform(-10,10);
solve m min z use nlp;
if {(m.solvestat = %solveStat.capabilityProblems%),
abort$(m.modelstat <> %modelStat.noSolutionReturned%) 'wrong modelstat for capability error';
abort.noError 'Solver capability error: further tests suppressed';
else
abort$(m.solvestat <> %solveStat.normalCompletion% or m.modelstat > %modelStat.locallyOptimal%) 'wrong status codes';
wantZ = log(sum(arg, exp(data(arg))));
abort$[abs(z.l-wantZ)>aTol0] 'bad z.l', z.l, wantZ;
};
};