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 = sand(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in sand-prod statement';
x = sor(rs, prod(subrs(rs), 2));
abort$(x<>1) 'Error in sor-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 = sand(rs, smin(subrs(rs), 2));
abort$(x<>1) 'Error in sand-smin statement';
x = sor(rs, smin(subrs(rs), 2));
abort$(x<>1) 'Error in sor-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 = sand(rs, smax(subrs(rs), 2));
abort$(x<>1) 'Error in sand-smax statement';
x = sor(rs, smax(subrs(rs), 2));
abort$(x<>1) 'Error in sor-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';
x = sand(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in sand-sum statement';
x = sor(rs, sum(subrs(rs), 2));
abort$(x<>0) 'Error in sor-sum statement';

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

x = sor(subrs(rs), 2);
abort$(x<>0) 'Error in sor statement';
x = prod(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in prod-sor statement';
x = sum(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in sum-sor statement';
x = smin(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in smin-sor statement';
x = smax(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in smax-sor statement';
x = sand(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in sand-sor statement';
x = sor(rs, sor(subrs(rs), 2));
abort$(x<>0) 'Error in sor-sor 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';