vardat05.gms : test table var/equ data statements with $onMulti

Description

Contributor: Alex Meeraus


Small Model of Type : GAMS


Category : GAMS Test library


Main file : vardat05.gms

$title 'test table var/equ data statements with $onMulti' (VARDAT05,SEQ=378)

$onText
Contributor: Alex Meeraus
$offText

$if not gamsversion 227 $exit

* note that the var/equ statement does not create 'l' .. as UELs

set i / 1*3 /, j /a*c/;
free variable y(i)
*parameter y(i,*)
table y
    l     up    lo
2  10     10    0.0

$onMulti
table y
    l    scale
1  20     20
3  20

table y
   l  m  scale  lo
2 30 30   30
3 30 30   30    0.0
*display y;

table py(i,*)
            l          up       scale           m   lo

1      20.000         inf      20.000               -inf
2      30.000      10.000      30.000      30.000   0.0
3      30.000         inf      30.000      30.000   0.0

display y.l,y.m,y.lo,y.up,y.scale;

abort$sum(i, y.l(i)     <> py(i,'l')) 'bad .l';
abort$sum(i, y.m(i)     <> py(i,'m')) 'bad .m';
abort$sum(i, y.lo(i)    <> py(i,'lo')) 'bad .lo';
abort$sum(i, y.up(i)    <> py(i,'up')) 'bad .up';
abort$sum(i, y.scale(i) <> py(i,'scale')) 'bad .scale';

* use same data as in vardat04

$set data   (1,2).a.l 20, 2.a.up 50, 3.a.m 60, 1.(a,c).scale 100, 2.a.lo 0
$set update (1 1, 2 2, 3 3).(a 1.1,b 1.2, c 1.3).l

variable table x(i,j)  '/ %data%, 3.a.fx 70 /'
        l    m     lo     up    scale
1.a    20                         100
1.c                               100
2.a    20           0     50
3.a    70   60     70     70

$onMulti
* note the embedded data definitions
table x(i,j) '/ %update% /'
       l
1.a   1.1
1.b   1.2
1.c   1.3
2.a   2.2
2.b   2.4
2.c   2.6
3.a   3.3
3.b   3.6
3.c   3.9

$offMulti
* default was set to free
parameter px (i,j,*) / 1*3.a*c.lo -inf, 1*3.a*c.up inf, 1*3.a*c.scale 1  /
* not the zero in %data%
$onMulti
          px (i,j,*) / %data%, 3.a.(l,lo,up) 70 /
          px (i,j,*) / %update% /

$offMulti
display x.l,x.m,x.lo,x.up,x.scale,px;

* note that  1.1*3 <> 3.3  off by 1e-16
parameter diff; diff(i,j) = px(i,j,'l')-x.l(i,j);  display diff;

abort$sum((i,j), abs(px(i,j,'l')-x.l(i,j)) >1e-10) 'incorrect .l';
abort$sum((i,j), px(i,j,'m')     <> x.m(i,j))      'incorrect .m';
abort$sum((i,j), px(i,j,'lo')    <> x.lo(i,j))     'incorrect .lo';
abort$sum((i,j), px(i,j,'up')    <> x.up(i,j))     'incorrect .up';
abort$sum((i,j), px(i,j,'scale') <> x.scale(i,j))  'incorrect .scale';