lsalib01.gms : Test extrinsic functions in lsadclib

Description

In this test we use the extrinsic Lindo Sampling library. We check both the
basically functionality and the licensing of this library.

Contributor: L. Westermann


Small Model of Type : GAMS


Category : GAMS Test library


Main file : lsalib01.gms

$Title Test extrinsic functions in lsadclib (LSALIB01,SEQ=609)

$ontext
In this test we use the extrinsic Lindo Sampling library. We check both the
basically functionality and the licensing of this library.

Contributor: L. Westermann
$offtext

$if %system.buildcode% == AIX $abort.noerror 'No Lindo on AIX';
$if %system.buildcode% == SOX $abort.noerror 'No Lindo on SOX';

$funclibin lsalib lsadclib

function normalSample   / lsalib.SampleLSnormal     /
         binomiSample   / lsalib.sampleLSBinomial   /
         triangSample   / lsalib.sampleLSTriangular /
         getSampleVal   / lsalib.getSampleValues    /;

scalar hNormal Handle for normal sampling
       hBinomi Handle for binomial sampling
       hTriang Handle for triangular sampling;

hNormal = normalSample(5, 2,    10);
hBinomi = binomiSample(50,0.5,  10);

$ifthen not %DEMOSIZE% == 1
hNormal = normalSample(5, 2,    11);
hTriang = triangSample(2, 5,  8,10);
$endif

set i /i01*i10/;

parameter sv(i) Sampled values;
loop(i, sv(i) = getSampleVal(hNormal) );
display 'Sample of normal distribution:', sv;

loop(i, sv(i) = getSampleVal(hBinomi) );
display 'Sample of binomial distribution:', sv;

$ifthen not %DEMOSIZE% == 1
loop(i, sv(i) = getSampleVal(hTriang) );
display 'Sample of triangular distribution:', sv;
$endif

* Now check that certain things do not work w/o a full Lindo license
$onEcho > needLicense1.gms
$funclibin lsalib lsadclib
function normalSample   / lsalib.SampleLSnormal     /;
scalar hNormal Handle for normal sampling;
hNormal = normalSample(5, 2,    11);
$offEcho

$call gams needLicense1.gms license=demo lo=%GAMS.lo%
$if not errorLevel 1 $abort Only samples with a size up to 10 should work w/o license

$onEcho > needLicense2.gms
$funclibin lsalib lsadclib
function triangSample   / lsalib.sampleLSTriangular /;
scalar hTriang Handle for triangular sampling;
hTriang = triangSample(2, 5,  8,10);
$offEcho

$call gams needLicense2.gms license=demo lo=%GAMS.lo%
$if not errorLevel 1 $abort Only normal and binomial distribution should work w/o license