GAMS [ Home | Support | Sales | Solvers | Documentation | Model Library | Search | Contact Us ]

ifstat5.gms : Tests $if/$ifi/$ife statements


Tests compile-time if tests, especially the new $ife test

For ife  expr1 == expr2   true if (expr1-expr2)/(1+abs(expr2)) < 1e-12
For ife  expr1            true if expr1 <> 0

Contributor: Alex Meeraus

Small Model of Type: GAMS
$title 'Tests $if/$ifi/$ife statements' (IFSTAT5,SEQ=325) $ontext Tests compile-time if tests, especially the new $ife test For ife expr1 == expr2 true if (expr1-expr2)/(1+abs(expr2)) < 1e-12 For ife expr1 true if expr1 <> 0 Contributor: Alex Meeraus $offtext $ondollar $if NOT '' $abort line %system.line% $if NOT "" $abort line %system.line% $if 'x' $abort line %system.line% $if NOT '1111' == '1111' $abort line %system.line% $if NOT '1111'== "1111" $abort line %system.line% $if NOT "1111" =='1111' $abort line %system.line% $if NOT '1111'=='1111' $abort line %system.line% $if NOT 1111 == 1111 $abort line %system.line% $if NOT 1111== 1111 $abort line %system.line% $if NOT 1111 ==1111 $abort line %system.line% $if NOT 1111==1111 $abort line %system.line% $if NOT 1111 == '1111' $abort line %system.line% $if NOT 1111== '1111' $abort line %system.line% $if NOT 1111 =='1111' $abort line %system.line% $if NOT 1111=='1111' $abort line %system.line% $if NOT '1111'== 1111 $abort line %system.line% $if NOT '1111'== 1111 $abort line %system.line% $if NOT '1111' ==1111 $abort line %system.line% $if NOT '1111'==1111 $abort line %system.line% $if 'aaaa' == 'AAAA' $abort line %system.line% $ifi NOT 'aaaa' == 'AAAA' $abort line %system.line% $ife NOT 001 == 1 $abort line %system.line% $if 001 == 1 $abort line %system.line% $ife 2>3 == 1 $abort line %system.line% $ife 2>=3 == 1 $abort line %system.line% $ife 2<>3 == 0 $abort line %system.line% $ife 2=3 == 1 $abort line %system.line% $ife 2<3 == 0 $abort line %system.line% $ife 2<=3 == 0 $abort line %system.line% $ife '2 GT 3' == 1 $abort line %system.line% $ife '2 GE 3' == 1 $abort line %system.line% $ife '2 NE 3' == 0 $abort line %system.line% $ife '2 EQ 3' == 1 $abort line %system.line% $ife '2 LT 3' == 0 $abort line %system.line% $ife '2 LE 3' == 0 $abort line %system.line% $ife 2>2 == 1 $abort line %system.line% $ife 2>=2 == 0 $abort line %system.line% $ife 2<>2 == 1 $abort line %system.line% $ife 2=2 == 0 $abort line %system.line% $ife 2<2 == 1 $abort line %system.line% $ife 2<=2 == 0 $abort line %system.line% $ife '2 GT 2' == 1 $abort line %system.line% $ife '2 GE 2' == 0 $abort line %system.line% $ife '2 NE 2' == 1 $abort line %system.line% $ife '2 EQ 2' == 0 $abort line %system.line% $ife '2 LT 2' == 1 $abort line %system.line% $ife '2 LE 2' == 0 $abort line %system.line% $ife NOT 4/2 == 2 $abort line %system.line% $ife NOT 3/2 == 1.5 $abort line %system.line% $ife NOT 3*2 == 6 $abort line %system.line% $ife NOT 3+2 == 5 $abort line %system.line% $ife NOT 3-2 == 1 $abort line %system.line% $ife NOT 2^3 == 8 $abort line %system.line% $ife NOT 3-2 == 1 $abort line %system.line% $ife NOT log2(16)^2 == 16 $abort line %system.line% $ife NOT sqr(log2(16)) == 16 $abort line %system.line% $ife NOT power(log2(16),2) == 16 $abort line %system.line% $ife NOT exp(log(16)) == 16 $abort line %system.line% $ife NOT 10**log10(16) == 16 $abort line %system.line% $ife NOT round(123.456) == 123 $abort line %system.line% $ife NOT round(123.456,0) == 123 $abort line %system.line% $ife NOT round(123.456,1) == 123.5 $abort line %system.line% $ife NOT round(123.456,2) == 123.46 $abort line %system.line% $ife NOT round(123.456,3) == 123.456 $abort line %system.line% $ife NOT round(123.456,5) == 123.456 $abort line %system.line% $ife NOT round(123.456,-1) == 120 $abort line %system.line% $ife NOT round(123.456,-2) == 100 $abort line %system.line% $ife NOT round(123.456,-3) == 0 $abort line %system.line% $ife NOT ifthen(1+1,2,3) == 2 $abort line %system.line% $ife NOT ifthen(1-1,2,3) == 3 $abort line %system.line% $ife NOT max(-1,+1) == 1 $abort line %system.line% $ife NOT min(-1,+1) == -1 $abort line %system.line% $ife NOT min(-1,+1,3,max(1,2,3,40),3) == -1 $abort line %system.line% $ife NOT sqr(sin(.5))+sqr(cos(.5)) == 1 $abort line %system.line% $ife sqr(sin(.5))+sqr(cos(.5))-1 $abort line %system.line% $ife 0 $abort line %system.line% $ife NOT 1e-300 $abort line %system.line% $ife 1e-300=0 $abort line %system.line% $ife ' 1e-300 = 0 ' $abort line %system.line% $ife NOT 1e-300 == 0 $abort line %system.line% $ife NOT '1e-300'==0 $abort line %system.line%