Description
Check if maximum... - identifier length - explanatory text length - number of indices - input line length - loop depths - nested include file depths is as expected. Contributor: M. Bussieck
Small Model of Type : GAMS
Category : GAMS Test library
Main file : maxima.gms
$title Test several maxima of Cmex (MAXIMA,SEQ=509)
$onText
Check if maximum...
- identifier length
- explanatory text length
- number of indices
- input line length
- loop depths
- nested include file depths
is as expected.
Contributor: M. Bussieck
$offText
$maxGoTo 1000
$set id x
$set cnt 1
$label startid
$eval cnt %cnt%+1
$eval cntmod mod(%cnt%,10)
$set id %id%%cntmod%
scalar %id%;
$if errorfree $goTo startid
$clearError
$eval maxidlength %cnt%-1
$set id
$set cnt 0
$label startet
$eval cnt %cnt%+1
$eval cntmod mod(%cnt%,10)
$set id %id%%cntmod%
$if defined y $kill y
scalar y %id% /1/;
$if errorfree $goTo startet
$clearError
$eval maxetlength %cnt%-1
set i /1/;
$set id x
$set idx i
$set cnt 1
$label startidx
$eval cnt %cnt%+1
$set idx %idx%,i
$set id %id%x
parameter %id%(%idx%);
$if errorfree $goTo startidx
$clearError
$eval maxidxlength %cnt%-1
* Need awk since put only writes to 32768 chars per line
$echo '{printf("*"); for(i=1;i<maxd;i++) printf("x");}' > il.awk
$set cnt 0
$set add 1000
$label startil
$eval cnt %cnt%+%add%
$call echo x | awk -v maxd=%cnt% -f il.awk > ilx.gms && gams ilx.gms lo=0
$if errorlevel 1 $goTo stopil
$goTo startil
$label stopil
$clearError
$ifE %add%=1 $goTo doneil
$eval cnt %cnt%-%add%
$eval add round(%add%/10)
$goTo startil
$label doneil
$eval maxillength %cnt%-2
$onEchoV > if.gms
set d /1*%maxd%/
file fx /ifx.gms/; put fx 'scalar i /1/';
loop(d, put 'if(i,' /);
put 'display i;' /;
loop(d, put ')' /);
$offEcho
$set cnt 0
$set add 10
$label startloop
$eval cnt %cnt%+%add%
$call gams if.gms --maxd=%cnt% lo=0 && gams ifx.gms lo=0
$if errorlevel 1 $goTo stoploop
$goTo startloop
$label stoploop
$clearError
$ifE %add%=1 $goTo doneloop
$eval cnt %cnt%-%add%
$eval add round(%add%/10)
$goTo startloop
$label doneloop
$eval maxloopdepth %cnt%-1
$onEchoV > inc.gms
set i /1*%maxi%/; alias(i,ii);
file fx /incx.gms/;
put fx '$echo set i; > i1.inc ' /;
loop((i,ii)$sameas(i,ii-1), put '$echo $include i'i.tl:0'.inc > i'ii.tl:0'.inc' /);
putclose '$include i%maxi%.inc';
$offEcho
$set cnt 0
$label startinc
$eval cnt %cnt%+1
$call gams inc.gms --maxi=%cnt% lo=0 && gams incx.gms lo=0
$if errorlevel 1 $goTo stopinc
$goTo startinc
$label stopinc
$clearError
$eval maxincdepth %cnt%+1-1
$log 'Maximum identifier length: ' %maxidlength%
$log 'Maximum explanatory text length: ' %maxetlength%
$log 'Maximum number of indices: ' %maxidxlength%
$log 'Maximum input line length: ' %maxillength%
$log 'Maximum loop depths: ' %maxloopdepth%
$log 'Maximum nested includefile depths:' %maxincdepth%
$set expidlength 63
$set expetlength 255
$set expidxlength 20
$set expillength 80000
$set exploopdepth 299
$set expincdepth 40
Abort$(%maxidlength%<>%expidlength%) 'Maximum identifier length should be %expidlength%'
Abort$(%maxetlength%<>%expetlength%) 'Maximum explanatory text length should be %expetlength%'
Abort$(%maxidxlength%<>%expidxlength%) 'Maximum number of indices be %expidxlength%'
Abort$(%maxillength%<>%expillength%) 'Maximum input line length should be %expillength%'
Abort$(%maxloopdepth%<>%exploopdepth%) 'Maximum loop depths should be %exploopdepth%'
Abort$(%maxincdepth%<>%expincdepth%) 'Maximum nested includefile depths should be %expincdepth%'