idxoper1.gms : Test indexed operations

Description

This test makes sure that indexed operations over empty sets work as expected.

Contributor: Lutz Westermann, April 2014


Small Model of Type : GAMS


Category : GAMS Test library


Main file : idxoper1.gms

$title 'Test indexed operations' (idxoper1,SEQ=661)

$ontext
This test makes sure that indexed operations over empty sets work as expected.

Contributor: Lutz Westermann, April 2014
$offtext


set r / 1 /;
set s / 1, 2 /;
set rs(r,s) / 1.1 /;
set subrs(r,s) / 1.2 /;
scalars x;

x = prod(subrs(rs), 2);
abort$(x<>1) 'Error in prod statement';
x = prod(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in prod-prod statement';
x = sum(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in sum-prod statement';
x = smin(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in smin-prod statement';
x = smax(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in smax-prod statement';

x = smin(subrs(rs), 2);
abort$(x<>+inf) 'Error in smin statement';
x = prod(rs, smin(subrs(rs), 2));
abort$(x<>+inf) 'Error in prod-smin statement';
x = sum(rs, smin(subrs(rs), 2));
abort$(x<>+inf) 'Error in sum-smin statement';
x = smin(rs, smin(subrs(rs), 2));
abort$(x<>+inf) 'Error in smin-smin statement';
x = smax(rs, smin(subrs(rs), 2));
abort$(x<>+inf) 'Error in smax-smin statement';

x = smax(subrs(rs), 2);
abort$(x<>-inf) 'Error in smax statement';
x = prod(rs, smax(subrs(rs), 2));
abort$(x<>-inf) 'Error in prod-smax statement';
x = sum(rs, smax(subrs(rs), 2));
abort$(x<>-inf) 'Error in sum-smax statement';
x = smin(rs, smax(subrs(rs), 2));
abort$(x<>-inf) 'Error in smin-smax statement';
x = smax(rs, smax(subrs(rs), 2));
abort$(x<>-inf) 'Error in smax-smax statement';

x = sum(subrs(rs), 2);
abort$(x<>0) 'Error in sum statement';
x = prod(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in prod-sum statement';
x = sum(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in sum-sum statement';
x = smin(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in smin-sum statement';
x = smax(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in smax-sum statement';

* Check that smin value is exact
parameter p(s) / 1 1, 2 0.01 /;
scalar pmin, ords /-1/;
pmin = smin(s, p(s));
loop(s$(pmin=p(s)), ords = ord(s));
abort$(ords=-1) 'did not enter loop';